]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.11.6-201311021635.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.11.6-201311021635.patch
1 diff --git a/Documentation/dontdiff b/Documentation/dontdiff
2 index b89a739..79768fb 100644
3 --- a/Documentation/dontdiff
4 +++ b/Documentation/dontdiff
5 @@ -2,9 +2,11 @@
6 *.aux
7 *.bin
8 *.bz2
9 +*.c.[012]*.*
10 *.cis
11 *.cpio
12 *.csp
13 +*.dbg
14 *.dsp
15 *.dvi
16 *.elf
17 @@ -14,6 +16,7 @@
18 *.gcov
19 *.gen.S
20 *.gif
21 +*.gmo
22 *.grep
23 *.grp
24 *.gz
25 @@ -48,14 +51,17 @@
26 *.tab.h
27 *.tex
28 *.ver
29 +*.vim
30 *.xml
31 *.xz
32 *_MODULES
33 +*_reg_safe.h
34 *_vga16.c
35 *~
36 \#*#
37 *.9
38 -.*
39 +.[^g]*
40 +.gen*
41 .*.d
42 .mm
43 53c700_d.h
44 @@ -69,9 +75,11 @@ Image
45 Module.markers
46 Module.symvers
47 PENDING
48 +PERF*
49 SCCS
50 System.map*
51 TAGS
52 +TRACEEVENT-CFLAGS
53 aconf
54 af_names.h
55 aic7*reg.h*
56 @@ -80,6 +88,7 @@ aic7*seq.h*
57 aicasm
58 aicdb.h*
59 altivec*.c
60 +ashldi3.S
61 asm-offsets.h
62 asm_offsets.h
63 autoconf.h*
64 @@ -92,19 +101,24 @@ bounds.h
65 bsetup
66 btfixupprep
67 build
68 +builtin-policy.h
69 bvmlinux
70 bzImage*
71 capability_names.h
72 capflags.c
73 classlist.h*
74 +clut_vga16.c
75 +common-cmds.h
76 comp*.log
77 compile.h*
78 conf
79 config
80 config-*
81 config_data.h*
82 +config.c
83 config.mak
84 config.mak.autogen
85 +config.tmp
86 conmakehash
87 consolemap_deftbl.c*
88 cpustr.h
89 @@ -115,9 +129,11 @@ devlist.h*
90 dnotify_test
91 docproc
92 dslm
93 +dtc-lexer.lex.c
94 elf2ecoff
95 elfconfig.h*
96 evergreen_reg_safe.h
97 +exception_policy.conf
98 fixdep
99 flask.h
100 fore200e_mkfirm
101 @@ -125,12 +141,15 @@ fore200e_pca_fw.c*
102 gconf
103 gconf.glade.h
104 gen-devlist
105 +gen-kdb_cmds.c
106 gen_crc32table
107 gen_init_cpio
108 generated
109 genheaders
110 genksyms
111 *_gray256.c
112 +hash
113 +hid-example
114 hpet_example
115 hugepage-mmap
116 hugepage-shm
117 @@ -145,14 +164,14 @@ int32.c
118 int4.c
119 int8.c
120 kallsyms
121 -kconfig
122 +kern_constants.h
123 keywords.c
124 ksym.c*
125 ksym.h*
126 kxgettext
127 lex.c
128 lex.*.c
129 -linux
130 +lib1funcs.S
131 logo_*.c
132 logo_*_clut224.c
133 logo_*_mono.c
134 @@ -162,14 +181,15 @@ mach-types.h
135 machtypes.h
136 map
137 map_hugetlb
138 -media
139 mconf
140 +mdp
141 miboot*
142 mk_elfconfig
143 mkboot
144 mkbugboot
145 mkcpustr
146 mkdep
147 +mkpiggy
148 mkprep
149 mkregtable
150 mktables
151 @@ -185,6 +205,8 @@ oui.c*
152 page-types
153 parse.c
154 parse.h
155 +parse-events*
156 +pasyms.h
157 patches*
158 pca200e.bin
159 pca200e_ecd.bin2
160 @@ -194,6 +216,7 @@ perf-archive
161 piggyback
162 piggy.gzip
163 piggy.S
164 +pmu-*
165 pnmtologo
166 ppc_defs.h*
167 pss_boot.h
168 @@ -203,7 +226,10 @@ r200_reg_safe.h
169 r300_reg_safe.h
170 r420_reg_safe.h
171 r600_reg_safe.h
172 +realmode.lds
173 +realmode.relocs
174 recordmcount
175 +regdb.c
176 relocs
177 rlim_names.h
178 rn50_reg_safe.h
179 @@ -213,8 +239,12 @@ series
180 setup
181 setup.bin
182 setup.elf
183 +signing_key*
184 +size_overflow_hash.h
185 sImage
186 +slabinfo
187 sm_tbl*
188 +sortextable
189 split-include
190 syscalltab.h
191 tables.c
192 @@ -224,6 +254,7 @@ tftpboot.img
193 timeconst.h
194 times.h*
195 trix_boot.h
196 +user_constants.h
197 utsrelease.h*
198 vdso-syms.lds
199 vdso.lds
200 @@ -235,13 +266,17 @@ vdso32.lds
201 vdso32.so.dbg
202 vdso64.lds
203 vdso64.so.dbg
204 +vdsox32.lds
205 +vdsox32-syms.lds
206 version.h*
207 vmImage
208 vmlinux
209 vmlinux-*
210 vmlinux.aout
211 vmlinux.bin.all
212 +vmlinux.bin.bz2
213 vmlinux.lds
214 +vmlinux.relocs
215 vmlinuz
216 voffset.h
217 vsyscall.lds
218 @@ -249,9 +284,12 @@ vsyscall_32.lds
219 wanxlfw.inc
220 uImage
221 unifdef
222 +utsrelease.h
223 wakeup.bin
224 wakeup.elf
225 wakeup.lds
226 +x509*
227 zImage*
228 zconf.hash.c
229 +zconf.lex.c
230 zoffset.h
231 diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
232 index 7f9d4f5..6d1afd6 100644
233 --- a/Documentation/kernel-parameters.txt
234 +++ b/Documentation/kernel-parameters.txt
235 @@ -976,6 +976,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
236 Format: <unsigned int> such that (rxsize & ~0x1fffc0) == 0.
237 Default: 1024
238
239 + grsec_proc_gid= [GRKERNSEC_PROC_USERGROUP] Chooses GID to
240 + ignore grsecurity's /proc restrictions
241 +
242 +
243 hashdist= [KNL,NUMA] Large hashes allocated during boot
244 are distributed across NUMA nodes. Defaults on
245 for 64-bit NUMA, off otherwise.
246 @@ -1932,6 +1936,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 noexec=on: enable non-executable mappings (default)
248 noexec=off: disable non-executable mappings
249
250 + nopcid [X86-64]
251 + Disable PCID (Process-Context IDentifier) even if it
252 + is supported by the processor.
253 +
254 nosmap [X86]
255 Disable SMAP (Supervisor Mode Access Prevention)
256 even if it is supported by processor.
257 @@ -2199,6 +2207,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
258 the specified number of seconds. This is to be used if
259 your oopses keep scrolling off the screen.
260
261 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
262 + virtualization environments that don't cope well with the
263 + expand down segment used by UDEREF on X86-32 or the frequent
264 + page table updates on X86-64.
265 +
266 + pax_sanitize_slab=
267 + 0/1 to disable/enable slab object sanitization (enabled by
268 + default).
269 +
270 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
271 +
272 + pax_extra_latent_entropy
273 + Enable a very simple form of latent entropy extraction
274 + from the first 4GB of memory as the bootmem allocator
275 + passes the memory pages to the buddy allocator.
276 +
277 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
278 + when the processor supports PCID.
279 +
280 pcbit= [HW,ISDN]
281
282 pcd. [PARIDE]
283 diff --git a/Makefile b/Makefile
284 index e87ba83..ee3c7b7 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 # Store (new) KERNELRELEASE string in include/config/kernel.release
403 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -942,6 +1005,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1063,6 +1128,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1224,6 +1290,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1363,17 +1431,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1383,11 +1455,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index 78b03ef..da28a51 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index d8f9b7e..f6222fa 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index 1402fcc..0b1abd2 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 0c4132d..88f0d53 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 43594d5..da71e62 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1791,7 +1791,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 17d0ae8..014e350 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index 56211f2..17e8a25 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index 12f71a1..04e063c 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __no_const;
1803
1804 #ifdef CONFIG_OUTER_CACHE
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index 4355f0e..c229913 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 626989f..9d67a33 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -75,6 +75,7 @@
1935 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1936 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1937 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1938 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1939 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1940
1941 /*
1942 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1943 index 5689c18..eea12f9 100644
1944 --- a/arch/arm/include/asm/pgtable-3level.h
1945 +++ b/arch/arm/include/asm/pgtable-3level.h
1946 @@ -82,6 +82,7 @@
1947 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1948 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1949 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1950 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1951 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1952 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1953 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1954 @@ -95,6 +96,7 @@
1955 /*
1956 * To be used in assembly code with the upper page attributes.
1957 */
1958 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1959 #define L_PTE_XN_HIGH (1 << (54 - 32))
1960 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1961
1962 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1963 index 04aeb02..73b70dd 100644
1964 --- a/arch/arm/include/asm/pgtable.h
1965 +++ b/arch/arm/include/asm/pgtable.h
1966 @@ -33,6 +33,9 @@
1967 #include <asm/pgtable-2level.h>
1968 #endif
1969
1970 +#define ktla_ktva(addr) (addr)
1971 +#define ktva_ktla(addr) (addr)
1972 +
1973 /*
1974 * Just any arbitrary offset to the start of the vmalloc VM area: the
1975 * current 8MB value just means that there will be a 8MB "hole" after the
1976 @@ -48,6 +51,9 @@
1977 #define LIBRARY_TEXT_START 0x0c000000
1978
1979 #ifndef __ASSEMBLY__
1980 +extern pteval_t __supported_pte_mask;
1981 +extern pmdval_t __supported_pmd_mask;
1982 +
1983 extern void __pte_error(const char *file, int line, pte_t);
1984 extern void __pmd_error(const char *file, int line, pmd_t);
1985 extern void __pgd_error(const char *file, int line, pgd_t);
1986 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1987 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1988 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1989
1990 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1991 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1992 +
1993 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1994 +#include <asm/domain.h>
1995 +#include <linux/thread_info.h>
1996 +#include <linux/preempt.h>
1997 +
1998 +static inline int test_domain(int domain, int domaintype)
1999 +{
2000 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2001 +}
2002 +#endif
2003 +
2004 +#ifdef CONFIG_PAX_KERNEXEC
2005 +static inline unsigned long pax_open_kernel(void) {
2006 +#ifdef CONFIG_ARM_LPAE
2007 + /* TODO */
2008 +#else
2009 + preempt_disable();
2010 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2011 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2012 +#endif
2013 + return 0;
2014 +}
2015 +
2016 +static inline unsigned long pax_close_kernel(void) {
2017 +#ifdef CONFIG_ARM_LPAE
2018 + /* TODO */
2019 +#else
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2021 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2022 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2023 + preempt_enable_no_resched();
2024 +#endif
2025 + return 0;
2026 +}
2027 +#else
2028 +static inline unsigned long pax_open_kernel(void) { return 0; }
2029 +static inline unsigned long pax_close_kernel(void) { return 0; }
2030 +#endif
2031 +
2032 /*
2033 * This is the lowest virtual address we can permit any user space
2034 * mapping to be mapped at. This is particularly important for
2035 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2036 /*
2037 * The pgprot_* and protection_map entries will be fixed up in runtime
2038 * to include the cachable and bufferable bits based on memory policy,
2039 - * as well as any architecture dependent bits like global/ASID and SMP
2040 - * shared mapping bits.
2041 + * as well as any architecture dependent bits like global/ASID, PXN,
2042 + * and SMP shared mapping bits.
2043 */
2044 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2045
2046 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2047 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2048 {
2049 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2050 - L_PTE_NONE | L_PTE_VALID;
2051 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2052 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2053 return pte;
2054 }
2055 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2056 index 5324c11..bcae5f0 100644
2057 --- a/arch/arm/include/asm/proc-fns.h
2058 +++ b/arch/arm/include/asm/proc-fns.h
2059 @@ -75,7 +75,7 @@ extern struct processor {
2060 unsigned int suspend_size;
2061 void (*do_suspend)(void *);
2062 void (*do_resume)(void *);
2063 -} processor;
2064 +} __do_const processor;
2065
2066 #ifndef MULTI_CPU
2067 extern void cpu_proc_init(void);
2068 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2069 index c4ae171..ea0c0c2 100644
2070 --- a/arch/arm/include/asm/psci.h
2071 +++ b/arch/arm/include/asm/psci.h
2072 @@ -29,7 +29,7 @@ struct psci_operations {
2073 int (*cpu_off)(struct psci_power_state state);
2074 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2075 int (*migrate)(unsigned long cpuid);
2076 -};
2077 +} __no_const;
2078
2079 extern struct psci_operations psci_ops;
2080 extern struct smp_operations psci_smp_ops;
2081 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2082 index a8cae71c..65dd797 100644
2083 --- a/arch/arm/include/asm/smp.h
2084 +++ b/arch/arm/include/asm/smp.h
2085 @@ -110,7 +110,7 @@ struct smp_operations {
2086 int (*cpu_disable)(unsigned int cpu);
2087 #endif
2088 #endif
2089 -};
2090 +} __no_const;
2091
2092 /*
2093 * set platform specific SMP operations
2094 diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h
2095 index f1d96d4..73ddd72 100644
2096 --- a/arch/arm/include/asm/syscall.h
2097 +++ b/arch/arm/include/asm/syscall.h
2098 @@ -57,6 +57,9 @@ static inline void syscall_get_arguments(struct task_struct *task,
2099 unsigned int i, unsigned int n,
2100 unsigned long *args)
2101 {
2102 + if (n == 0)
2103 + return;
2104 +
2105 if (i + n > SYSCALL_MAX_ARGS) {
2106 unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i;
2107 unsigned int n_bad = n + i - SYSCALL_MAX_ARGS;
2108 @@ -81,6 +84,9 @@ static inline void syscall_set_arguments(struct task_struct *task,
2109 unsigned int i, unsigned int n,
2110 const unsigned long *args)
2111 {
2112 + if (n == 0)
2113 + return;
2114 +
2115 if (i + n > SYSCALL_MAX_ARGS) {
2116 pr_warning("%s called with max args %d, handling only %d\n",
2117 __func__, i + n, SYSCALL_MAX_ARGS);
2118 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2119 index 2b8114f..8fe9bcf 100644
2120 --- a/arch/arm/include/asm/thread_info.h
2121 +++ b/arch/arm/include/asm/thread_info.h
2122 @@ -77,9 +77,9 @@ struct thread_info {
2123 .flags = 0, \
2124 .preempt_count = INIT_PREEMPT_COUNT, \
2125 .addr_limit = KERNEL_DS, \
2126 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2127 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2128 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2129 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2130 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2131 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2132 .restart_block = { \
2133 .fn = do_no_restart_syscall, \
2134 }, \
2135 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2136 #define TIF_SYSCALL_AUDIT 9
2137 #define TIF_SYSCALL_TRACEPOINT 10
2138 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2139 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2140 +/* within 8 bits of TIF_SYSCALL_TRACE
2141 + * to meet flexible second operand requirements
2142 + */
2143 +#define TIF_GRSEC_SETXID 12
2144 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2145 #define TIF_USING_IWMMXT 17
2146 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2147 #define TIF_RESTORE_SIGMASK 20
2148 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2149 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2150 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2151 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2152 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2153
2154 /* Checks for any syscall work in entry-common.S */
2155 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2156 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2157 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2158
2159 /*
2160 * Change these and you break ASM code in entry-common.S
2161 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2162 index 7e1f760..de33b13 100644
2163 --- a/arch/arm/include/asm/uaccess.h
2164 +++ b/arch/arm/include/asm/uaccess.h
2165 @@ -18,6 +18,7 @@
2166 #include <asm/domain.h>
2167 #include <asm/unified.h>
2168 #include <asm/compiler.h>
2169 +#include <asm/pgtable.h>
2170
2171 #define VERIFY_READ 0
2172 #define VERIFY_WRITE 1
2173 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2174 static inline void set_fs(mm_segment_t fs)
2175 {
2176 current_thread_info()->addr_limit = fs;
2177 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2178 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2179 }
2180
2181 #define segment_eq(a,b) ((a) == (b))
2182
2183 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2184 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2185 +
2186 +static inline void pax_open_userland(void)
2187 +{
2188 +
2189 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2190 + if (segment_eq(get_fs(), USER_DS)) {
2191 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2192 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2193 + }
2194 +#endif
2195 +
2196 +}
2197 +
2198 +static inline void pax_close_userland(void)
2199 +{
2200 +
2201 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2202 + if (segment_eq(get_fs(), USER_DS)) {
2203 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2204 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2205 + }
2206 +#endif
2207 +
2208 +}
2209 +
2210 #define __addr_ok(addr) ({ \
2211 unsigned long flag; \
2212 __asm__("cmp %2, %0; movlo %0, #0" \
2213 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2214
2215 #define get_user(x,p) \
2216 ({ \
2217 + int __e; \
2218 might_fault(); \
2219 - __get_user_check(x,p); \
2220 + pax_open_userland(); \
2221 + __e = __get_user_check(x,p); \
2222 + pax_close_userland(); \
2223 + __e; \
2224 })
2225
2226 extern int __put_user_1(void *, unsigned int);
2227 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2228
2229 #define put_user(x,p) \
2230 ({ \
2231 + int __e; \
2232 might_fault(); \
2233 - __put_user_check(x,p); \
2234 + pax_open_userland(); \
2235 + __e = __put_user_check(x,p); \
2236 + pax_close_userland(); \
2237 + __e; \
2238 })
2239
2240 #else /* CONFIG_MMU */
2241 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2242 #define __get_user(x,ptr) \
2243 ({ \
2244 long __gu_err = 0; \
2245 + pax_open_userland(); \
2246 __get_user_err((x),(ptr),__gu_err); \
2247 + pax_close_userland(); \
2248 __gu_err; \
2249 })
2250
2251 #define __get_user_error(x,ptr,err) \
2252 ({ \
2253 + pax_open_userland(); \
2254 __get_user_err((x),(ptr),err); \
2255 + pax_close_userland(); \
2256 (void) 0; \
2257 })
2258
2259 @@ -312,13 +352,17 @@ do { \
2260 #define __put_user(x,ptr) \
2261 ({ \
2262 long __pu_err = 0; \
2263 + pax_open_userland(); \
2264 __put_user_err((x),(ptr),__pu_err); \
2265 + pax_close_userland(); \
2266 __pu_err; \
2267 })
2268
2269 #define __put_user_error(x,ptr,err) \
2270 ({ \
2271 + pax_open_userland(); \
2272 __put_user_err((x),(ptr),err); \
2273 + pax_close_userland(); \
2274 (void) 0; \
2275 })
2276
2277 @@ -418,11 +462,44 @@ do { \
2278
2279
2280 #ifdef CONFIG_MMU
2281 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2282 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2283 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2284 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2285 +
2286 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2287 +{
2288 + unsigned long ret;
2289 +
2290 + check_object_size(to, n, false);
2291 + pax_open_userland();
2292 + ret = ___copy_from_user(to, from, n);
2293 + pax_close_userland();
2294 + return ret;
2295 +}
2296 +
2297 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2298 +{
2299 + unsigned long ret;
2300 +
2301 + check_object_size(from, n, true);
2302 + pax_open_userland();
2303 + ret = ___copy_to_user(to, from, n);
2304 + pax_close_userland();
2305 + return ret;
2306 +}
2307 +
2308 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2309 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2310 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2311 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2312 +
2313 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2314 +{
2315 + unsigned long ret;
2316 + pax_open_userland();
2317 + ret = ___clear_user(addr, n);
2318 + pax_close_userland();
2319 + return ret;
2320 +}
2321 +
2322 #else
2323 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2324 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2325 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2326
2327 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2328 {
2329 + if ((long)n < 0)
2330 + return n;
2331 +
2332 if (access_ok(VERIFY_READ, from, n))
2333 n = __copy_from_user(to, from, n);
2334 else /* security hole - plug it */
2335 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2336
2337 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2338 {
2339 + if ((long)n < 0)
2340 + return n;
2341 +
2342 if (access_ok(VERIFY_WRITE, to, n))
2343 n = __copy_to_user(to, from, n);
2344 return n;
2345 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2346 index 5af0ed1..cea83883 100644
2347 --- a/arch/arm/include/uapi/asm/ptrace.h
2348 +++ b/arch/arm/include/uapi/asm/ptrace.h
2349 @@ -92,7 +92,7 @@
2350 * ARMv7 groups of PSR bits
2351 */
2352 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2353 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2354 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2355 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2356 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2357
2358 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2359 index 60d3b73..e5a0f22 100644
2360 --- a/arch/arm/kernel/armksyms.c
2361 +++ b/arch/arm/kernel/armksyms.c
2362 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2363
2364 /* networking */
2365 EXPORT_SYMBOL(csum_partial);
2366 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2367 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2368 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2369 EXPORT_SYMBOL(__csum_ipv6_magic);
2370
2371 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2372 #ifdef CONFIG_MMU
2373 EXPORT_SYMBOL(copy_page);
2374
2375 -EXPORT_SYMBOL(__copy_from_user);
2376 -EXPORT_SYMBOL(__copy_to_user);
2377 -EXPORT_SYMBOL(__clear_user);
2378 +EXPORT_SYMBOL(___copy_from_user);
2379 +EXPORT_SYMBOL(___copy_to_user);
2380 +EXPORT_SYMBOL(___clear_user);
2381
2382 EXPORT_SYMBOL(__get_user_1);
2383 EXPORT_SYMBOL(__get_user_2);
2384 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2385 index 9cbe70c..a7b5e34 100644
2386 --- a/arch/arm/kernel/entry-armv.S
2387 +++ b/arch/arm/kernel/entry-armv.S
2388 @@ -47,6 +47,87 @@
2389 9997:
2390 .endm
2391
2392 + .macro pax_enter_kernel
2393 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2394 + @ make aligned space for saved DACR
2395 + sub sp, sp, #8
2396 + @ save regs
2397 + stmdb sp!, {r1, r2}
2398 + @ read DACR from cpu_domain into r1
2399 + mov r2, sp
2400 + @ assume 8K pages, since we have to split the immediate in two
2401 + bic r2, r2, #(0x1fc0)
2402 + bic r2, r2, #(0x3f)
2403 + ldr r1, [r2, #TI_CPU_DOMAIN]
2404 + @ store old DACR on stack
2405 + str r1, [sp, #8]
2406 +#ifdef CONFIG_PAX_KERNEXEC
2407 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2408 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2409 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2410 +#endif
2411 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2412 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2413 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2414 +#endif
2415 + @ write r1 to current_thread_info()->cpu_domain
2416 + str r1, [r2, #TI_CPU_DOMAIN]
2417 + @ write r1 to DACR
2418 + mcr p15, 0, r1, c3, c0, 0
2419 + @ instruction sync
2420 + instr_sync
2421 + @ restore regs
2422 + ldmia sp!, {r1, r2}
2423 +#endif
2424 + .endm
2425 +
2426 + .macro pax_open_userland
2427 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2428 + @ save regs
2429 + stmdb sp!, {r0, r1}
2430 + @ read DACR from cpu_domain into r1
2431 + mov r0, sp
2432 + @ assume 8K pages, since we have to split the immediate in two
2433 + bic r0, r0, #(0x1fc0)
2434 + bic r0, r0, #(0x3f)
2435 + ldr r1, [r0, #TI_CPU_DOMAIN]
2436 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2437 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2438 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2439 + @ write r1 to current_thread_info()->cpu_domain
2440 + str r1, [r0, #TI_CPU_DOMAIN]
2441 + @ write r1 to DACR
2442 + mcr p15, 0, r1, c3, c0, 0
2443 + @ instruction sync
2444 + instr_sync
2445 + @ restore regs
2446 + ldmia sp!, {r0, r1}
2447 +#endif
2448 + .endm
2449 +
2450 + .macro pax_close_userland
2451 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2452 + @ save regs
2453 + stmdb sp!, {r0, r1}
2454 + @ read DACR from cpu_domain into r1
2455 + mov r0, sp
2456 + @ assume 8K pages, since we have to split the immediate in two
2457 + bic r0, r0, #(0x1fc0)
2458 + bic r0, r0, #(0x3f)
2459 + ldr r1, [r0, #TI_CPU_DOMAIN]
2460 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2461 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2462 + @ write r1 to current_thread_info()->cpu_domain
2463 + str r1, [r0, #TI_CPU_DOMAIN]
2464 + @ write r1 to DACR
2465 + mcr p15, 0, r1, c3, c0, 0
2466 + @ instruction sync
2467 + instr_sync
2468 + @ restore regs
2469 + ldmia sp!, {r0, r1}
2470 +#endif
2471 + .endm
2472 +
2473 .macro pabt_helper
2474 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2475 #ifdef MULTI_PABORT
2476 @@ -89,11 +170,15 @@
2477 * Invalid mode handlers
2478 */
2479 .macro inv_entry, reason
2480 +
2481 + pax_enter_kernel
2482 +
2483 sub sp, sp, #S_FRAME_SIZE
2484 ARM( stmib sp, {r1 - lr} )
2485 THUMB( stmia sp, {r0 - r12} )
2486 THUMB( str sp, [sp, #S_SP] )
2487 THUMB( str lr, [sp, #S_LR] )
2488 +
2489 mov r1, #\reason
2490 .endm
2491
2492 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2493 .macro svc_entry, stack_hole=0
2494 UNWIND(.fnstart )
2495 UNWIND(.save {r0 - pc} )
2496 +
2497 + pax_enter_kernel
2498 +
2499 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2500 +
2501 #ifdef CONFIG_THUMB2_KERNEL
2502 SPFIX( str r0, [sp] ) @ temporarily saved
2503 SPFIX( mov r0, sp )
2504 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2505 ldmia r0, {r3 - r5}
2506 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2507 mov r6, #-1 @ "" "" "" ""
2508 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2509 + @ offset sp by 8 as done in pax_enter_kernel
2510 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2511 +#else
2512 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2513 +#endif
2514 SPFIX( addeq r2, r2, #4 )
2515 str r3, [sp, #-4]! @ save the "real" r0 copied
2516 @ from the exception stack
2517 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2518 .macro usr_entry
2519 UNWIND(.fnstart )
2520 UNWIND(.cantunwind ) @ don't unwind the user space
2521 +
2522 + pax_enter_kernel_user
2523 +
2524 sub sp, sp, #S_FRAME_SIZE
2525 ARM( stmib sp, {r1 - r12} )
2526 THUMB( stmia sp, {r0 - r12} )
2527 @@ -415,7 +512,9 @@ __und_usr:
2528 tst r3, #PSR_T_BIT @ Thumb mode?
2529 bne __und_usr_thumb
2530 sub r4, r2, #4 @ ARM instr at LR - 4
2531 + pax_open_userland
2532 1: ldrt r0, [r4]
2533 + pax_close_userland
2534 #ifdef CONFIG_CPU_ENDIAN_BE8
2535 rev r0, r0 @ little endian instruction
2536 #endif
2537 @@ -450,10 +549,14 @@ __und_usr_thumb:
2538 */
2539 .arch armv6t2
2540 #endif
2541 + pax_open_userland
2542 2: ldrht r5, [r4]
2543 + pax_close_userland
2544 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2545 blo __und_usr_fault_16 @ 16bit undefined instruction
2546 + pax_open_userland
2547 3: ldrht r0, [r2]
2548 + pax_close_userland
2549 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2550 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2551 orr r0, r0, r5, lsl #16
2552 @@ -482,7 +585,8 @@ ENDPROC(__und_usr)
2553 */
2554 .pushsection .fixup, "ax"
2555 .align 2
2556 -4: mov pc, r9
2557 +4: pax_close_userland
2558 + mov pc, r9
2559 .popsection
2560 .pushsection __ex_table,"a"
2561 .long 1b, 4b
2562 @@ -692,7 +796,7 @@ ENTRY(__switch_to)
2563 THUMB( str lr, [ip], #4 )
2564 ldr r4, [r2, #TI_TP_VALUE]
2565 ldr r5, [r2, #TI_TP_VALUE + 4]
2566 -#ifdef CONFIG_CPU_USE_DOMAINS
2567 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2568 ldr r6, [r2, #TI_CPU_DOMAIN]
2569 #endif
2570 switch_tls r1, r4, r5, r3, r7
2571 @@ -701,7 +805,7 @@ ENTRY(__switch_to)
2572 ldr r8, =__stack_chk_guard
2573 ldr r7, [r7, #TSK_STACK_CANARY]
2574 #endif
2575 -#ifdef CONFIG_CPU_USE_DOMAINS
2576 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2577 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2578 #endif
2579 mov r5, r0
2580 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2581 index 94104bf..e425391 100644
2582 --- a/arch/arm/kernel/entry-common.S
2583 +++ b/arch/arm/kernel/entry-common.S
2584 @@ -10,18 +10,46 @@
2585
2586 #include <asm/unistd.h>
2587 #include <asm/ftrace.h>
2588 +#include <asm/domain.h>
2589 #include <asm/unwind.h>
2590
2591 +#include "entry-header.S"
2592 +
2593 #ifdef CONFIG_NEED_RET_TO_USER
2594 #include <mach/entry-macro.S>
2595 #else
2596 .macro arch_ret_to_user, tmp1, tmp2
2597 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2598 + @ save regs
2599 + stmdb sp!, {r1, r2}
2600 + @ read DACR from cpu_domain into r1
2601 + mov r2, sp
2602 + @ assume 8K pages, since we have to split the immediate in two
2603 + bic r2, r2, #(0x1fc0)
2604 + bic r2, r2, #(0x3f)
2605 + ldr r1, [r2, #TI_CPU_DOMAIN]
2606 +#ifdef CONFIG_PAX_KERNEXEC
2607 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2608 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2609 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2610 +#endif
2611 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2612 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2613 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2614 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2615 +#endif
2616 + @ write r1 to current_thread_info()->cpu_domain
2617 + str r1, [r2, #TI_CPU_DOMAIN]
2618 + @ write r1 to DACR
2619 + mcr p15, 0, r1, c3, c0, 0
2620 + @ instruction sync
2621 + instr_sync
2622 + @ restore regs
2623 + ldmia sp!, {r1, r2}
2624 +#endif
2625 .endm
2626 #endif
2627
2628 -#include "entry-header.S"
2629 -
2630 -
2631 .align 5
2632 /*
2633 * This is the fast syscall return path. We do as little as
2634 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2635 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2636 #endif
2637
2638 + /*
2639 + * do this here to avoid a performance hit of wrapping the code above
2640 + * that directly dereferences userland to parse the SWI instruction
2641 + */
2642 + pax_enter_kernel_user
2643 +
2644 adr tbl, sys_call_table @ load syscall table pointer
2645
2646 #if defined(CONFIG_OABI_COMPAT)
2647 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2648 index de23a9b..94c37c4 100644
2649 --- a/arch/arm/kernel/entry-header.S
2650 +++ b/arch/arm/kernel/entry-header.S
2651 @@ -184,6 +184,60 @@
2652 msr cpsr_c, \rtemp @ switch back to the SVC mode
2653 .endm
2654
2655 + .macro pax_enter_kernel_user
2656 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2657 + @ save regs
2658 + stmdb sp!, {r0, r1}
2659 + @ read DACR from cpu_domain into r1
2660 + mov r0, sp
2661 + @ assume 8K pages, since we have to split the immediate in two
2662 + bic r0, r0, #(0x1fc0)
2663 + bic r0, r0, #(0x3f)
2664 + ldr r1, [r0, #TI_CPU_DOMAIN]
2665 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2666 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2667 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2668 +#endif
2669 +#ifdef CONFIG_PAX_KERNEXEC
2670 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2671 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2672 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2673 +#endif
2674 + @ write r1 to current_thread_info()->cpu_domain
2675 + str r1, [r0, #TI_CPU_DOMAIN]
2676 + @ write r1 to DACR
2677 + mcr p15, 0, r1, c3, c0, 0
2678 + @ instruction sync
2679 + instr_sync
2680 + @ restore regs
2681 + ldmia sp!, {r0, r1}
2682 +#endif
2683 + .endm
2684 +
2685 + .macro pax_exit_kernel
2686 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2687 + @ save regs
2688 + stmdb sp!, {r0, r1}
2689 + @ read old DACR from stack into r1
2690 + ldr r1, [sp, #(8 + S_SP)]
2691 + sub r1, r1, #8
2692 + ldr r1, [r1]
2693 +
2694 + @ write r1 to current_thread_info()->cpu_domain
2695 + mov r0, sp
2696 + @ assume 8K pages, since we have to split the immediate in two
2697 + bic r0, r0, #(0x1fc0)
2698 + bic r0, r0, #(0x3f)
2699 + str r1, [r0, #TI_CPU_DOMAIN]
2700 + @ write r1 to DACR
2701 + mcr p15, 0, r1, c3, c0, 0
2702 + @ instruction sync
2703 + instr_sync
2704 + @ restore regs
2705 + ldmia sp!, {r0, r1}
2706 +#endif
2707 + .endm
2708 +
2709 #ifndef CONFIG_THUMB2_KERNEL
2710 .macro svc_exit, rpsr, irq = 0
2711 .if \irq != 0
2712 @@ -203,6 +257,9 @@
2713 blne trace_hardirqs_off
2714 #endif
2715 .endif
2716 +
2717 + pax_exit_kernel
2718 +
2719 msr spsr_cxsf, \rpsr
2720 #if defined(CONFIG_CPU_V6)
2721 ldr r0, [sp]
2722 @@ -266,6 +323,9 @@
2723 blne trace_hardirqs_off
2724 #endif
2725 .endif
2726 +
2727 + pax_exit_kernel
2728 +
2729 ldr lr, [sp, #S_SP] @ top of the stack
2730 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2731 clrex @ clear the exclusive monitor
2732 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2733 index 918875d..cd5fa27 100644
2734 --- a/arch/arm/kernel/fiq.c
2735 +++ b/arch/arm/kernel/fiq.c
2736 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2737 void *base = vectors_page;
2738 unsigned offset = FIQ_OFFSET;
2739
2740 + pax_open_kernel();
2741 memcpy(base + offset, start, length);
2742 + pax_close_kernel();
2743 +
2744 if (!cache_is_vipt_nonaliasing())
2745 flush_icache_range((unsigned long)base + offset, offset +
2746 length);
2747 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2748 index 2c7cc1e..ab2e911 100644
2749 --- a/arch/arm/kernel/head.S
2750 +++ b/arch/arm/kernel/head.S
2751 @@ -52,7 +52,9 @@
2752 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2753
2754 .macro pgtbl, rd, phys
2755 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2756 + mov \rd, #TEXT_OFFSET
2757 + sub \rd, #PG_DIR_SIZE
2758 + add \rd, \rd, \phys
2759 .endm
2760
2761 /*
2762 @@ -432,7 +434,7 @@ __enable_mmu:
2763 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2764 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2765 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2766 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2767 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2768 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2769 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2770 #endif
2771 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2772 index 85c3fb6..054c2dc 100644
2773 --- a/arch/arm/kernel/module.c
2774 +++ b/arch/arm/kernel/module.c
2775 @@ -37,12 +37,39 @@
2776 #endif
2777
2778 #ifdef CONFIG_MMU
2779 -void *module_alloc(unsigned long size)
2780 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2781 {
2782 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2783 + return NULL;
2784 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2785 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2786 + GFP_KERNEL, prot, -1,
2787 __builtin_return_address(0));
2788 }
2789 +
2790 +void *module_alloc(unsigned long size)
2791 +{
2792 +
2793 +#ifdef CONFIG_PAX_KERNEXEC
2794 + return __module_alloc(size, PAGE_KERNEL);
2795 +#else
2796 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2797 +#endif
2798 +
2799 +}
2800 +
2801 +#ifdef CONFIG_PAX_KERNEXEC
2802 +void module_free_exec(struct module *mod, void *module_region)
2803 +{
2804 + module_free(mod, module_region);
2805 +}
2806 +EXPORT_SYMBOL(module_free_exec);
2807 +
2808 +void *module_alloc_exec(unsigned long size)
2809 +{
2810 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2811 +}
2812 +EXPORT_SYMBOL(module_alloc_exec);
2813 +#endif
2814 #endif
2815
2816 int
2817 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2818 index 07314af..c46655c 100644
2819 --- a/arch/arm/kernel/patch.c
2820 +++ b/arch/arm/kernel/patch.c
2821 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2822 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2823 int size;
2824
2825 + pax_open_kernel();
2826 if (thumb2 && __opcode_is_thumb16(insn)) {
2827 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2828 size = sizeof(u16);
2829 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2830 *(u32 *)addr = insn;
2831 size = sizeof(u32);
2832 }
2833 + pax_close_kernel();
2834
2835 flush_icache_range((uintptr_t)(addr),
2836 (uintptr_t)(addr) + size);
2837 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2838 index 94f6b05..efd7312 100644
2839 --- a/arch/arm/kernel/process.c
2840 +++ b/arch/arm/kernel/process.c
2841 @@ -217,6 +217,7 @@ void machine_power_off(void)
2842
2843 if (pm_power_off)
2844 pm_power_off();
2845 + BUG();
2846 }
2847
2848 /*
2849 @@ -230,7 +231,7 @@ void machine_power_off(void)
2850 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2851 * to use. Implementing such co-ordination would be essentially impossible.
2852 */
2853 -void machine_restart(char *cmd)
2854 +__noreturn void machine_restart(char *cmd)
2855 {
2856 local_irq_disable();
2857 smp_send_stop();
2858 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2859
2860 show_regs_print_info(KERN_DEFAULT);
2861
2862 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2863 - print_symbol("LR is at %s\n", regs->ARM_lr);
2864 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2865 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2866 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2867 "sp : %08lx ip : %08lx fp : %08lx\n",
2868 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2869 @@ -422,12 +423,6 @@ unsigned long get_wchan(struct task_struct *p)
2870 return 0;
2871 }
2872
2873 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2874 -{
2875 - unsigned long range_end = mm->brk + 0x02000000;
2876 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2877 -}
2878 -
2879 #ifdef CONFIG_MMU
2880 #ifdef CONFIG_KUSER_HELPERS
2881 /*
2882 @@ -443,7 +438,7 @@ static struct vm_area_struct gate_vma = {
2883
2884 static int __init gate_vma_init(void)
2885 {
2886 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2887 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2888 return 0;
2889 }
2890 arch_initcall(gate_vma_init);
2891 @@ -469,41 +464,16 @@ int in_gate_area_no_mm(unsigned long addr)
2892
2893 const char *arch_vma_name(struct vm_area_struct *vma)
2894 {
2895 - return is_gate_vma(vma) ? "[vectors]" :
2896 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2897 - "[sigpage]" : NULL;
2898 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2899 }
2900
2901 -static struct page *signal_page;
2902 -extern struct page *get_signal_page(void);
2903 -
2904 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2905 {
2906 struct mm_struct *mm = current->mm;
2907 - unsigned long addr;
2908 - int ret;
2909 -
2910 - if (!signal_page)
2911 - signal_page = get_signal_page();
2912 - if (!signal_page)
2913 - return -ENOMEM;
2914
2915 down_write(&mm->mmap_sem);
2916 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2917 - if (IS_ERR_VALUE(addr)) {
2918 - ret = addr;
2919 - goto up_fail;
2920 - }
2921 -
2922 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2923 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2924 - &signal_page);
2925 -
2926 - if (ret == 0)
2927 - mm->context.sigpage = addr;
2928 -
2929 - up_fail:
2930 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2931 up_write(&mm->mmap_sem);
2932 - return ret;
2933 + return 0;
2934 }
2935 #endif
2936 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2937 index 4693188..4596c5e 100644
2938 --- a/arch/arm/kernel/psci.c
2939 +++ b/arch/arm/kernel/psci.c
2940 @@ -24,7 +24,7 @@
2941 #include <asm/opcodes-virt.h>
2942 #include <asm/psci.h>
2943
2944 -struct psci_operations psci_ops;
2945 +struct psci_operations psci_ops __read_only;
2946
2947 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2948
2949 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2950 index 0dd3b79..e018f64 100644
2951 --- a/arch/arm/kernel/ptrace.c
2952 +++ b/arch/arm/kernel/ptrace.c
2953 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2954 return current_thread_info()->syscall;
2955 }
2956
2957 +#ifdef CONFIG_GRKERNSEC_SETXID
2958 +extern void gr_delayed_cred_worker(void);
2959 +#endif
2960 +
2961 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2962 {
2963 current_thread_info()->syscall = scno;
2964
2965 +#ifdef CONFIG_GRKERNSEC_SETXID
2966 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2967 + gr_delayed_cred_worker();
2968 +#endif
2969 +
2970 /* Do the secure computing check first; failures should be fast. */
2971 if (secure_computing(scno) == -1)
2972 return -1;
2973 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2974 index afc2489..6372bc8 100644
2975 --- a/arch/arm/kernel/setup.c
2976 +++ b/arch/arm/kernel/setup.c
2977 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2978 unsigned int elf_hwcap __read_mostly;
2979 EXPORT_SYMBOL(elf_hwcap);
2980
2981 +pteval_t __supported_pte_mask __read_only;
2982 +pmdval_t __supported_pmd_mask __read_only;
2983
2984 #ifdef MULTI_CPU
2985 -struct processor processor __read_mostly;
2986 +struct processor processor;
2987 #endif
2988 #ifdef MULTI_TLB
2989 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2990 +struct cpu_tlb_fns cpu_tlb __read_only;
2991 #endif
2992 #ifdef MULTI_USER
2993 -struct cpu_user_fns cpu_user __read_mostly;
2994 +struct cpu_user_fns cpu_user __read_only;
2995 #endif
2996 #ifdef MULTI_CACHE
2997 -struct cpu_cache_fns cpu_cache __read_mostly;
2998 +struct cpu_cache_fns cpu_cache __read_only;
2999 #endif
3000 #ifdef CONFIG_OUTER_CACHE
3001 -struct outer_cache_fns outer_cache __read_mostly;
3002 +struct outer_cache_fns outer_cache __read_only;
3003 EXPORT_SYMBOL(outer_cache);
3004 #endif
3005
3006 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
3007 asm("mrc p15, 0, %0, c0, c1, 4"
3008 : "=r" (mmfr0));
3009 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3010 - (mmfr0 & 0x000000f0) >= 0x00000030)
3011 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3012 cpu_arch = CPU_ARCH_ARMv7;
3013 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3014 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3015 + __supported_pte_mask |= L_PTE_PXN;
3016 + __supported_pmd_mask |= PMD_PXNTABLE;
3017 + }
3018 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3019 (mmfr0 & 0x000000f0) == 0x00000020)
3020 cpu_arch = CPU_ARCH_ARMv6;
3021 else
3022 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
3023 __cpu_architecture = __get_cpu_architecture();
3024
3025 #ifdef MULTI_CPU
3026 - processor = *list->proc;
3027 + memcpy((void *)&processor, list->proc, sizeof processor);
3028 #endif
3029 #ifdef MULTI_TLB
3030 cpu_tlb = *list->tlb;
3031 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3032 index ab33042..11248a8 100644
3033 --- a/arch/arm/kernel/signal.c
3034 +++ b/arch/arm/kernel/signal.c
3035 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3036 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3037 };
3038
3039 -static unsigned long signal_return_offset;
3040 -
3041 #ifdef CONFIG_CRUNCH
3042 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3043 {
3044 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3045 * except when the MPU has protected the vectors
3046 * page from PL0
3047 */
3048 - retcode = mm->context.sigpage + signal_return_offset +
3049 - (idx << 2) + thumb;
3050 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3051 } else
3052 #endif
3053 {
3054 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3055 } while (thread_flags & _TIF_WORK_MASK);
3056 return 0;
3057 }
3058 -
3059 -struct page *get_signal_page(void)
3060 -{
3061 - unsigned long ptr;
3062 - unsigned offset;
3063 - struct page *page;
3064 - void *addr;
3065 -
3066 - page = alloc_pages(GFP_KERNEL, 0);
3067 -
3068 - if (!page)
3069 - return NULL;
3070 -
3071 - addr = page_address(page);
3072 -
3073 - /* Give the signal return code some randomness */
3074 - offset = 0x200 + (get_random_int() & 0x7fc);
3075 - signal_return_offset = offset;
3076 -
3077 - /*
3078 - * Copy signal return handlers into the vector page, and
3079 - * set sigreturn to be a pointer to these.
3080 - */
3081 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3082 -
3083 - ptr = (unsigned long)addr + offset;
3084 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3085 -
3086 - return page;
3087 -}
3088 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3089 index 2dc1934..ecf0e21 100644
3090 --- a/arch/arm/kernel/smp.c
3091 +++ b/arch/arm/kernel/smp.c
3092 @@ -71,7 +71,7 @@ enum ipi_msg_type {
3093
3094 static DECLARE_COMPLETION(cpu_running);
3095
3096 -static struct smp_operations smp_ops;
3097 +static struct smp_operations smp_ops __read_only;
3098
3099 void __init smp_set_ops(struct smp_operations *ops)
3100 {
3101 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3102 index ab517fc..9adf2fa 100644
3103 --- a/arch/arm/kernel/traps.c
3104 +++ b/arch/arm/kernel/traps.c
3105 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3106 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3107 {
3108 #ifdef CONFIG_KALLSYMS
3109 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3110 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3111 #else
3112 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3113 #endif
3114 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3115 static int die_owner = -1;
3116 static unsigned int die_nest_count;
3117
3118 +extern void gr_handle_kernel_exploit(void);
3119 +
3120 static unsigned long oops_begin(void)
3121 {
3122 int cpu;
3123 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3124 panic("Fatal exception in interrupt");
3125 if (panic_on_oops)
3126 panic("Fatal exception");
3127 +
3128 + gr_handle_kernel_exploit();
3129 +
3130 if (signr)
3131 do_exit(signr);
3132 }
3133 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3134 * The user helper at 0xffff0fe0 must be used instead.
3135 * (see entry-armv.S for details)
3136 */
3137 + pax_open_kernel();
3138 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3139 + pax_close_kernel();
3140 }
3141 return 0;
3142
3143 @@ -849,7 +856,11 @@ void __init early_trap_init(void *vectors_base)
3144 kuser_init(vectors_base);
3145
3146 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3147 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3148 +
3149 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3150 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3151 +#endif
3152 +
3153 #else /* ifndef CONFIG_CPU_V7M */
3154 /*
3155 * on V7-M there is no need to copy the vector table to a dedicated
3156 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3157 index 7bcee5c..e2f3249 100644
3158 --- a/arch/arm/kernel/vmlinux.lds.S
3159 +++ b/arch/arm/kernel/vmlinux.lds.S
3160 @@ -8,7 +8,11 @@
3161 #include <asm/thread_info.h>
3162 #include <asm/memory.h>
3163 #include <asm/page.h>
3164 -
3165 +
3166 +#ifdef CONFIG_PAX_KERNEXEC
3167 +#include <asm/pgtable.h>
3168 +#endif
3169 +
3170 #define PROC_INFO \
3171 . = ALIGN(4); \
3172 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3173 @@ -34,7 +38,7 @@
3174 #endif
3175
3176 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3177 - defined(CONFIG_GENERIC_BUG)
3178 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3179 #define ARM_EXIT_KEEP(x) x
3180 #define ARM_EXIT_DISCARD(x)
3181 #else
3182 @@ -90,6 +94,11 @@ SECTIONS
3183 _text = .;
3184 HEAD_TEXT
3185 }
3186 +
3187 +#ifdef CONFIG_PAX_KERNEXEC
3188 + . = ALIGN(1<<SECTION_SHIFT);
3189 +#endif
3190 +
3191 .text : { /* Real text segment */
3192 _stext = .; /* Text and read-only data */
3193 __exception_text_start = .;
3194 @@ -112,6 +121,8 @@ SECTIONS
3195 ARM_CPU_KEEP(PROC_INFO)
3196 }
3197
3198 + _etext = .; /* End of text section */
3199 +
3200 RO_DATA(PAGE_SIZE)
3201
3202 . = ALIGN(4);
3203 @@ -142,7 +153,9 @@ SECTIONS
3204
3205 NOTES
3206
3207 - _etext = .; /* End of text and rodata section */
3208 +#ifdef CONFIG_PAX_KERNEXEC
3209 + . = ALIGN(1<<SECTION_SHIFT);
3210 +#endif
3211
3212 #ifndef CONFIG_XIP_KERNEL
3213 . = ALIGN(PAGE_SIZE);
3214 @@ -220,6 +233,11 @@ SECTIONS
3215 . = PAGE_OFFSET + TEXT_OFFSET;
3216 #else
3217 __init_end = .;
3218 +
3219 +#ifdef CONFIG_PAX_KERNEXEC
3220 + . = ALIGN(1<<SECTION_SHIFT);
3221 +#endif
3222 +
3223 . = ALIGN(THREAD_SIZE);
3224 __data_loc = .;
3225 #endif
3226 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3227 index 741f66a..8a5615c 100644
3228 --- a/arch/arm/kvm/arm.c
3229 +++ b/arch/arm/kvm/arm.c
3230 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3231 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3232
3233 /* The VMID used in the VTTBR */
3234 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3235 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3236 static u8 kvm_next_vmid;
3237 static DEFINE_SPINLOCK(kvm_vmid_lock);
3238
3239 @@ -392,7 +392,7 @@ void force_vm_exit(const cpumask_t *mask)
3240 */
3241 static bool need_new_vmid_gen(struct kvm *kvm)
3242 {
3243 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3244 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3245 }
3246
3247 /**
3248 @@ -425,7 +425,7 @@ static void update_vttbr(struct kvm *kvm)
3249
3250 /* First user of a new VMID generation? */
3251 if (unlikely(kvm_next_vmid == 0)) {
3252 - atomic64_inc(&kvm_vmid_gen);
3253 + atomic64_inc_unchecked(&kvm_vmid_gen);
3254 kvm_next_vmid = 1;
3255
3256 /*
3257 @@ -442,7 +442,7 @@ static void update_vttbr(struct kvm *kvm)
3258 kvm_call_hyp(__kvm_flush_vm_context);
3259 }
3260
3261 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3262 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3263 kvm->arch.vmid = kvm_next_vmid;
3264 kvm_next_vmid++;
3265
3266 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3267 index 14a0d98..7771a7d 100644
3268 --- a/arch/arm/lib/clear_user.S
3269 +++ b/arch/arm/lib/clear_user.S
3270 @@ -12,14 +12,14 @@
3271
3272 .text
3273
3274 -/* Prototype: int __clear_user(void *addr, size_t sz)
3275 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3276 * Purpose : clear some user memory
3277 * Params : addr - user memory address to clear
3278 * : sz - number of bytes to clear
3279 * Returns : number of bytes NOT cleared
3280 */
3281 ENTRY(__clear_user_std)
3282 -WEAK(__clear_user)
3283 +WEAK(___clear_user)
3284 stmfd sp!, {r1, lr}
3285 mov r2, #0
3286 cmp r1, #4
3287 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3288 USER( strnebt r2, [r0])
3289 mov r0, #0
3290 ldmfd sp!, {r1, pc}
3291 -ENDPROC(__clear_user)
3292 +ENDPROC(___clear_user)
3293 ENDPROC(__clear_user_std)
3294
3295 .pushsection .fixup,"ax"
3296 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3297 index 66a477a..bee61d3 100644
3298 --- a/arch/arm/lib/copy_from_user.S
3299 +++ b/arch/arm/lib/copy_from_user.S
3300 @@ -16,7 +16,7 @@
3301 /*
3302 * Prototype:
3303 *
3304 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3305 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3306 *
3307 * Purpose:
3308 *
3309 @@ -84,11 +84,11 @@
3310
3311 .text
3312
3313 -ENTRY(__copy_from_user)
3314 +ENTRY(___copy_from_user)
3315
3316 #include "copy_template.S"
3317
3318 -ENDPROC(__copy_from_user)
3319 +ENDPROC(___copy_from_user)
3320
3321 .pushsection .fixup,"ax"
3322 .align 0
3323 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3324 index 6ee2f67..d1cce76 100644
3325 --- a/arch/arm/lib/copy_page.S
3326 +++ b/arch/arm/lib/copy_page.S
3327 @@ -10,6 +10,7 @@
3328 * ASM optimised string functions
3329 */
3330 #include <linux/linkage.h>
3331 +#include <linux/const.h>
3332 #include <asm/assembler.h>
3333 #include <asm/asm-offsets.h>
3334 #include <asm/cache.h>
3335 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3336 index d066df6..df28194 100644
3337 --- a/arch/arm/lib/copy_to_user.S
3338 +++ b/arch/arm/lib/copy_to_user.S
3339 @@ -16,7 +16,7 @@
3340 /*
3341 * Prototype:
3342 *
3343 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3344 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3345 *
3346 * Purpose:
3347 *
3348 @@ -88,11 +88,11 @@
3349 .text
3350
3351 ENTRY(__copy_to_user_std)
3352 -WEAK(__copy_to_user)
3353 +WEAK(___copy_to_user)
3354
3355 #include "copy_template.S"
3356
3357 -ENDPROC(__copy_to_user)
3358 +ENDPROC(___copy_to_user)
3359 ENDPROC(__copy_to_user_std)
3360
3361 .pushsection .fixup,"ax"
3362 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3363 index 7d08b43..f7ca7ea 100644
3364 --- a/arch/arm/lib/csumpartialcopyuser.S
3365 +++ b/arch/arm/lib/csumpartialcopyuser.S
3366 @@ -57,8 +57,8 @@
3367 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3368 */
3369
3370 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3371 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3372 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3373 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3374
3375 #include "csumpartialcopygeneric.S"
3376
3377 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3378 index 5306de3..aed6d03 100644
3379 --- a/arch/arm/lib/delay.c
3380 +++ b/arch/arm/lib/delay.c
3381 @@ -28,7 +28,7 @@
3382 /*
3383 * Default to the loop-based delay implementation.
3384 */
3385 -struct arm_delay_ops arm_delay_ops = {
3386 +struct arm_delay_ops arm_delay_ops __read_only = {
3387 .delay = __loop_delay,
3388 .const_udelay = __loop_const_udelay,
3389 .udelay = __loop_udelay,
3390 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3391 index 025f742..a9e5b3b 100644
3392 --- a/arch/arm/lib/uaccess_with_memcpy.c
3393 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3394 @@ -104,7 +104,7 @@ out:
3395 }
3396
3397 unsigned long
3398 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3399 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3400 {
3401 /*
3402 * This test is stubbed out of the main function above to keep
3403 @@ -155,7 +155,7 @@ out:
3404 return n;
3405 }
3406
3407 -unsigned long __clear_user(void __user *addr, unsigned long n)
3408 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3409 {
3410 /* See rational for this in __copy_to_user() above. */
3411 if (n < 64)
3412 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3413 index e9238b5..6ed904a 100644
3414 --- a/arch/arm/mach-kirkwood/common.c
3415 +++ b/arch/arm/mach-kirkwood/common.c
3416 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3417 clk_gate_ops.disable(hw);
3418 }
3419
3420 -static struct clk_ops clk_gate_fn_ops;
3421 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3422 +{
3423 + return clk_gate_ops.is_enabled(hw);
3424 +}
3425 +
3426 +static struct clk_ops clk_gate_fn_ops = {
3427 + .enable = clk_gate_fn_enable,
3428 + .disable = clk_gate_fn_disable,
3429 + .is_enabled = clk_gate_fn_is_enabled,
3430 +};
3431
3432 static struct clk __init *clk_register_gate_fn(struct device *dev,
3433 const char *name,
3434 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3435 gate_fn->fn_en = fn_en;
3436 gate_fn->fn_dis = fn_dis;
3437
3438 - /* ops is the gate ops, but with our enable/disable functions */
3439 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3440 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3441 - clk_gate_fn_ops = clk_gate_ops;
3442 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3443 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3444 - }
3445 -
3446 clk = clk_register(dev, &gate_fn->gate.hw);
3447
3448 if (IS_ERR(clk))
3449 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3450 index 827d1500..2885dc6 100644
3451 --- a/arch/arm/mach-omap2/board-n8x0.c
3452 +++ b/arch/arm/mach-omap2/board-n8x0.c
3453 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3454 }
3455 #endif
3456
3457 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3458 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3459 .late_init = n8x0_menelaus_late_init,
3460 };
3461
3462 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3463 index f3fdd6a..3564800 100644
3464 --- a/arch/arm/mach-omap2/gpmc.c
3465 +++ b/arch/arm/mach-omap2/gpmc.c
3466 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3467 };
3468
3469 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3470 -static struct irq_chip gpmc_irq_chip;
3471 static unsigned gpmc_irq_start;
3472
3473 static struct resource gpmc_mem_root;
3474 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3475
3476 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3477
3478 +static struct irq_chip gpmc_irq_chip = {
3479 + .name = "gpmc",
3480 + .irq_startup = gpmc_irq_noop_ret,
3481 + .irq_enable = gpmc_irq_enable,
3482 + .irq_disable = gpmc_irq_disable,
3483 + .irq_shutdown = gpmc_irq_noop,
3484 + .irq_ack = gpmc_irq_noop,
3485 + .irq_mask = gpmc_irq_noop,
3486 + .irq_unmask = gpmc_irq_noop,
3487 +
3488 +};
3489 +
3490 static int gpmc_setup_irq(void)
3491 {
3492 int i;
3493 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3494 return gpmc_irq_start;
3495 }
3496
3497 - gpmc_irq_chip.name = "gpmc";
3498 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3499 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3500 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3501 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3502 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3503 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3504 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3505 -
3506 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3507 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3508
3509 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3510 index f991016..145ebeb 100644
3511 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3512 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3513 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3514 int (*finish_suspend)(unsigned long cpu_state);
3515 void (*resume)(void);
3516 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3517 -};
3518 +} __no_const;
3519
3520 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3521 static struct powerdomain *mpuss_pd;
3522 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3523 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3524 {}
3525
3526 -struct cpu_pm_ops omap_pm_ops = {
3527 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3528 .finish_suspend = default_finish_suspend,
3529 .resume = dummy_cpu_resume,
3530 .scu_prepare = dummy_scu_prepare,
3531 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3532 index 813c615..ce467c6 100644
3533 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3534 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3535 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3536 return NOTIFY_OK;
3537 }
3538
3539 -static struct notifier_block __refdata irq_hotplug_notifier = {
3540 +static struct notifier_block irq_hotplug_notifier = {
3541 .notifier_call = irq_cpu_hotplug_notify,
3542 };
3543
3544 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3545 index f99f68e..e573e20 100644
3546 --- a/arch/arm/mach-omap2/omap_device.c
3547 +++ b/arch/arm/mach-omap2/omap_device.c
3548 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3549 struct platform_device __init *omap_device_build(const char *pdev_name,
3550 int pdev_id,
3551 struct omap_hwmod *oh,
3552 - void *pdata, int pdata_len)
3553 + const void *pdata, int pdata_len)
3554 {
3555 struct omap_hwmod *ohs[] = { oh };
3556
3557 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3558 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3559 int pdev_id,
3560 struct omap_hwmod **ohs,
3561 - int oh_cnt, void *pdata,
3562 + int oh_cnt, const void *pdata,
3563 int pdata_len)
3564 {
3565 int ret = -ENOMEM;
3566 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3567 index 17ca1ae..beba869 100644
3568 --- a/arch/arm/mach-omap2/omap_device.h
3569 +++ b/arch/arm/mach-omap2/omap_device.h
3570 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3571 /* Core code interface */
3572
3573 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3574 - struct omap_hwmod *oh, void *pdata,
3575 + struct omap_hwmod *oh, const void *pdata,
3576 int pdata_len);
3577
3578 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3579 struct omap_hwmod **oh, int oh_cnt,
3580 - void *pdata, int pdata_len);
3581 + const void *pdata, int pdata_len);
3582
3583 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3584 struct omap_hwmod **ohs, int oh_cnt);
3585 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3586 index 7f4db12..0243012 100644
3587 --- a/arch/arm/mach-omap2/omap_hwmod.c
3588 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3589 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3590 int (*init_clkdm)(struct omap_hwmod *oh);
3591 void (*update_context_lost)(struct omap_hwmod *oh);
3592 int (*get_context_lost)(struct omap_hwmod *oh);
3593 -};
3594 +} __no_const;
3595
3596 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3597 -static struct omap_hwmod_soc_ops soc_ops;
3598 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3599
3600 /* omap_hwmod_list contains all registered struct omap_hwmods */
3601 static LIST_HEAD(omap_hwmod_list);
3602 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3603 index d15c7bb..b2d1f0c 100644
3604 --- a/arch/arm/mach-omap2/wd_timer.c
3605 +++ b/arch/arm/mach-omap2/wd_timer.c
3606 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3607 struct omap_hwmod *oh;
3608 char *oh_name = "wd_timer2";
3609 char *dev_name = "omap_wdt";
3610 - struct omap_wd_timer_platform_data pdata;
3611 + static struct omap_wd_timer_platform_data pdata = {
3612 + .read_reset_sources = prm_read_reset_sources
3613 + };
3614
3615 if (!cpu_class_is_omap2() || of_have_populated_dt())
3616 return 0;
3617 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3618 return -EINVAL;
3619 }
3620
3621 - pdata.read_reset_sources = prm_read_reset_sources;
3622 -
3623 pdev = omap_device_build(dev_name, id, oh, &pdata,
3624 sizeof(struct omap_wd_timer_platform_data));
3625 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3626 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3627 index 706aa42..f85e9131 100644
3628 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3629 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3630 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3631 bool entered_lp2 = false;
3632
3633 if (tegra_pending_sgi())
3634 - ACCESS_ONCE(abort_flag) = true;
3635 + ACCESS_ONCE_RW(abort_flag) = true;
3636
3637 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3638
3639 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3640 index cad3ca86..1d79e0f 100644
3641 --- a/arch/arm/mach-ux500/setup.h
3642 +++ b/arch/arm/mach-ux500/setup.h
3643 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3644 .type = MT_DEVICE, \
3645 }
3646
3647 -#define __MEM_DEV_DESC(x, sz) { \
3648 - .virtual = IO_ADDRESS(x), \
3649 - .pfn = __phys_to_pfn(x), \
3650 - .length = sz, \
3651 - .type = MT_MEMORY, \
3652 -}
3653 -
3654 extern struct smp_operations ux500_smp_ops;
3655 extern void ux500_cpu_die(unsigned int cpu);
3656
3657 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3658 index cd2c88e..7430282 100644
3659 --- a/arch/arm/mm/Kconfig
3660 +++ b/arch/arm/mm/Kconfig
3661 @@ -446,7 +446,7 @@ config CPU_32v5
3662
3663 config CPU_32v6
3664 bool
3665 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3666 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3667 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3668
3669 config CPU_32v6K
3670 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3671
3672 config CPU_USE_DOMAINS
3673 bool
3674 + depends on !ARM_LPAE && !PAX_KERNEXEC
3675 help
3676 This option enables or disables the use of domain switching
3677 via the set_fs() function.
3678 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3679 config KUSER_HELPERS
3680 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3681 default y
3682 + depends on !(CPU_V6 || CPU_V6K || CPU_V7)
3683 help
3684 Warning: disabling this option may break user programs.
3685
3686 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3687 See Documentation/arm/kernel_user_helpers.txt for details.
3688
3689 However, the fixed address nature of these helpers can be used
3690 - by ROP (return orientated programming) authors when creating
3691 + by ROP (Return Oriented Programming) authors when creating
3692 exploits.
3693
3694 If all of the binaries and libraries which run on your platform
3695 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3696 index 6f4585b..7b6f52b 100644
3697 --- a/arch/arm/mm/alignment.c
3698 +++ b/arch/arm/mm/alignment.c
3699 @@ -211,10 +211,12 @@ union offset_union {
3700 #define __get16_unaligned_check(ins,val,addr) \
3701 do { \
3702 unsigned int err = 0, v, a = addr; \
3703 + pax_open_userland(); \
3704 __get8_unaligned_check(ins,v,a,err); \
3705 val = v << ((BE) ? 8 : 0); \
3706 __get8_unaligned_check(ins,v,a,err); \
3707 val |= v << ((BE) ? 0 : 8); \
3708 + pax_close_userland(); \
3709 if (err) \
3710 goto fault; \
3711 } while (0)
3712 @@ -228,6 +230,7 @@ union offset_union {
3713 #define __get32_unaligned_check(ins,val,addr) \
3714 do { \
3715 unsigned int err = 0, v, a = addr; \
3716 + pax_open_userland(); \
3717 __get8_unaligned_check(ins,v,a,err); \
3718 val = v << ((BE) ? 24 : 0); \
3719 __get8_unaligned_check(ins,v,a,err); \
3720 @@ -236,6 +239,7 @@ union offset_union {
3721 val |= v << ((BE) ? 8 : 16); \
3722 __get8_unaligned_check(ins,v,a,err); \
3723 val |= v << ((BE) ? 0 : 24); \
3724 + pax_close_userland(); \
3725 if (err) \
3726 goto fault; \
3727 } while (0)
3728 @@ -249,6 +253,7 @@ union offset_union {
3729 #define __put16_unaligned_check(ins,val,addr) \
3730 do { \
3731 unsigned int err = 0, v = val, a = addr; \
3732 + pax_open_userland(); \
3733 __asm__( FIRST_BYTE_16 \
3734 ARM( "1: "ins" %1, [%2], #1\n" ) \
3735 THUMB( "1: "ins" %1, [%2]\n" ) \
3736 @@ -268,6 +273,7 @@ union offset_union {
3737 " .popsection\n" \
3738 : "=r" (err), "=&r" (v), "=&r" (a) \
3739 : "0" (err), "1" (v), "2" (a)); \
3740 + pax_close_userland(); \
3741 if (err) \
3742 goto fault; \
3743 } while (0)
3744 @@ -281,6 +287,7 @@ union offset_union {
3745 #define __put32_unaligned_check(ins,val,addr) \
3746 do { \
3747 unsigned int err = 0, v = val, a = addr; \
3748 + pax_open_userland(); \
3749 __asm__( FIRST_BYTE_32 \
3750 ARM( "1: "ins" %1, [%2], #1\n" ) \
3751 THUMB( "1: "ins" %1, [%2]\n" ) \
3752 @@ -310,6 +317,7 @@ union offset_union {
3753 " .popsection\n" \
3754 : "=r" (err), "=&r" (v), "=&r" (a) \
3755 : "0" (err), "1" (v), "2" (a)); \
3756 + pax_close_userland(); \
3757 if (err) \
3758 goto fault; \
3759 } while (0)
3760 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3761 index 4a05444..d21968c 100644
3762 --- a/arch/arm/mm/context.c
3763 +++ b/arch/arm/mm/context.c
3764 @@ -43,7 +43,7 @@
3765 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3766
3767 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3768 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3769 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3770 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3771
3772 static DEFINE_PER_CPU(atomic64_t, active_asids);
3773 @@ -183,7 +183,7 @@ static int is_reserved_asid(u64 asid)
3774 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3775 {
3776 u64 asid = atomic64_read(&mm->context.id);
3777 - u64 generation = atomic64_read(&asid_generation);
3778 + u64 generation = atomic64_read_unchecked(&asid_generation);
3779
3780 if (asid != 0 && is_reserved_asid(asid)) {
3781 /*
3782 @@ -201,7 +201,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3783 */
3784 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3785 if (asid == NUM_USER_ASIDS) {
3786 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3787 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3788 &asid_generation);
3789 flush_context(cpu);
3790 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3791 @@ -230,14 +230,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3792 cpu_set_reserved_ttbr0();
3793
3794 asid = atomic64_read(&mm->context.id);
3795 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3796 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3797 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3798 goto switch_mm_fastpath;
3799
3800 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3801 /* Check that our ASID belongs to the current generation. */
3802 asid = atomic64_read(&mm->context.id);
3803 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3804 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3805 asid = new_context(mm, cpu);
3806 atomic64_set(&mm->context.id, asid);
3807 }
3808 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3809 index c97f794..6461880 100644
3810 --- a/arch/arm/mm/fault.c
3811 +++ b/arch/arm/mm/fault.c
3812 @@ -25,6 +25,7 @@
3813 #include <asm/system_misc.h>
3814 #include <asm/system_info.h>
3815 #include <asm/tlbflush.h>
3816 +#include <asm/sections.h>
3817
3818 #include "fault.h"
3819
3820 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3821 if (fixup_exception(regs))
3822 return;
3823
3824 +#ifdef CONFIG_PAX_KERNEXEC
3825 + if ((fsr & FSR_WRITE) &&
3826 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3827 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3828 + {
3829 + if (current->signal->curr_ip)
3830 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3831 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3832 + else
3833 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3834 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3835 + }
3836 +#endif
3837 +
3838 /*
3839 * No handler, we'll have to terminate things with extreme prejudice.
3840 */
3841 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3842 }
3843 #endif
3844
3845 +#ifdef CONFIG_PAX_PAGEEXEC
3846 + if (fsr & FSR_LNX_PF) {
3847 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3848 + do_group_exit(SIGKILL);
3849 + }
3850 +#endif
3851 +
3852 tsk->thread.address = addr;
3853 tsk->thread.error_code = fsr;
3854 tsk->thread.trap_no = 14;
3855 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3856 }
3857 #endif /* CONFIG_MMU */
3858
3859 +#ifdef CONFIG_PAX_PAGEEXEC
3860 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3861 +{
3862 + long i;
3863 +
3864 + printk(KERN_ERR "PAX: bytes at PC: ");
3865 + for (i = 0; i < 20; i++) {
3866 + unsigned char c;
3867 + if (get_user(c, (__force unsigned char __user *)pc+i))
3868 + printk(KERN_CONT "?? ");
3869 + else
3870 + printk(KERN_CONT "%02x ", c);
3871 + }
3872 + printk("\n");
3873 +
3874 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3875 + for (i = -1; i < 20; i++) {
3876 + unsigned long c;
3877 + if (get_user(c, (__force unsigned long __user *)sp+i))
3878 + printk(KERN_CONT "???????? ");
3879 + else
3880 + printk(KERN_CONT "%08lx ", c);
3881 + }
3882 + printk("\n");
3883 +}
3884 +#endif
3885 +
3886 /*
3887 * First Level Translation Fault Handler
3888 *
3889 @@ -545,9 +594,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3890 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3891 struct siginfo info;
3892
3893 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3894 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3895 + if (current->signal->curr_ip)
3896 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3897 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3898 + else
3899 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3900 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3901 + goto die;
3902 + }
3903 +#endif
3904 +
3905 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3906 return;
3907
3908 +die:
3909 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3910 inf->name, fsr, addr);
3911
3912 @@ -571,15 +633,92 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3913 ifsr_info[nr].name = name;
3914 }
3915
3916 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3917 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3918 +
3919 asmlinkage void __exception
3920 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3921 {
3922 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3923 struct siginfo info;
3924 + unsigned long pc = instruction_pointer(regs);
3925 +
3926 + if (user_mode(regs)) {
3927 + unsigned long sigpage = current->mm->context.sigpage;
3928 +
3929 + if (sigpage <= pc && pc < sigpage + 7*4) {
3930 + if (pc < sigpage + 3*4)
3931 + sys_sigreturn(regs);
3932 + else
3933 + sys_rt_sigreturn(regs);
3934 + return;
3935 + }
3936 + if (pc == 0xffff0f60UL) {
3937 + /*
3938 + * PaX: __kuser_cmpxchg64 emulation
3939 + */
3940 + // TODO
3941 + //regs->ARM_pc = regs->ARM_lr;
3942 + //return;
3943 + }
3944 + if (pc == 0xffff0fa0UL) {
3945 + /*
3946 + * PaX: __kuser_memory_barrier emulation
3947 + */
3948 + // dmb(); implied by the exception
3949 + regs->ARM_pc = regs->ARM_lr;
3950 + return;
3951 + }
3952 + if (pc == 0xffff0fc0UL) {
3953 + /*
3954 + * PaX: __kuser_cmpxchg emulation
3955 + */
3956 + // TODO
3957 + //regs->ARM_pc = regs->ARM_lr;
3958 + //return;
3959 + }
3960 + if (pc == 0xffff0fe0UL) {
3961 + /*
3962 + * PaX: __kuser_get_tls emulation
3963 + */
3964 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3965 + regs->ARM_pc = regs->ARM_lr;
3966 + return;
3967 + }
3968 + }
3969 +
3970 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3971 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3972 + if (current->signal->curr_ip)
3973 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3974 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3975 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3976 + else
3977 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3978 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3979 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3980 + goto die;
3981 + }
3982 +#endif
3983 +
3984 +#ifdef CONFIG_PAX_REFCOUNT
3985 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3986 + unsigned int bkpt;
3987 +
3988 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
3989 + current->thread.error_code = ifsr;
3990 + current->thread.trap_no = 0;
3991 + pax_report_refcount_overflow(regs);
3992 + fixup_exception(regs);
3993 + return;
3994 + }
3995 + }
3996 +#endif
3997
3998 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3999 return;
4000
4001 +die:
4002 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4003 inf->name, ifsr, addr);
4004
4005 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4006 index cf08bdf..772656c 100644
4007 --- a/arch/arm/mm/fault.h
4008 +++ b/arch/arm/mm/fault.h
4009 @@ -3,6 +3,7 @@
4010
4011 /*
4012 * Fault status register encodings. We steal bit 31 for our own purposes.
4013 + * Set when the FSR value is from an instruction fault.
4014 */
4015 #define FSR_LNX_PF (1 << 31)
4016 #define FSR_WRITE (1 << 11)
4017 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4018 }
4019 #endif
4020
4021 +/* valid for LPAE and !LPAE */
4022 +static inline int is_xn_fault(unsigned int fsr)
4023 +{
4024 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4025 +}
4026 +
4027 +static inline int is_domain_fault(unsigned int fsr)
4028 +{
4029 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4030 +}
4031 +
4032 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4033 unsigned long search_exception_table(unsigned long addr);
4034
4035 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4036 index 15225d8..25e2e3c 100644
4037 --- a/arch/arm/mm/init.c
4038 +++ b/arch/arm/mm/init.c
4039 @@ -30,6 +30,8 @@
4040 #include <asm/setup.h>
4041 #include <asm/tlb.h>
4042 #include <asm/fixmap.h>
4043 +#include <asm/system_info.h>
4044 +#include <asm/cp15.h>
4045
4046 #include <asm/mach/arch.h>
4047 #include <asm/mach/map.h>
4048 @@ -683,7 +685,46 @@ void free_initmem(void)
4049 {
4050 #ifdef CONFIG_HAVE_TCM
4051 extern char __tcm_start, __tcm_end;
4052 +#endif
4053
4054 +#ifdef CONFIG_PAX_KERNEXEC
4055 + unsigned long addr;
4056 + pgd_t *pgd;
4057 + pud_t *pud;
4058 + pmd_t *pmd;
4059 + int cpu_arch = cpu_architecture();
4060 + unsigned int cr = get_cr();
4061 +
4062 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4063 + /* make pages tables, etc before .text NX */
4064 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4065 + pgd = pgd_offset_k(addr);
4066 + pud = pud_offset(pgd, addr);
4067 + pmd = pmd_offset(pud, addr);
4068 + __section_update(pmd, addr, PMD_SECT_XN);
4069 + }
4070 + /* make init NX */
4071 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4072 + pgd = pgd_offset_k(addr);
4073 + pud = pud_offset(pgd, addr);
4074 + pmd = pmd_offset(pud, addr);
4075 + __section_update(pmd, addr, PMD_SECT_XN);
4076 + }
4077 + /* make kernel code/rodata RX */
4078 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4079 + pgd = pgd_offset_k(addr);
4080 + pud = pud_offset(pgd, addr);
4081 + pmd = pmd_offset(pud, addr);
4082 +#ifdef CONFIG_ARM_LPAE
4083 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4084 +#else
4085 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4086 +#endif
4087 + }
4088 + }
4089 +#endif
4090 +
4091 +#ifdef CONFIG_HAVE_TCM
4092 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4093 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4094 #endif
4095 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4096 index f123d6e..04bf569 100644
4097 --- a/arch/arm/mm/ioremap.c
4098 +++ b/arch/arm/mm/ioremap.c
4099 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4100 unsigned int mtype;
4101
4102 if (cached)
4103 - mtype = MT_MEMORY;
4104 + mtype = MT_MEMORY_RX;
4105 else
4106 - mtype = MT_MEMORY_NONCACHED;
4107 + mtype = MT_MEMORY_NONCACHED_RX;
4108
4109 return __arm_ioremap_caller(phys_addr, size, mtype,
4110 __builtin_return_address(0));
4111 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4112 index 0c63562..7128a90 100644
4113 --- a/arch/arm/mm/mmap.c
4114 +++ b/arch/arm/mm/mmap.c
4115 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4116 struct vm_area_struct *vma;
4117 int do_align = 0;
4118 int aliasing = cache_is_vipt_aliasing();
4119 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4120 struct vm_unmapped_area_info info;
4121
4122 /*
4123 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4124 if (len > TASK_SIZE)
4125 return -ENOMEM;
4126
4127 +#ifdef CONFIG_PAX_RANDMMAP
4128 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4129 +#endif
4130 +
4131 if (addr) {
4132 if (do_align)
4133 addr = COLOUR_ALIGN(addr, pgoff);
4134 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4135 addr = PAGE_ALIGN(addr);
4136
4137 vma = find_vma(mm, addr);
4138 - if (TASK_SIZE - len >= addr &&
4139 - (!vma || addr + len <= vma->vm_start))
4140 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4141 return addr;
4142 }
4143
4144 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4145 info.high_limit = TASK_SIZE;
4146 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4147 info.align_offset = pgoff << PAGE_SHIFT;
4148 + info.threadstack_offset = offset;
4149 return vm_unmapped_area(&info);
4150 }
4151
4152 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4153 unsigned long addr = addr0;
4154 int do_align = 0;
4155 int aliasing = cache_is_vipt_aliasing();
4156 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4157 struct vm_unmapped_area_info info;
4158
4159 /*
4160 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4161 return addr;
4162 }
4163
4164 +#ifdef CONFIG_PAX_RANDMMAP
4165 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4166 +#endif
4167 +
4168 /* requesting a specific address */
4169 if (addr) {
4170 if (do_align)
4171 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4172 else
4173 addr = PAGE_ALIGN(addr);
4174 vma = find_vma(mm, addr);
4175 - if (TASK_SIZE - len >= addr &&
4176 - (!vma || addr + len <= vma->vm_start))
4177 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4178 return addr;
4179 }
4180
4181 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4182 info.high_limit = mm->mmap_base;
4183 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4184 info.align_offset = pgoff << PAGE_SHIFT;
4185 + info.threadstack_offset = offset;
4186 addr = vm_unmapped_area(&info);
4187
4188 /*
4189 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4190 {
4191 unsigned long random_factor = 0UL;
4192
4193 +#ifdef CONFIG_PAX_RANDMMAP
4194 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4195 +#endif
4196 +
4197 /* 8 bits of randomness in 20 address space bits */
4198 if ((current->flags & PF_RANDOMIZE) &&
4199 !(current->personality & ADDR_NO_RANDOMIZE))
4200 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4201
4202 if (mmap_is_legacy()) {
4203 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4204 +
4205 +#ifdef CONFIG_PAX_RANDMMAP
4206 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4207 + mm->mmap_base += mm->delta_mmap;
4208 +#endif
4209 +
4210 mm->get_unmapped_area = arch_get_unmapped_area;
4211 } else {
4212 mm->mmap_base = mmap_base(random_factor);
4213 +
4214 +#ifdef CONFIG_PAX_RANDMMAP
4215 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4216 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4217 +#endif
4218 +
4219 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4220 }
4221 }
4222 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4223 index 53cdbd3..670f177 100644
4224 --- a/arch/arm/mm/mmu.c
4225 +++ b/arch/arm/mm/mmu.c
4226 @@ -36,6 +36,22 @@
4227 #include "mm.h"
4228 #include "tcm.h"
4229
4230 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4231 +void modify_domain(unsigned int dom, unsigned int type)
4232 +{
4233 + struct thread_info *thread = current_thread_info();
4234 + unsigned int domain = thread->cpu_domain;
4235 + /*
4236 + * DOMAIN_MANAGER might be defined to some other value,
4237 + * use the arch-defined constant
4238 + */
4239 + domain &= ~domain_val(dom, 3);
4240 + thread->cpu_domain = domain | domain_val(dom, type);
4241 + set_domain(thread->cpu_domain);
4242 +}
4243 +EXPORT_SYMBOL(modify_domain);
4244 +#endif
4245 +
4246 /*
4247 * empty_zero_page is a special page that is used for
4248 * zero-initialized data and COW.
4249 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4250
4251 #endif /* ifdef CONFIG_CPU_CP15 / else */
4252
4253 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4254 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4255 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4256
4257 -static struct mem_type mem_types[] = {
4258 +#ifdef CONFIG_PAX_KERNEXEC
4259 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4260 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4261 +#else
4262 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4263 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4264 +#endif
4265 +
4266 +static struct mem_type mem_types[] __read_only = {
4267 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4268 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4269 L_PTE_SHARED,
4270 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4271 [MT_UNCACHED] = {
4272 .prot_pte = PROT_PTE_DEVICE,
4273 .prot_l1 = PMD_TYPE_TABLE,
4274 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4275 + .prot_sect = PROT_SECT_DEVICE,
4276 .domain = DOMAIN_IO,
4277 },
4278 [MT_CACHECLEAN] = {
4279 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4280 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4281 .domain = DOMAIN_KERNEL,
4282 },
4283 #ifndef CONFIG_ARM_LPAE
4284 [MT_MINICLEAN] = {
4285 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4286 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4287 .domain = DOMAIN_KERNEL,
4288 },
4289 #endif
4290 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4291 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4292 L_PTE_RDONLY,
4293 .prot_l1 = PMD_TYPE_TABLE,
4294 - .domain = DOMAIN_USER,
4295 + .domain = DOMAIN_VECTORS,
4296 },
4297 [MT_HIGH_VECTORS] = {
4298 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4299 L_PTE_USER | L_PTE_RDONLY,
4300 .prot_l1 = PMD_TYPE_TABLE,
4301 - .domain = DOMAIN_USER,
4302 + .domain = DOMAIN_VECTORS,
4303 },
4304 - [MT_MEMORY] = {
4305 + [MT_MEMORY_RWX] = {
4306 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4307 .prot_l1 = PMD_TYPE_TABLE,
4308 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4309 .domain = DOMAIN_KERNEL,
4310 },
4311 + [MT_MEMORY_RW] = {
4312 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4313 + .prot_l1 = PMD_TYPE_TABLE,
4314 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4315 + .domain = DOMAIN_KERNEL,
4316 + },
4317 + [MT_MEMORY_RX] = {
4318 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4319 + .prot_l1 = PMD_TYPE_TABLE,
4320 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4321 + .domain = DOMAIN_KERNEL,
4322 + },
4323 [MT_ROM] = {
4324 - .prot_sect = PMD_TYPE_SECT,
4325 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4326 .domain = DOMAIN_KERNEL,
4327 },
4328 - [MT_MEMORY_NONCACHED] = {
4329 + [MT_MEMORY_NONCACHED_RW] = {
4330 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4331 L_PTE_MT_BUFFERABLE,
4332 .prot_l1 = PMD_TYPE_TABLE,
4333 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4334 .domain = DOMAIN_KERNEL,
4335 },
4336 + [MT_MEMORY_NONCACHED_RX] = {
4337 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4338 + L_PTE_MT_BUFFERABLE,
4339 + .prot_l1 = PMD_TYPE_TABLE,
4340 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4341 + .domain = DOMAIN_KERNEL,
4342 + },
4343 [MT_MEMORY_DTCM] = {
4344 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4345 - L_PTE_XN,
4346 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4347 .prot_l1 = PMD_TYPE_TABLE,
4348 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4349 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4350 .domain = DOMAIN_KERNEL,
4351 },
4352 [MT_MEMORY_ITCM] = {
4353 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4354 },
4355 [MT_MEMORY_SO] = {
4356 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4357 - L_PTE_MT_UNCACHED | L_PTE_XN,
4358 + L_PTE_MT_UNCACHED,
4359 .prot_l1 = PMD_TYPE_TABLE,
4360 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4361 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4362 + PMD_SECT_UNCACHED,
4363 .domain = DOMAIN_KERNEL,
4364 },
4365 [MT_MEMORY_DMA_READY] = {
4366 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4367 * to prevent speculative instruction fetches.
4368 */
4369 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4370 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4371 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4372 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4373 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4374 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4375 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4376 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4377 +
4378 + /* Mark other regions on ARMv6+ as execute-never */
4379 +
4380 +#ifdef CONFIG_PAX_KERNEXEC
4381 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4382 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4383 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4384 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4385 +#ifndef CONFIG_ARM_LPAE
4386 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4388 +#endif
4389 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4390 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4391 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4392 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4393 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4394 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4395 +#endif
4396 +
4397 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4398 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4399 }
4400 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4401 /*
4402 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4403 * from SVC mode and no access from userspace.
4404 */
4405 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4406 +#ifdef CONFIG_PAX_KERNEXEC
4407 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4408 +#endif
4409 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4410 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4411 #endif
4412 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4413 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4414 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4415 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4416 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4417 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4418 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4419 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4420 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4421 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4422 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4423 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4424 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4425 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4426 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4427 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4428 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4429 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4430 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4431 }
4432 }
4433
4434 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4435 if (cpu_arch >= CPU_ARCH_ARMv6) {
4436 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4437 /* Non-cacheable Normal is XCB = 001 */
4438 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4439 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4440 + PMD_SECT_BUFFERED;
4441 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4442 PMD_SECT_BUFFERED;
4443 } else {
4444 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4445 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4446 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4447 + PMD_SECT_TEX(1);
4448 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4449 PMD_SECT_TEX(1);
4450 }
4451 } else {
4452 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4453 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4454 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4455 }
4456
4457 #ifdef CONFIG_ARM_LPAE
4458 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4459 vecs_pgprot |= PTE_EXT_AF;
4460 #endif
4461
4462 + user_pgprot |= __supported_pte_mask;
4463 +
4464 for (i = 0; i < 16; i++) {
4465 pteval_t v = pgprot_val(protection_map[i]);
4466 protection_map[i] = __pgprot(v | user_pgprot);
4467 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4468
4469 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4470 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4471 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4472 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4473 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4474 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4475 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4476 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4477 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4478 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4479 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4480 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4481 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4482 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4483 mem_types[MT_ROM].prot_sect |= cp->pmd;
4484
4485 switch (cp->pmd) {
4486 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4487 * called function. This means you can't use any function or debugging
4488 * method which may touch any device, otherwise the kernel _will_ crash.
4489 */
4490 +
4491 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4492 +
4493 static void __init devicemaps_init(struct machine_desc *mdesc)
4494 {
4495 struct map_desc map;
4496 unsigned long addr;
4497 - void *vectors;
4498
4499 - /*
4500 - * Allocate the vector page early.
4501 - */
4502 - vectors = early_alloc(PAGE_SIZE * 2);
4503 -
4504 - early_trap_init(vectors);
4505 + early_trap_init(&vectors);
4506
4507 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4508 pmd_clear(pmd_off_k(addr));
4509 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4510 * location (0xffff0000). If we aren't using high-vectors, also
4511 * create a mapping at the low-vectors virtual address.
4512 */
4513 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4514 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4515 map.virtual = 0xffff0000;
4516 map.length = PAGE_SIZE;
4517 #ifdef CONFIG_KUSER_HELPERS
4518 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4519 map.pfn = __phys_to_pfn(start);
4520 map.virtual = __phys_to_virt(start);
4521 map.length = end - start;
4522 - map.type = MT_MEMORY;
4523
4524 +#ifdef CONFIG_PAX_KERNEXEC
4525 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4526 + struct map_desc kernel;
4527 + struct map_desc initmap;
4528 +
4529 + /* when freeing initmem we will make this RW */
4530 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4531 + initmap.virtual = (unsigned long)__init_begin;
4532 + initmap.length = _sdata - __init_begin;
4533 + initmap.type = MT_MEMORY_RWX;
4534 + create_mapping(&initmap);
4535 +
4536 + /* when freeing initmem we will make this RX */
4537 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4538 + kernel.virtual = (unsigned long)_stext;
4539 + kernel.length = __init_begin - _stext;
4540 + kernel.type = MT_MEMORY_RWX;
4541 + create_mapping(&kernel);
4542 +
4543 + if (map.virtual < (unsigned long)_stext) {
4544 + map.length = (unsigned long)_stext - map.virtual;
4545 + map.type = MT_MEMORY_RWX;
4546 + create_mapping(&map);
4547 + }
4548 +
4549 + map.pfn = __phys_to_pfn(__pa(_sdata));
4550 + map.virtual = (unsigned long)_sdata;
4551 + map.length = end - __pa(_sdata);
4552 + }
4553 +#endif
4554 +
4555 + map.type = MT_MEMORY_RW;
4556 create_mapping(&map);
4557 }
4558 }
4559 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4560 index a5bc92d..0bb4730 100644
4561 --- a/arch/arm/plat-omap/sram.c
4562 +++ b/arch/arm/plat-omap/sram.c
4563 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4564 * Looks like we need to preserve some bootloader code at the
4565 * beginning of SRAM for jumping to flash for reboot to work...
4566 */
4567 + pax_open_kernel();
4568 memset_io(omap_sram_base + omap_sram_skip, 0,
4569 omap_sram_size - omap_sram_skip);
4570 + pax_close_kernel();
4571 }
4572 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4573 index ce6d763..cfea917 100644
4574 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4575 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4576 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4577 int (*started)(unsigned ch);
4578 int (*flush)(unsigned ch);
4579 int (*stop)(unsigned ch);
4580 -};
4581 +} __no_const;
4582
4583 extern void *samsung_dmadev_get_ops(void);
4584 extern void *s3c_dma_get_ops(void);
4585 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4586 index c3a58a1..78fbf54 100644
4587 --- a/arch/avr32/include/asm/cache.h
4588 +++ b/arch/avr32/include/asm/cache.h
4589 @@ -1,8 +1,10 @@
4590 #ifndef __ASM_AVR32_CACHE_H
4591 #define __ASM_AVR32_CACHE_H
4592
4593 +#include <linux/const.h>
4594 +
4595 #define L1_CACHE_SHIFT 5
4596 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4597 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4598
4599 /*
4600 * Memory returned by kmalloc() may be used for DMA, so we must make
4601 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4602 index d232888..87c8df1 100644
4603 --- a/arch/avr32/include/asm/elf.h
4604 +++ b/arch/avr32/include/asm/elf.h
4605 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4606 the loader. We need to make sure that it is out of the way of the program
4607 that it will "exec", and that there is sufficient room for the brk. */
4608
4609 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4610 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4611
4612 +#ifdef CONFIG_PAX_ASLR
4613 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4614 +
4615 +#define PAX_DELTA_MMAP_LEN 15
4616 +#define PAX_DELTA_STACK_LEN 15
4617 +#endif
4618
4619 /* This yields a mask that user programs can use to figure out what
4620 instruction set this CPU supports. This could be done in user space,
4621 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4622 index 479330b..53717a8 100644
4623 --- a/arch/avr32/include/asm/kmap_types.h
4624 +++ b/arch/avr32/include/asm/kmap_types.h
4625 @@ -2,9 +2,9 @@
4626 #define __ASM_AVR32_KMAP_TYPES_H
4627
4628 #ifdef CONFIG_DEBUG_HIGHMEM
4629 -# define KM_TYPE_NR 29
4630 +# define KM_TYPE_NR 30
4631 #else
4632 -# define KM_TYPE_NR 14
4633 +# define KM_TYPE_NR 15
4634 #endif
4635
4636 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4637 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4638 index b2f2d2d..d1c85cb 100644
4639 --- a/arch/avr32/mm/fault.c
4640 +++ b/arch/avr32/mm/fault.c
4641 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4642
4643 int exception_trace = 1;
4644
4645 +#ifdef CONFIG_PAX_PAGEEXEC
4646 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4647 +{
4648 + unsigned long i;
4649 +
4650 + printk(KERN_ERR "PAX: bytes at PC: ");
4651 + for (i = 0; i < 20; i++) {
4652 + unsigned char c;
4653 + if (get_user(c, (unsigned char *)pc+i))
4654 + printk(KERN_CONT "???????? ");
4655 + else
4656 + printk(KERN_CONT "%02x ", c);
4657 + }
4658 + printk("\n");
4659 +}
4660 +#endif
4661 +
4662 /*
4663 * This routine handles page faults. It determines the address and the
4664 * problem, and then passes it off to one of the appropriate routines.
4665 @@ -174,6 +191,16 @@ bad_area:
4666 up_read(&mm->mmap_sem);
4667
4668 if (user_mode(regs)) {
4669 +
4670 +#ifdef CONFIG_PAX_PAGEEXEC
4671 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4672 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4673 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4674 + do_group_exit(SIGKILL);
4675 + }
4676 + }
4677 +#endif
4678 +
4679 if (exception_trace && printk_ratelimit())
4680 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4681 "sp %08lx ecr %lu\n",
4682 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4683 index 568885a..f8008df 100644
4684 --- a/arch/blackfin/include/asm/cache.h
4685 +++ b/arch/blackfin/include/asm/cache.h
4686 @@ -7,6 +7,7 @@
4687 #ifndef __ARCH_BLACKFIN_CACHE_H
4688 #define __ARCH_BLACKFIN_CACHE_H
4689
4690 +#include <linux/const.h>
4691 #include <linux/linkage.h> /* for asmlinkage */
4692
4693 /*
4694 @@ -14,7 +15,7 @@
4695 * Blackfin loads 32 bytes for cache
4696 */
4697 #define L1_CACHE_SHIFT 5
4698 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4699 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4700 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4701
4702 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4703 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4704 index aea2718..3639a60 100644
4705 --- a/arch/cris/include/arch-v10/arch/cache.h
4706 +++ b/arch/cris/include/arch-v10/arch/cache.h
4707 @@ -1,8 +1,9 @@
4708 #ifndef _ASM_ARCH_CACHE_H
4709 #define _ASM_ARCH_CACHE_H
4710
4711 +#include <linux/const.h>
4712 /* Etrax 100LX have 32-byte cache-lines. */
4713 -#define L1_CACHE_BYTES 32
4714 #define L1_CACHE_SHIFT 5
4715 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4716
4717 #endif /* _ASM_ARCH_CACHE_H */
4718 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4719 index 7caf25d..ee65ac5 100644
4720 --- a/arch/cris/include/arch-v32/arch/cache.h
4721 +++ b/arch/cris/include/arch-v32/arch/cache.h
4722 @@ -1,11 +1,12 @@
4723 #ifndef _ASM_CRIS_ARCH_CACHE_H
4724 #define _ASM_CRIS_ARCH_CACHE_H
4725
4726 +#include <linux/const.h>
4727 #include <arch/hwregs/dma.h>
4728
4729 /* A cache-line is 32 bytes. */
4730 -#define L1_CACHE_BYTES 32
4731 #define L1_CACHE_SHIFT 5
4732 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4733
4734 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4735
4736 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4737 index b86329d..6709906 100644
4738 --- a/arch/frv/include/asm/atomic.h
4739 +++ b/arch/frv/include/asm/atomic.h
4740 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4741 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4742 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4743
4744 +#define atomic64_read_unchecked(v) atomic64_read(v)
4745 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4746 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4747 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4748 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4749 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4750 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4751 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4752 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4753 +
4754 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4755 {
4756 int c, old;
4757 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4758 index 2797163..c2a401d 100644
4759 --- a/arch/frv/include/asm/cache.h
4760 +++ b/arch/frv/include/asm/cache.h
4761 @@ -12,10 +12,11 @@
4762 #ifndef __ASM_CACHE_H
4763 #define __ASM_CACHE_H
4764
4765 +#include <linux/const.h>
4766
4767 /* bytes per L1 cache line */
4768 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4769 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4770 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4771
4772 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4773 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4774 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4775 index 43901f2..0d8b865 100644
4776 --- a/arch/frv/include/asm/kmap_types.h
4777 +++ b/arch/frv/include/asm/kmap_types.h
4778 @@ -2,6 +2,6 @@
4779 #ifndef _ASM_KMAP_TYPES_H
4780 #define _ASM_KMAP_TYPES_H
4781
4782 -#define KM_TYPE_NR 17
4783 +#define KM_TYPE_NR 18
4784
4785 #endif
4786 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4787 index 836f147..4cf23f5 100644
4788 --- a/arch/frv/mm/elf-fdpic.c
4789 +++ b/arch/frv/mm/elf-fdpic.c
4790 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4791 {
4792 struct vm_area_struct *vma;
4793 struct vm_unmapped_area_info info;
4794 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4795
4796 if (len > TASK_SIZE)
4797 return -ENOMEM;
4798 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4799 if (addr) {
4800 addr = PAGE_ALIGN(addr);
4801 vma = find_vma(current->mm, addr);
4802 - if (TASK_SIZE - len >= addr &&
4803 - (!vma || addr + len <= vma->vm_start))
4804 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4805 goto success;
4806 }
4807
4808 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4809 info.high_limit = (current->mm->start_stack - 0x00200000);
4810 info.align_mask = 0;
4811 info.align_offset = 0;
4812 + info.threadstack_offset = offset;
4813 addr = vm_unmapped_area(&info);
4814 if (!(addr & ~PAGE_MASK))
4815 goto success;
4816 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4817 index f4ca594..adc72fd6 100644
4818 --- a/arch/hexagon/include/asm/cache.h
4819 +++ b/arch/hexagon/include/asm/cache.h
4820 @@ -21,9 +21,11 @@
4821 #ifndef __ASM_CACHE_H
4822 #define __ASM_CACHE_H
4823
4824 +#include <linux/const.h>
4825 +
4826 /* Bytes per L1 cache line */
4827 -#define L1_CACHE_SHIFT (5)
4828 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4829 +#define L1_CACHE_SHIFT 5
4830 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4831
4832 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4833 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4834 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4835 index 6e6fe18..a6ae668 100644
4836 --- a/arch/ia64/include/asm/atomic.h
4837 +++ b/arch/ia64/include/asm/atomic.h
4838 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4839 #define atomic64_inc(v) atomic64_add(1, (v))
4840 #define atomic64_dec(v) atomic64_sub(1, (v))
4841
4842 +#define atomic64_read_unchecked(v) atomic64_read(v)
4843 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4844 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4845 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4846 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4847 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4848 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4849 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4850 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4851 +
4852 /* Atomic operations are already serializing */
4853 #define smp_mb__before_atomic_dec() barrier()
4854 #define smp_mb__after_atomic_dec() barrier()
4855 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4856 index 988254a..e1ee885 100644
4857 --- a/arch/ia64/include/asm/cache.h
4858 +++ b/arch/ia64/include/asm/cache.h
4859 @@ -1,6 +1,7 @@
4860 #ifndef _ASM_IA64_CACHE_H
4861 #define _ASM_IA64_CACHE_H
4862
4863 +#include <linux/const.h>
4864
4865 /*
4866 * Copyright (C) 1998-2000 Hewlett-Packard Co
4867 @@ -9,7 +10,7 @@
4868
4869 /* Bytes per L1 (data) cache line. */
4870 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4871 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4872 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4873
4874 #ifdef CONFIG_SMP
4875 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4876 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4877 index 5a83c5c..4d7f553 100644
4878 --- a/arch/ia64/include/asm/elf.h
4879 +++ b/arch/ia64/include/asm/elf.h
4880 @@ -42,6 +42,13 @@
4881 */
4882 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4883
4884 +#ifdef CONFIG_PAX_ASLR
4885 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4886 +
4887 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4888 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4889 +#endif
4890 +
4891 #define PT_IA_64_UNWIND 0x70000001
4892
4893 /* IA-64 relocations: */
4894 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4895 index 96a8d92..617a1cf 100644
4896 --- a/arch/ia64/include/asm/pgalloc.h
4897 +++ b/arch/ia64/include/asm/pgalloc.h
4898 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4899 pgd_val(*pgd_entry) = __pa(pud);
4900 }
4901
4902 +static inline void
4903 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4904 +{
4905 + pgd_populate(mm, pgd_entry, pud);
4906 +}
4907 +
4908 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4909 {
4910 return quicklist_alloc(0, GFP_KERNEL, NULL);
4911 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4912 pud_val(*pud_entry) = __pa(pmd);
4913 }
4914
4915 +static inline void
4916 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4917 +{
4918 + pud_populate(mm, pud_entry, pmd);
4919 +}
4920 +
4921 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4922 {
4923 return quicklist_alloc(0, GFP_KERNEL, NULL);
4924 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4925 index 7935115..c0eca6a 100644
4926 --- a/arch/ia64/include/asm/pgtable.h
4927 +++ b/arch/ia64/include/asm/pgtable.h
4928 @@ -12,7 +12,7 @@
4929 * David Mosberger-Tang <davidm@hpl.hp.com>
4930 */
4931
4932 -
4933 +#include <linux/const.h>
4934 #include <asm/mman.h>
4935 #include <asm/page.h>
4936 #include <asm/processor.h>
4937 @@ -142,6 +142,17 @@
4938 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4939 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4940 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4941 +
4942 +#ifdef CONFIG_PAX_PAGEEXEC
4943 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4944 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4945 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4946 +#else
4947 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4948 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4949 +# define PAGE_COPY_NOEXEC PAGE_COPY
4950 +#endif
4951 +
4952 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4953 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4954 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4955 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4956 index 54ff557..70c88b7 100644
4957 --- a/arch/ia64/include/asm/spinlock.h
4958 +++ b/arch/ia64/include/asm/spinlock.h
4959 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4960 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4961
4962 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4963 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4964 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4965 }
4966
4967 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4968 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4969 index 449c8c0..18965fb 100644
4970 --- a/arch/ia64/include/asm/uaccess.h
4971 +++ b/arch/ia64/include/asm/uaccess.h
4972 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4973 static inline unsigned long
4974 __copy_to_user (void __user *to, const void *from, unsigned long count)
4975 {
4976 + if (count > INT_MAX)
4977 + return count;
4978 +
4979 + if (!__builtin_constant_p(count))
4980 + check_object_size(from, count, true);
4981 +
4982 return __copy_user(to, (__force void __user *) from, count);
4983 }
4984
4985 static inline unsigned long
4986 __copy_from_user (void *to, const void __user *from, unsigned long count)
4987 {
4988 + if (count > INT_MAX)
4989 + return count;
4990 +
4991 + if (!__builtin_constant_p(count))
4992 + check_object_size(to, count, false);
4993 +
4994 return __copy_user((__force void __user *) to, from, count);
4995 }
4996
4997 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4998 ({ \
4999 void __user *__cu_to = (to); \
5000 const void *__cu_from = (from); \
5001 - long __cu_len = (n); \
5002 + unsigned long __cu_len = (n); \
5003 \
5004 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5005 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5006 + if (!__builtin_constant_p(n)) \
5007 + check_object_size(__cu_from, __cu_len, true); \
5008 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5009 + } \
5010 __cu_len; \
5011 })
5012
5013 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5014 ({ \
5015 void *__cu_to = (to); \
5016 const void __user *__cu_from = (from); \
5017 - long __cu_len = (n); \
5018 + unsigned long __cu_len = (n); \
5019 \
5020 __chk_user_ptr(__cu_from); \
5021 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5022 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5023 + if (!__builtin_constant_p(n)) \
5024 + check_object_size(__cu_to, __cu_len, false); \
5025 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5026 + } \
5027 __cu_len; \
5028 })
5029
5030 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5031 index 24603be..948052d 100644
5032 --- a/arch/ia64/kernel/module.c
5033 +++ b/arch/ia64/kernel/module.c
5034 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5035 void
5036 module_free (struct module *mod, void *module_region)
5037 {
5038 - if (mod && mod->arch.init_unw_table &&
5039 - module_region == mod->module_init) {
5040 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5041 unw_remove_unwind_table(mod->arch.init_unw_table);
5042 mod->arch.init_unw_table = NULL;
5043 }
5044 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5045 }
5046
5047 static inline int
5048 +in_init_rx (const struct module *mod, uint64_t addr)
5049 +{
5050 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5051 +}
5052 +
5053 +static inline int
5054 +in_init_rw (const struct module *mod, uint64_t addr)
5055 +{
5056 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5057 +}
5058 +
5059 +static inline int
5060 in_init (const struct module *mod, uint64_t addr)
5061 {
5062 - return addr - (uint64_t) mod->module_init < mod->init_size;
5063 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5064 +}
5065 +
5066 +static inline int
5067 +in_core_rx (const struct module *mod, uint64_t addr)
5068 +{
5069 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5070 +}
5071 +
5072 +static inline int
5073 +in_core_rw (const struct module *mod, uint64_t addr)
5074 +{
5075 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5076 }
5077
5078 static inline int
5079 in_core (const struct module *mod, uint64_t addr)
5080 {
5081 - return addr - (uint64_t) mod->module_core < mod->core_size;
5082 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5083 }
5084
5085 static inline int
5086 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5087 break;
5088
5089 case RV_BDREL:
5090 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5091 + if (in_init_rx(mod, val))
5092 + val -= (uint64_t) mod->module_init_rx;
5093 + else if (in_init_rw(mod, val))
5094 + val -= (uint64_t) mod->module_init_rw;
5095 + else if (in_core_rx(mod, val))
5096 + val -= (uint64_t) mod->module_core_rx;
5097 + else if (in_core_rw(mod, val))
5098 + val -= (uint64_t) mod->module_core_rw;
5099 break;
5100
5101 case RV_LTV:
5102 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5103 * addresses have been selected...
5104 */
5105 uint64_t gp;
5106 - if (mod->core_size > MAX_LTOFF)
5107 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5108 /*
5109 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5110 * at the end of the module.
5111 */
5112 - gp = mod->core_size - MAX_LTOFF / 2;
5113 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5114 else
5115 - gp = mod->core_size / 2;
5116 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5117 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5118 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5119 mod->arch.gp = gp;
5120 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5121 }
5122 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5123 index ab33328..f39506c 100644
5124 --- a/arch/ia64/kernel/palinfo.c
5125 +++ b/arch/ia64/kernel/palinfo.c
5126 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5127 return NOTIFY_OK;
5128 }
5129
5130 -static struct notifier_block __refdata palinfo_cpu_notifier =
5131 +static struct notifier_block palinfo_cpu_notifier =
5132 {
5133 .notifier_call = palinfo_cpu_callback,
5134 .priority = 0,
5135 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5136 index 41e33f8..65180b2 100644
5137 --- a/arch/ia64/kernel/sys_ia64.c
5138 +++ b/arch/ia64/kernel/sys_ia64.c
5139 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5140 unsigned long align_mask = 0;
5141 struct mm_struct *mm = current->mm;
5142 struct vm_unmapped_area_info info;
5143 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5144
5145 if (len > RGN_MAP_LIMIT)
5146 return -ENOMEM;
5147 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5148 if (REGION_NUMBER(addr) == RGN_HPAGE)
5149 addr = 0;
5150 #endif
5151 +
5152 +#ifdef CONFIG_PAX_RANDMMAP
5153 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5154 + addr = mm->free_area_cache;
5155 + else
5156 +#endif
5157 +
5158 if (!addr)
5159 addr = TASK_UNMAPPED_BASE;
5160
5161 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5162 info.high_limit = TASK_SIZE;
5163 info.align_mask = align_mask;
5164 info.align_offset = 0;
5165 + info.threadstack_offset = offset;
5166 return vm_unmapped_area(&info);
5167 }
5168
5169 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5170 index 0ccb28f..8992469 100644
5171 --- a/arch/ia64/kernel/vmlinux.lds.S
5172 +++ b/arch/ia64/kernel/vmlinux.lds.S
5173 @@ -198,7 +198,7 @@ SECTIONS {
5174 /* Per-cpu data: */
5175 . = ALIGN(PERCPU_PAGE_SIZE);
5176 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5177 - __phys_per_cpu_start = __per_cpu_load;
5178 + __phys_per_cpu_start = per_cpu_load;
5179 /*
5180 * ensure percpu data fits
5181 * into percpu page size
5182 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5183 index 6cf0341..d352594 100644
5184 --- a/arch/ia64/mm/fault.c
5185 +++ b/arch/ia64/mm/fault.c
5186 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5187 return pte_present(pte);
5188 }
5189
5190 +#ifdef CONFIG_PAX_PAGEEXEC
5191 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5192 +{
5193 + unsigned long i;
5194 +
5195 + printk(KERN_ERR "PAX: bytes at PC: ");
5196 + for (i = 0; i < 8; i++) {
5197 + unsigned int c;
5198 + if (get_user(c, (unsigned int *)pc+i))
5199 + printk(KERN_CONT "???????? ");
5200 + else
5201 + printk(KERN_CONT "%08x ", c);
5202 + }
5203 + printk("\n");
5204 +}
5205 +#endif
5206 +
5207 # define VM_READ_BIT 0
5208 # define VM_WRITE_BIT 1
5209 # define VM_EXEC_BIT 2
5210 @@ -149,8 +166,21 @@ retry:
5211 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5212 goto bad_area;
5213
5214 - if ((vma->vm_flags & mask) != mask)
5215 + if ((vma->vm_flags & mask) != mask) {
5216 +
5217 +#ifdef CONFIG_PAX_PAGEEXEC
5218 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5219 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5220 + goto bad_area;
5221 +
5222 + up_read(&mm->mmap_sem);
5223 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5224 + do_group_exit(SIGKILL);
5225 + }
5226 +#endif
5227 +
5228 goto bad_area;
5229 + }
5230
5231 /*
5232 * If for any reason at all we couldn't handle the fault, make
5233 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5234 index 76069c1..c2aa816 100644
5235 --- a/arch/ia64/mm/hugetlbpage.c
5236 +++ b/arch/ia64/mm/hugetlbpage.c
5237 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5238 unsigned long pgoff, unsigned long flags)
5239 {
5240 struct vm_unmapped_area_info info;
5241 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5242
5243 if (len > RGN_MAP_LIMIT)
5244 return -ENOMEM;
5245 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5246 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5247 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5248 info.align_offset = 0;
5249 + info.threadstack_offset = offset;
5250 return vm_unmapped_area(&info);
5251 }
5252
5253 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5254 index b6f7f43..c04320d 100644
5255 --- a/arch/ia64/mm/init.c
5256 +++ b/arch/ia64/mm/init.c
5257 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5258 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5259 vma->vm_end = vma->vm_start + PAGE_SIZE;
5260 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5261 +
5262 +#ifdef CONFIG_PAX_PAGEEXEC
5263 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5264 + vma->vm_flags &= ~VM_EXEC;
5265 +
5266 +#ifdef CONFIG_PAX_MPROTECT
5267 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5268 + vma->vm_flags &= ~VM_MAYEXEC;
5269 +#endif
5270 +
5271 + }
5272 +#endif
5273 +
5274 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5275 down_write(&current->mm->mmap_sem);
5276 if (insert_vm_struct(current->mm, vma)) {
5277 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5278 index 40b3ee9..8c2c112 100644
5279 --- a/arch/m32r/include/asm/cache.h
5280 +++ b/arch/m32r/include/asm/cache.h
5281 @@ -1,8 +1,10 @@
5282 #ifndef _ASM_M32R_CACHE_H
5283 #define _ASM_M32R_CACHE_H
5284
5285 +#include <linux/const.h>
5286 +
5287 /* L1 cache line size */
5288 #define L1_CACHE_SHIFT 4
5289 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5290 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5291
5292 #endif /* _ASM_M32R_CACHE_H */
5293 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5294 index 82abd15..d95ae5d 100644
5295 --- a/arch/m32r/lib/usercopy.c
5296 +++ b/arch/m32r/lib/usercopy.c
5297 @@ -14,6 +14,9 @@
5298 unsigned long
5299 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5300 {
5301 + if ((long)n < 0)
5302 + return n;
5303 +
5304 prefetch(from);
5305 if (access_ok(VERIFY_WRITE, to, n))
5306 __copy_user(to,from,n);
5307 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5308 unsigned long
5309 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5310 {
5311 + if ((long)n < 0)
5312 + return n;
5313 +
5314 prefetchw(to);
5315 if (access_ok(VERIFY_READ, from, n))
5316 __copy_user_zeroing(to,from,n);
5317 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5318 index 0395c51..5f26031 100644
5319 --- a/arch/m68k/include/asm/cache.h
5320 +++ b/arch/m68k/include/asm/cache.h
5321 @@ -4,9 +4,11 @@
5322 #ifndef __ARCH_M68K_CACHE_H
5323 #define __ARCH_M68K_CACHE_H
5324
5325 +#include <linux/const.h>
5326 +
5327 /* bytes per L1 cache line */
5328 #define L1_CACHE_SHIFT 4
5329 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5330 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5331
5332 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5333
5334 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5335 index 3c52fa6..11b2ad8 100644
5336 --- a/arch/metag/mm/hugetlbpage.c
5337 +++ b/arch/metag/mm/hugetlbpage.c
5338 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5339 info.high_limit = TASK_SIZE;
5340 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5341 info.align_offset = 0;
5342 + info.threadstack_offset = 0;
5343 return vm_unmapped_area(&info);
5344 }
5345
5346 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5347 index 4efe96a..60e8699 100644
5348 --- a/arch/microblaze/include/asm/cache.h
5349 +++ b/arch/microblaze/include/asm/cache.h
5350 @@ -13,11 +13,12 @@
5351 #ifndef _ASM_MICROBLAZE_CACHE_H
5352 #define _ASM_MICROBLAZE_CACHE_H
5353
5354 +#include <linux/const.h>
5355 #include <asm/registers.h>
5356
5357 #define L1_CACHE_SHIFT 5
5358 /* word-granular cache in microblaze */
5359 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5360 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5361
5362 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5363
5364 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5365 index 08b6079..8b554d2 100644
5366 --- a/arch/mips/include/asm/atomic.h
5367 +++ b/arch/mips/include/asm/atomic.h
5368 @@ -21,15 +21,39 @@
5369 #include <asm/cmpxchg.h>
5370 #include <asm/war.h>
5371
5372 +#ifdef CONFIG_GENERIC_ATOMIC64
5373 +#include <asm-generic/atomic64.h>
5374 +#endif
5375 +
5376 #define ATOMIC_INIT(i) { (i) }
5377
5378 +#ifdef CONFIG_64BIT
5379 +#define _ASM_EXTABLE(from, to) \
5380 +" .section __ex_table,\"a\"\n" \
5381 +" .dword " #from ", " #to"\n" \
5382 +" .previous\n"
5383 +#else
5384 +#define _ASM_EXTABLE(from, to) \
5385 +" .section __ex_table,\"a\"\n" \
5386 +" .word " #from ", " #to"\n" \
5387 +" .previous\n"
5388 +#endif
5389 +
5390 /*
5391 * atomic_read - read atomic variable
5392 * @v: pointer of type atomic_t
5393 *
5394 * Atomically reads the value of @v.
5395 */
5396 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5397 +static inline int atomic_read(const atomic_t *v)
5398 +{
5399 + return (*(volatile const int *) &v->counter);
5400 +}
5401 +
5402 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5403 +{
5404 + return (*(volatile const int *) &v->counter);
5405 +}
5406
5407 /*
5408 * atomic_set - set atomic variable
5409 @@ -38,7 +62,15 @@
5410 *
5411 * Atomically sets the value of @v to @i.
5412 */
5413 -#define atomic_set(v, i) ((v)->counter = (i))
5414 +static inline void atomic_set(atomic_t *v, int i)
5415 +{
5416 + v->counter = i;
5417 +}
5418 +
5419 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5420 +{
5421 + v->counter = i;
5422 +}
5423
5424 /*
5425 * atomic_add - add integer to atomic variable
5426 @@ -47,7 +79,67 @@
5427 *
5428 * Atomically adds @i to @v.
5429 */
5430 -static __inline__ void atomic_add(int i, atomic_t * v)
5431 +static __inline__ void atomic_add(int i, atomic_t *v)
5432 +{
5433 + int temp;
5434 +
5435 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5436 + __asm__ __volatile__(
5437 + " .set mips3 \n"
5438 + "1: ll %0, %1 # atomic_add \n"
5439 +#ifdef CONFIG_PAX_REFCOUNT
5440 + /* Exception on overflow. */
5441 + "2: add %0, %2 \n"
5442 +#else
5443 + " addu %0, %2 \n"
5444 +#endif
5445 + " sc %0, %1 \n"
5446 + " beqzl %0, 1b \n"
5447 +#ifdef CONFIG_PAX_REFCOUNT
5448 + "3: \n"
5449 + _ASM_EXTABLE(2b, 3b)
5450 +#endif
5451 + " .set mips0 \n"
5452 + : "=&r" (temp), "+m" (v->counter)
5453 + : "Ir" (i));
5454 + } else if (kernel_uses_llsc) {
5455 + __asm__ __volatile__(
5456 + " .set mips3 \n"
5457 + "1: ll %0, %1 # atomic_add \n"
5458 +#ifdef CONFIG_PAX_REFCOUNT
5459 + /* Exception on overflow. */
5460 + "2: add %0, %2 \n"
5461 +#else
5462 + " addu %0, %2 \n"
5463 +#endif
5464 + " sc %0, %1 \n"
5465 + " beqz %0, 1b \n"
5466 +#ifdef CONFIG_PAX_REFCOUNT
5467 + "3: \n"
5468 + _ASM_EXTABLE(2b, 3b)
5469 +#endif
5470 + " .set mips0 \n"
5471 + : "=&r" (temp), "+m" (v->counter)
5472 + : "Ir" (i));
5473 + } else {
5474 + unsigned long flags;
5475 +
5476 + raw_local_irq_save(flags);
5477 + __asm__ __volatile__(
5478 +#ifdef CONFIG_PAX_REFCOUNT
5479 + /* Exception on overflow. */
5480 + "1: add %0, %1 \n"
5481 + "2: \n"
5482 + _ASM_EXTABLE(1b, 2b)
5483 +#else
5484 + " addu %0, %1 \n"
5485 +#endif
5486 + : "+r" (v->counter) : "Ir" (i));
5487 + raw_local_irq_restore(flags);
5488 + }
5489 +}
5490 +
5491 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5492 {
5493 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5494 int temp;
5495 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5496 *
5497 * Atomically subtracts @i from @v.
5498 */
5499 -static __inline__ void atomic_sub(int i, atomic_t * v)
5500 +static __inline__ void atomic_sub(int i, atomic_t *v)
5501 +{
5502 + int temp;
5503 +
5504 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5505 + __asm__ __volatile__(
5506 + " .set mips3 \n"
5507 + "1: ll %0, %1 # atomic64_sub \n"
5508 +#ifdef CONFIG_PAX_REFCOUNT
5509 + /* Exception on overflow. */
5510 + "2: sub %0, %2 \n"
5511 +#else
5512 + " subu %0, %2 \n"
5513 +#endif
5514 + " sc %0, %1 \n"
5515 + " beqzl %0, 1b \n"
5516 +#ifdef CONFIG_PAX_REFCOUNT
5517 + "3: \n"
5518 + _ASM_EXTABLE(2b, 3b)
5519 +#endif
5520 + " .set mips0 \n"
5521 + : "=&r" (temp), "+m" (v->counter)
5522 + : "Ir" (i));
5523 + } else if (kernel_uses_llsc) {
5524 + __asm__ __volatile__(
5525 + " .set mips3 \n"
5526 + "1: ll %0, %1 # atomic64_sub \n"
5527 +#ifdef CONFIG_PAX_REFCOUNT
5528 + /* Exception on overflow. */
5529 + "2: sub %0, %2 \n"
5530 +#else
5531 + " subu %0, %2 \n"
5532 +#endif
5533 + " sc %0, %1 \n"
5534 + " beqz %0, 1b \n"
5535 +#ifdef CONFIG_PAX_REFCOUNT
5536 + "3: \n"
5537 + _ASM_EXTABLE(2b, 3b)
5538 +#endif
5539 + " .set mips0 \n"
5540 + : "=&r" (temp), "+m" (v->counter)
5541 + : "Ir" (i));
5542 + } else {
5543 + unsigned long flags;
5544 +
5545 + raw_local_irq_save(flags);
5546 + __asm__ __volatile__(
5547 +#ifdef CONFIG_PAX_REFCOUNT
5548 + /* Exception on overflow. */
5549 + "1: sub %0, %1 \n"
5550 + "2: \n"
5551 + _ASM_EXTABLE(1b, 2b)
5552 +#else
5553 + " subu %0, %1 \n"
5554 +#endif
5555 + : "+r" (v->counter) : "Ir" (i));
5556 + raw_local_irq_restore(flags);
5557 + }
5558 +}
5559 +
5560 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5561 {
5562 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5563 int temp;
5564 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5565 /*
5566 * Same as above, but return the result value
5567 */
5568 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5569 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5570 +{
5571 + int result;
5572 + int temp;
5573 +
5574 + smp_mb__before_llsc();
5575 +
5576 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5577 + __asm__ __volatile__(
5578 + " .set mips3 \n"
5579 + "1: ll %1, %2 # atomic_add_return \n"
5580 +#ifdef CONFIG_PAX_REFCOUNT
5581 + "2: add %0, %1, %3 \n"
5582 +#else
5583 + " addu %0, %1, %3 \n"
5584 +#endif
5585 + " sc %0, %2 \n"
5586 + " beqzl %0, 1b \n"
5587 +#ifdef CONFIG_PAX_REFCOUNT
5588 + " b 4f \n"
5589 + " .set noreorder \n"
5590 + "3: b 5f \n"
5591 + " move %0, %1 \n"
5592 + " .set reorder \n"
5593 + _ASM_EXTABLE(2b, 3b)
5594 +#endif
5595 + "4: addu %0, %1, %3 \n"
5596 +#ifdef CONFIG_PAX_REFCOUNT
5597 + "5: \n"
5598 +#endif
5599 + " .set mips0 \n"
5600 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5601 + : "Ir" (i));
5602 + } else if (kernel_uses_llsc) {
5603 + __asm__ __volatile__(
5604 + " .set mips3 \n"
5605 + "1: ll %1, %2 # atomic_add_return \n"
5606 +#ifdef CONFIG_PAX_REFCOUNT
5607 + "2: add %0, %1, %3 \n"
5608 +#else
5609 + " addu %0, %1, %3 \n"
5610 +#endif
5611 + " sc %0, %2 \n"
5612 + " bnez %0, 4f \n"
5613 + " b 1b \n"
5614 +#ifdef CONFIG_PAX_REFCOUNT
5615 + " .set noreorder \n"
5616 + "3: b 5f \n"
5617 + " move %0, %1 \n"
5618 + " .set reorder \n"
5619 + _ASM_EXTABLE(2b, 3b)
5620 +#endif
5621 + "4: addu %0, %1, %3 \n"
5622 +#ifdef CONFIG_PAX_REFCOUNT
5623 + "5: \n"
5624 +#endif
5625 + " .set mips0 \n"
5626 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5627 + : "Ir" (i));
5628 + } else {
5629 + unsigned long flags;
5630 +
5631 + raw_local_irq_save(flags);
5632 + __asm__ __volatile__(
5633 + " lw %0, %1 \n"
5634 +#ifdef CONFIG_PAX_REFCOUNT
5635 + /* Exception on overflow. */
5636 + "1: add %0, %2 \n"
5637 +#else
5638 + " addu %0, %2 \n"
5639 +#endif
5640 + " sw %0, %1 \n"
5641 +#ifdef CONFIG_PAX_REFCOUNT
5642 + /* Note: Dest reg is not modified on overflow */
5643 + "2: \n"
5644 + _ASM_EXTABLE(1b, 2b)
5645 +#endif
5646 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5647 + raw_local_irq_restore(flags);
5648 + }
5649 +
5650 + smp_llsc_mb();
5651 +
5652 + return result;
5653 +}
5654 +
5655 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5656 {
5657 int result;
5658
5659 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5660 return result;
5661 }
5662
5663 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5664 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5665 +{
5666 + int result;
5667 + int temp;
5668 +
5669 + smp_mb__before_llsc();
5670 +
5671 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5672 + __asm__ __volatile__(
5673 + " .set mips3 \n"
5674 + "1: ll %1, %2 # atomic_sub_return \n"
5675 +#ifdef CONFIG_PAX_REFCOUNT
5676 + "2: sub %0, %1, %3 \n"
5677 +#else
5678 + " subu %0, %1, %3 \n"
5679 +#endif
5680 + " sc %0, %2 \n"
5681 + " beqzl %0, 1b \n"
5682 +#ifdef CONFIG_PAX_REFCOUNT
5683 + " b 4f \n"
5684 + " .set noreorder \n"
5685 + "3: b 5f \n"
5686 + " move %0, %1 \n"
5687 + " .set reorder \n"
5688 + _ASM_EXTABLE(2b, 3b)
5689 +#endif
5690 + "4: subu %0, %1, %3 \n"
5691 +#ifdef CONFIG_PAX_REFCOUNT
5692 + "5: \n"
5693 +#endif
5694 + " .set mips0 \n"
5695 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5696 + : "Ir" (i), "m" (v->counter)
5697 + : "memory");
5698 + } else if (kernel_uses_llsc) {
5699 + __asm__ __volatile__(
5700 + " .set mips3 \n"
5701 + "1: ll %1, %2 # atomic_sub_return \n"
5702 +#ifdef CONFIG_PAX_REFCOUNT
5703 + "2: sub %0, %1, %3 \n"
5704 +#else
5705 + " subu %0, %1, %3 \n"
5706 +#endif
5707 + " sc %0, %2 \n"
5708 + " bnez %0, 4f \n"
5709 + " b 1b \n"
5710 +#ifdef CONFIG_PAX_REFCOUNT
5711 + " .set noreorder \n"
5712 + "3: b 5f \n"
5713 + " move %0, %1 \n"
5714 + " .set reorder \n"
5715 + _ASM_EXTABLE(2b, 3b)
5716 +#endif
5717 + "4: subu %0, %1, %3 \n"
5718 +#ifdef CONFIG_PAX_REFCOUNT
5719 + "5: \n"
5720 +#endif
5721 + " .set mips0 \n"
5722 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5723 + : "Ir" (i));
5724 + } else {
5725 + unsigned long flags;
5726 +
5727 + raw_local_irq_save(flags);
5728 + __asm__ __volatile__(
5729 + " lw %0, %1 \n"
5730 +#ifdef CONFIG_PAX_REFCOUNT
5731 + /* Exception on overflow. */
5732 + "1: sub %0, %2 \n"
5733 +#else
5734 + " subu %0, %2 \n"
5735 +#endif
5736 + " sw %0, %1 \n"
5737 +#ifdef CONFIG_PAX_REFCOUNT
5738 + /* Note: Dest reg is not modified on overflow */
5739 + "2: \n"
5740 + _ASM_EXTABLE(1b, 2b)
5741 +#endif
5742 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5743 + raw_local_irq_restore(flags);
5744 + }
5745 +
5746 + smp_llsc_mb();
5747 +
5748 + return result;
5749 +}
5750 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5751 {
5752 int result;
5753
5754 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5755 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5756 * The function returns the old value of @v minus @i.
5757 */
5758 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5759 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5760 {
5761 int result;
5762
5763 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5764 return result;
5765 }
5766
5767 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5768 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5769 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5770 +{
5771 + return cmpxchg(&v->counter, old, new);
5772 +}
5773 +
5774 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5775 + int new)
5776 +{
5777 + return cmpxchg(&(v->counter), old, new);
5778 +}
5779 +
5780 +static inline int atomic_xchg(atomic_t *v, int new)
5781 +{
5782 + return xchg(&v->counter, new);
5783 +}
5784 +
5785 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5786 +{
5787 + return xchg(&(v->counter), new);
5788 +}
5789
5790 /**
5791 * __atomic_add_unless - add unless the number is a given value
5792 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5793
5794 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5795 #define atomic_inc_return(v) atomic_add_return(1, (v))
5796 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5797 +{
5798 + return atomic_add_return_unchecked(1, v);
5799 +}
5800
5801 /*
5802 * atomic_sub_and_test - subtract value from variable and test result
5803 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5804 * other cases.
5805 */
5806 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5807 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5808 +{
5809 + return atomic_add_return_unchecked(1, v) == 0;
5810 +}
5811
5812 /*
5813 * atomic_dec_and_test - decrement by 1 and test
5814 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5815 * Atomically increments @v by 1.
5816 */
5817 #define atomic_inc(v) atomic_add(1, (v))
5818 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5819 +{
5820 + atomic_add_unchecked(1, v);
5821 +}
5822
5823 /*
5824 * atomic_dec - decrement and test
5825 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5826 * Atomically decrements @v by 1.
5827 */
5828 #define atomic_dec(v) atomic_sub(1, (v))
5829 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5830 +{
5831 + atomic_sub_unchecked(1, v);
5832 +}
5833
5834 /*
5835 * atomic_add_negative - add and test if negative
5836 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5837 * @v: pointer of type atomic64_t
5838 *
5839 */
5840 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5841 +static inline long atomic64_read(const atomic64_t *v)
5842 +{
5843 + return (*(volatile const long *) &v->counter);
5844 +}
5845 +
5846 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5847 +{
5848 + return (*(volatile const long *) &v->counter);
5849 +}
5850
5851 /*
5852 * atomic64_set - set atomic variable
5853 * @v: pointer of type atomic64_t
5854 * @i: required value
5855 */
5856 -#define atomic64_set(v, i) ((v)->counter = (i))
5857 +static inline void atomic64_set(atomic64_t *v, long i)
5858 +{
5859 + v->counter = i;
5860 +}
5861 +
5862 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5863 +{
5864 + v->counter = i;
5865 +}
5866
5867 /*
5868 * atomic64_add - add integer to atomic variable
5869 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5870 *
5871 * Atomically adds @i to @v.
5872 */
5873 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5874 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5875 +{
5876 + long temp;
5877 +
5878 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5879 + __asm__ __volatile__(
5880 + " .set mips3 \n"
5881 + "1: lld %0, %1 # atomic64_add \n"
5882 +#ifdef CONFIG_PAX_REFCOUNT
5883 + /* Exception on overflow. */
5884 + "2: dadd %0, %2 \n"
5885 +#else
5886 + " daddu %0, %2 \n"
5887 +#endif
5888 + " scd %0, %1 \n"
5889 + " beqzl %0, 1b \n"
5890 +#ifdef CONFIG_PAX_REFCOUNT
5891 + "3: \n"
5892 + _ASM_EXTABLE(2b, 3b)
5893 +#endif
5894 + " .set mips0 \n"
5895 + : "=&r" (temp), "+m" (v->counter)
5896 + : "Ir" (i));
5897 + } else if (kernel_uses_llsc) {
5898 + __asm__ __volatile__(
5899 + " .set mips3 \n"
5900 + "1: lld %0, %1 # atomic64_add \n"
5901 +#ifdef CONFIG_PAX_REFCOUNT
5902 + /* Exception on overflow. */
5903 + "2: dadd %0, %2 \n"
5904 +#else
5905 + " daddu %0, %2 \n"
5906 +#endif
5907 + " scd %0, %1 \n"
5908 + " beqz %0, 1b \n"
5909 +#ifdef CONFIG_PAX_REFCOUNT
5910 + "3: \n"
5911 + _ASM_EXTABLE(2b, 3b)
5912 +#endif
5913 + " .set mips0 \n"
5914 + : "=&r" (temp), "+m" (v->counter)
5915 + : "Ir" (i));
5916 + } else {
5917 + unsigned long flags;
5918 +
5919 + raw_local_irq_save(flags);
5920 + __asm__ __volatile__(
5921 +#ifdef CONFIG_PAX_REFCOUNT
5922 + /* Exception on overflow. */
5923 + "1: dadd %0, %1 \n"
5924 + "2: \n"
5925 + _ASM_EXTABLE(1b, 2b)
5926 +#else
5927 + " daddu %0, %1 \n"
5928 +#endif
5929 + : "+r" (v->counter) : "Ir" (i));
5930 + raw_local_irq_restore(flags);
5931 + }
5932 +}
5933 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5934 {
5935 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5936 long temp;
5937 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5938 *
5939 * Atomically subtracts @i from @v.
5940 */
5941 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5942 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5943 +{
5944 + long temp;
5945 +
5946 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5947 + __asm__ __volatile__(
5948 + " .set mips3 \n"
5949 + "1: lld %0, %1 # atomic64_sub \n"
5950 +#ifdef CONFIG_PAX_REFCOUNT
5951 + /* Exception on overflow. */
5952 + "2: dsub %0, %2 \n"
5953 +#else
5954 + " dsubu %0, %2 \n"
5955 +#endif
5956 + " scd %0, %1 \n"
5957 + " beqzl %0, 1b \n"
5958 +#ifdef CONFIG_PAX_REFCOUNT
5959 + "3: \n"
5960 + _ASM_EXTABLE(2b, 3b)
5961 +#endif
5962 + " .set mips0 \n"
5963 + : "=&r" (temp), "+m" (v->counter)
5964 + : "Ir" (i));
5965 + } else if (kernel_uses_llsc) {
5966 + __asm__ __volatile__(
5967 + " .set mips3 \n"
5968 + "1: lld %0, %1 # atomic64_sub \n"
5969 +#ifdef CONFIG_PAX_REFCOUNT
5970 + /* Exception on overflow. */
5971 + "2: dsub %0, %2 \n"
5972 +#else
5973 + " dsubu %0, %2 \n"
5974 +#endif
5975 + " scd %0, %1 \n"
5976 + " beqz %0, 1b \n"
5977 +#ifdef CONFIG_PAX_REFCOUNT
5978 + "3: \n"
5979 + _ASM_EXTABLE(2b, 3b)
5980 +#endif
5981 + " .set mips0 \n"
5982 + : "=&r" (temp), "+m" (v->counter)
5983 + : "Ir" (i));
5984 + } else {
5985 + unsigned long flags;
5986 +
5987 + raw_local_irq_save(flags);
5988 + __asm__ __volatile__(
5989 +#ifdef CONFIG_PAX_REFCOUNT
5990 + /* Exception on overflow. */
5991 + "1: dsub %0, %1 \n"
5992 + "2: \n"
5993 + _ASM_EXTABLE(1b, 2b)
5994 +#else
5995 + " dsubu %0, %1 \n"
5996 +#endif
5997 + : "+r" (v->counter) : "Ir" (i));
5998 + raw_local_irq_restore(flags);
5999 + }
6000 +}
6001 +
6002 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
6003 {
6004 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6005 long temp;
6006 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6007 /*
6008 * Same as above, but return the result value
6009 */
6010 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6011 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6012 +{
6013 + long result;
6014 + long temp;
6015 +
6016 + smp_mb__before_llsc();
6017 +
6018 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6019 + __asm__ __volatile__(
6020 + " .set mips3 \n"
6021 + "1: lld %1, %2 # atomic64_add_return \n"
6022 +#ifdef CONFIG_PAX_REFCOUNT
6023 + "2: dadd %0, %1, %3 \n"
6024 +#else
6025 + " daddu %0, %1, %3 \n"
6026 +#endif
6027 + " scd %0, %2 \n"
6028 + " beqzl %0, 1b \n"
6029 +#ifdef CONFIG_PAX_REFCOUNT
6030 + " b 4f \n"
6031 + " .set noreorder \n"
6032 + "3: b 5f \n"
6033 + " move %0, %1 \n"
6034 + " .set reorder \n"
6035 + _ASM_EXTABLE(2b, 3b)
6036 +#endif
6037 + "4: daddu %0, %1, %3 \n"
6038 +#ifdef CONFIG_PAX_REFCOUNT
6039 + "5: \n"
6040 +#endif
6041 + " .set mips0 \n"
6042 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6043 + : "Ir" (i));
6044 + } else if (kernel_uses_llsc) {
6045 + __asm__ __volatile__(
6046 + " .set mips3 \n"
6047 + "1: lld %1, %2 # atomic64_add_return \n"
6048 +#ifdef CONFIG_PAX_REFCOUNT
6049 + "2: dadd %0, %1, %3 \n"
6050 +#else
6051 + " daddu %0, %1, %3 \n"
6052 +#endif
6053 + " scd %0, %2 \n"
6054 + " bnez %0, 4f \n"
6055 + " b 1b \n"
6056 +#ifdef CONFIG_PAX_REFCOUNT
6057 + " .set noreorder \n"
6058 + "3: b 5f \n"
6059 + " move %0, %1 \n"
6060 + " .set reorder \n"
6061 + _ASM_EXTABLE(2b, 3b)
6062 +#endif
6063 + "4: daddu %0, %1, %3 \n"
6064 +#ifdef CONFIG_PAX_REFCOUNT
6065 + "5: \n"
6066 +#endif
6067 + " .set mips0 \n"
6068 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6069 + : "Ir" (i), "m" (v->counter)
6070 + : "memory");
6071 + } else {
6072 + unsigned long flags;
6073 +
6074 + raw_local_irq_save(flags);
6075 + __asm__ __volatile__(
6076 + " ld %0, %1 \n"
6077 +#ifdef CONFIG_PAX_REFCOUNT
6078 + /* Exception on overflow. */
6079 + "1: dadd %0, %2 \n"
6080 +#else
6081 + " daddu %0, %2 \n"
6082 +#endif
6083 + " sd %0, %1 \n"
6084 +#ifdef CONFIG_PAX_REFCOUNT
6085 + /* Note: Dest reg is not modified on overflow */
6086 + "2: \n"
6087 + _ASM_EXTABLE(1b, 2b)
6088 +#endif
6089 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6090 + raw_local_irq_restore(flags);
6091 + }
6092 +
6093 + smp_llsc_mb();
6094 +
6095 + return result;
6096 +}
6097 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6098 {
6099 long result;
6100
6101 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6102 return result;
6103 }
6104
6105 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6106 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6107 +{
6108 + long result;
6109 + long temp;
6110 +
6111 + smp_mb__before_llsc();
6112 +
6113 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6114 + long temp;
6115 +
6116 + __asm__ __volatile__(
6117 + " .set mips3 \n"
6118 + "1: lld %1, %2 # atomic64_sub_return \n"
6119 +#ifdef CONFIG_PAX_REFCOUNT
6120 + "2: dsub %0, %1, %3 \n"
6121 +#else
6122 + " dsubu %0, %1, %3 \n"
6123 +#endif
6124 + " scd %0, %2 \n"
6125 + " beqzl %0, 1b \n"
6126 +#ifdef CONFIG_PAX_REFCOUNT
6127 + " b 4f \n"
6128 + " .set noreorder \n"
6129 + "3: b 5f \n"
6130 + " move %0, %1 \n"
6131 + " .set reorder \n"
6132 + _ASM_EXTABLE(2b, 3b)
6133 +#endif
6134 + "4: dsubu %0, %1, %3 \n"
6135 +#ifdef CONFIG_PAX_REFCOUNT
6136 + "5: \n"
6137 +#endif
6138 + " .set mips0 \n"
6139 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6140 + : "Ir" (i), "m" (v->counter)
6141 + : "memory");
6142 + } else if (kernel_uses_llsc) {
6143 + __asm__ __volatile__(
6144 + " .set mips3 \n"
6145 + "1: lld %1, %2 # atomic64_sub_return \n"
6146 +#ifdef CONFIG_PAX_REFCOUNT
6147 + "2: dsub %0, %1, %3 \n"
6148 +#else
6149 + " dsubu %0, %1, %3 \n"
6150 +#endif
6151 + " scd %0, %2 \n"
6152 + " bnez %0, 4f \n"
6153 + " b 1b \n"
6154 +#ifdef CONFIG_PAX_REFCOUNT
6155 + " .set noreorder \n"
6156 + "3: b 5f \n"
6157 + " move %0, %1 \n"
6158 + " .set reorder \n"
6159 + _ASM_EXTABLE(2b, 3b)
6160 +#endif
6161 + "4: dsubu %0, %1, %3 \n"
6162 +#ifdef CONFIG_PAX_REFCOUNT
6163 + "5: \n"
6164 +#endif
6165 + " .set mips0 \n"
6166 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6167 + : "Ir" (i), "m" (v->counter)
6168 + : "memory");
6169 + } else {
6170 + unsigned long flags;
6171 +
6172 + raw_local_irq_save(flags);
6173 + __asm__ __volatile__(
6174 + " ld %0, %1 \n"
6175 +#ifdef CONFIG_PAX_REFCOUNT
6176 + /* Exception on overflow. */
6177 + "1: dsub %0, %2 \n"
6178 +#else
6179 + " dsubu %0, %2 \n"
6180 +#endif
6181 + " sd %0, %1 \n"
6182 +#ifdef CONFIG_PAX_REFCOUNT
6183 + /* Note: Dest reg is not modified on overflow */
6184 + "2: \n"
6185 + _ASM_EXTABLE(1b, 2b)
6186 +#endif
6187 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6188 + raw_local_irq_restore(flags);
6189 + }
6190 +
6191 + smp_llsc_mb();
6192 +
6193 + return result;
6194 +}
6195 +
6196 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6197 {
6198 long result;
6199
6200 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6201 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6202 * The function returns the old value of @v minus @i.
6203 */
6204 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6205 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6206 {
6207 long result;
6208
6209 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6210 return result;
6211 }
6212
6213 -#define atomic64_cmpxchg(v, o, n) \
6214 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6215 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6216 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6217 +{
6218 + return cmpxchg(&v->counter, old, new);
6219 +}
6220 +
6221 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6222 + long new)
6223 +{
6224 + return cmpxchg(&(v->counter), old, new);
6225 +}
6226 +
6227 +static inline long atomic64_xchg(atomic64_t *v, long new)
6228 +{
6229 + return xchg(&v->counter, new);
6230 +}
6231 +
6232 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6233 +{
6234 + return xchg(&(v->counter), new);
6235 +}
6236
6237 /**
6238 * atomic64_add_unless - add unless the number is a given value
6239 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6240
6241 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6242 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6243 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6244
6245 /*
6246 * atomic64_sub_and_test - subtract value from variable and test result
6247 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6248 * other cases.
6249 */
6250 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6251 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6252
6253 /*
6254 * atomic64_dec_and_test - decrement by 1 and test
6255 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6256 * Atomically increments @v by 1.
6257 */
6258 #define atomic64_inc(v) atomic64_add(1, (v))
6259 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6260
6261 /*
6262 * atomic64_dec - decrement and test
6263 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6264 * Atomically decrements @v by 1.
6265 */
6266 #define atomic64_dec(v) atomic64_sub(1, (v))
6267 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6268
6269 /*
6270 * atomic64_add_negative - add and test if negative
6271 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6272 index b4db69f..8f3b093 100644
6273 --- a/arch/mips/include/asm/cache.h
6274 +++ b/arch/mips/include/asm/cache.h
6275 @@ -9,10 +9,11 @@
6276 #ifndef _ASM_CACHE_H
6277 #define _ASM_CACHE_H
6278
6279 +#include <linux/const.h>
6280 #include <kmalloc.h>
6281
6282 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6283 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6284 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6285
6286 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6287 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6288 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6289 index cf3ae24..238d22f 100644
6290 --- a/arch/mips/include/asm/elf.h
6291 +++ b/arch/mips/include/asm/elf.h
6292 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6293 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6294 #endif
6295
6296 +#ifdef CONFIG_PAX_ASLR
6297 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6298 +
6299 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6300 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6301 +#endif
6302 +
6303 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6304 struct linux_binprm;
6305 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6306 int uses_interp);
6307
6308 -struct mm_struct;
6309 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6310 -#define arch_randomize_brk arch_randomize_brk
6311 -
6312 #endif /* _ASM_ELF_H */
6313 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6314 index c1f6afa..38cc6e9 100644
6315 --- a/arch/mips/include/asm/exec.h
6316 +++ b/arch/mips/include/asm/exec.h
6317 @@ -12,6 +12,6 @@
6318 #ifndef _ASM_EXEC_H
6319 #define _ASM_EXEC_H
6320
6321 -extern unsigned long arch_align_stack(unsigned long sp);
6322 +#define arch_align_stack(x) ((x) & ~0xfUL)
6323
6324 #endif /* _ASM_EXEC_H */
6325 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6326 index d44622c..64990d2 100644
6327 --- a/arch/mips/include/asm/local.h
6328 +++ b/arch/mips/include/asm/local.h
6329 @@ -12,15 +12,25 @@ typedef struct
6330 atomic_long_t a;
6331 } local_t;
6332
6333 +typedef struct {
6334 + atomic_long_unchecked_t a;
6335 +} local_unchecked_t;
6336 +
6337 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6338
6339 #define local_read(l) atomic_long_read(&(l)->a)
6340 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6341 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6342 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6343
6344 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6345 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6346 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6347 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6348 #define local_inc(l) atomic_long_inc(&(l)->a)
6349 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6350 #define local_dec(l) atomic_long_dec(&(l)->a)
6351 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6352
6353 /*
6354 * Same as above, but return the result value
6355 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6356 return result;
6357 }
6358
6359 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6360 +{
6361 + unsigned long result;
6362 +
6363 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6364 + unsigned long temp;
6365 +
6366 + __asm__ __volatile__(
6367 + " .set mips3 \n"
6368 + "1:" __LL "%1, %2 # local_add_return \n"
6369 + " addu %0, %1, %3 \n"
6370 + __SC "%0, %2 \n"
6371 + " beqzl %0, 1b \n"
6372 + " addu %0, %1, %3 \n"
6373 + " .set mips0 \n"
6374 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6375 + : "Ir" (i), "m" (l->a.counter)
6376 + : "memory");
6377 + } else if (kernel_uses_llsc) {
6378 + unsigned long temp;
6379 +
6380 + __asm__ __volatile__(
6381 + " .set mips3 \n"
6382 + "1:" __LL "%1, %2 # local_add_return \n"
6383 + " addu %0, %1, %3 \n"
6384 + __SC "%0, %2 \n"
6385 + " beqz %0, 1b \n"
6386 + " addu %0, %1, %3 \n"
6387 + " .set mips0 \n"
6388 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6389 + : "Ir" (i), "m" (l->a.counter)
6390 + : "memory");
6391 + } else {
6392 + unsigned long flags;
6393 +
6394 + local_irq_save(flags);
6395 + result = l->a.counter;
6396 + result += i;
6397 + l->a.counter = result;
6398 + local_irq_restore(flags);
6399 + }
6400 +
6401 + return result;
6402 +}
6403 +
6404 static __inline__ long local_sub_return(long i, local_t * l)
6405 {
6406 unsigned long result;
6407 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6408
6409 #define local_cmpxchg(l, o, n) \
6410 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6411 +#define local_cmpxchg_unchecked(l, o, n) \
6412 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6413 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6414
6415 /**
6416 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6417 index f6be474..12ad554 100644
6418 --- a/arch/mips/include/asm/page.h
6419 +++ b/arch/mips/include/asm/page.h
6420 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6421 #ifdef CONFIG_CPU_MIPS32
6422 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6423 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6424 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6425 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6426 #else
6427 typedef struct { unsigned long long pte; } pte_t;
6428 #define pte_val(x) ((x).pte)
6429 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6430 index 881d18b..cea38bc 100644
6431 --- a/arch/mips/include/asm/pgalloc.h
6432 +++ b/arch/mips/include/asm/pgalloc.h
6433 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6434 {
6435 set_pud(pud, __pud((unsigned long)pmd));
6436 }
6437 +
6438 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6439 +{
6440 + pud_populate(mm, pud, pmd);
6441 +}
6442 #endif
6443
6444 /*
6445 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6446 index 25da651..ae2a259 100644
6447 --- a/arch/mips/include/asm/smtc_proc.h
6448 +++ b/arch/mips/include/asm/smtc_proc.h
6449 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6450
6451 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6452
6453 -extern atomic_t smtc_fpu_recoveries;
6454 +extern atomic_unchecked_t smtc_fpu_recoveries;
6455
6456 #endif /* __ASM_SMTC_PROC_H */
6457 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6458 index 61215a3..213ee0e 100644
6459 --- a/arch/mips/include/asm/thread_info.h
6460 +++ b/arch/mips/include/asm/thread_info.h
6461 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6462 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6463 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6464 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6465 +/* li takes a 32bit immediate */
6466 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6467 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6468
6469 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6470 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6471 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6472 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6473 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6474 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6475
6476 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6477 - _TIF_SYSCALL_AUDIT)
6478 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6479
6480 /* work to do in syscall_trace_leave() */
6481 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6482 - _TIF_SYSCALL_AUDIT)
6483 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6484
6485 /* work to do on interrupt/exception return */
6486 #define _TIF_WORK_MASK \
6487 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6488 /* work to do on any return to u-space */
6489 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6490 - _TIF_WORK_SYSCALL_EXIT)
6491 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6492
6493 #endif /* __KERNEL__ */
6494
6495 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6496 index 1188e00..41cf144 100644
6497 --- a/arch/mips/kernel/binfmt_elfn32.c
6498 +++ b/arch/mips/kernel/binfmt_elfn32.c
6499 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6500 #undef ELF_ET_DYN_BASE
6501 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6502
6503 +#ifdef CONFIG_PAX_ASLR
6504 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6505 +
6506 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6507 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6508 +#endif
6509 +
6510 #include <asm/processor.h>
6511 #include <linux/module.h>
6512 #include <linux/elfcore.h>
6513 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6514 index 202e581..689ca79 100644
6515 --- a/arch/mips/kernel/binfmt_elfo32.c
6516 +++ b/arch/mips/kernel/binfmt_elfo32.c
6517 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6518 #undef ELF_ET_DYN_BASE
6519 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6520
6521 +#ifdef CONFIG_PAX_ASLR
6522 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6523 +
6524 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6525 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6526 +#endif
6527 +
6528 #include <asm/processor.h>
6529
6530 /*
6531 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6532 index d1fea7a..45602ea 100644
6533 --- a/arch/mips/kernel/irq.c
6534 +++ b/arch/mips/kernel/irq.c
6535 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6536 printk("unexpected IRQ # %d\n", irq);
6537 }
6538
6539 -atomic_t irq_err_count;
6540 +atomic_unchecked_t irq_err_count;
6541
6542 int arch_show_interrupts(struct seq_file *p, int prec)
6543 {
6544 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6545 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6546 return 0;
6547 }
6548
6549 asmlinkage void spurious_interrupt(void)
6550 {
6551 - atomic_inc(&irq_err_count);
6552 + atomic_inc_unchecked(&irq_err_count);
6553 }
6554
6555 void __init init_IRQ(void)
6556 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6557 index ddc7610..8c58f17 100644
6558 --- a/arch/mips/kernel/process.c
6559 +++ b/arch/mips/kernel/process.c
6560 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6561 out:
6562 return pc;
6563 }
6564 -
6565 -/*
6566 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6567 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6568 - */
6569 -unsigned long arch_align_stack(unsigned long sp)
6570 -{
6571 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6572 - sp -= get_random_int() & ~PAGE_MASK;
6573 -
6574 - return sp & ALMASK;
6575 -}
6576 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6577 index 8ae1ebe..1bcbf47 100644
6578 --- a/arch/mips/kernel/ptrace.c
6579 +++ b/arch/mips/kernel/ptrace.c
6580 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6581 return arch;
6582 }
6583
6584 +#ifdef CONFIG_GRKERNSEC_SETXID
6585 +extern void gr_delayed_cred_worker(void);
6586 +#endif
6587 +
6588 /*
6589 * Notification of system call entry/exit
6590 * - triggered by current->work.syscall_trace
6591 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6592 /* do the secure computing check first */
6593 secure_computing_strict(regs->regs[2]);
6594
6595 +#ifdef CONFIG_GRKERNSEC_SETXID
6596 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6597 + gr_delayed_cred_worker();
6598 +#endif
6599 +
6600 if (!(current->ptrace & PT_PTRACED))
6601 goto out;
6602
6603 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6604 index c10aa84..9ec2e60 100644
6605 --- a/arch/mips/kernel/smtc-proc.c
6606 +++ b/arch/mips/kernel/smtc-proc.c
6607 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6608
6609 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6610
6611 -atomic_t smtc_fpu_recoveries;
6612 +atomic_unchecked_t smtc_fpu_recoveries;
6613
6614 static int smtc_proc_show(struct seq_file *m, void *v)
6615 {
6616 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6617 for(i = 0; i < NR_CPUS; i++)
6618 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6619 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6620 - atomic_read(&smtc_fpu_recoveries));
6621 + atomic_read_unchecked(&smtc_fpu_recoveries));
6622 return 0;
6623 }
6624
6625 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6626 smtc_cpu_stats[i].selfipis = 0;
6627 }
6628
6629 - atomic_set(&smtc_fpu_recoveries, 0);
6630 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6631
6632 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6633 }
6634 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6635 index dfc1b91..11a2c07 100644
6636 --- a/arch/mips/kernel/smtc.c
6637 +++ b/arch/mips/kernel/smtc.c
6638 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6639 }
6640 smtc_ipi_qdump();
6641 printk("%d Recoveries of \"stolen\" FPU\n",
6642 - atomic_read(&smtc_fpu_recoveries));
6643 + atomic_read_unchecked(&smtc_fpu_recoveries));
6644 }
6645
6646
6647 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6648 index 84536bf..79caa4d 100644
6649 --- a/arch/mips/kernel/sync-r4k.c
6650 +++ b/arch/mips/kernel/sync-r4k.c
6651 @@ -21,8 +21,8 @@
6652 #include <asm/mipsregs.h>
6653
6654 static atomic_t count_start_flag = ATOMIC_INIT(0);
6655 -static atomic_t count_count_start = ATOMIC_INIT(0);
6656 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6657 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6658 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6659 static atomic_t count_reference = ATOMIC_INIT(0);
6660
6661 #define COUNTON 100
6662 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6663
6664 for (i = 0; i < NR_LOOPS; i++) {
6665 /* slaves loop on '!= 2' */
6666 - while (atomic_read(&count_count_start) != 1)
6667 + while (atomic_read_unchecked(&count_count_start) != 1)
6668 mb();
6669 - atomic_set(&count_count_stop, 0);
6670 + atomic_set_unchecked(&count_count_stop, 0);
6671 smp_wmb();
6672
6673 /* this lets the slaves write their count register */
6674 - atomic_inc(&count_count_start);
6675 + atomic_inc_unchecked(&count_count_start);
6676
6677 /*
6678 * Everyone initialises count in the last loop:
6679 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6680 /*
6681 * Wait for all slaves to leave the synchronization point:
6682 */
6683 - while (atomic_read(&count_count_stop) != 1)
6684 + while (atomic_read_unchecked(&count_count_stop) != 1)
6685 mb();
6686 - atomic_set(&count_count_start, 0);
6687 + atomic_set_unchecked(&count_count_start, 0);
6688 smp_wmb();
6689 - atomic_inc(&count_count_stop);
6690 + atomic_inc_unchecked(&count_count_stop);
6691 }
6692 /* Arrange for an interrupt in a short while */
6693 write_c0_compare(read_c0_count() + COUNTON);
6694 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6695 initcount = atomic_read(&count_reference);
6696
6697 for (i = 0; i < NR_LOOPS; i++) {
6698 - atomic_inc(&count_count_start);
6699 - while (atomic_read(&count_count_start) != 2)
6700 + atomic_inc_unchecked(&count_count_start);
6701 + while (atomic_read_unchecked(&count_count_start) != 2)
6702 mb();
6703
6704 /*
6705 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6706 if (i == NR_LOOPS-1)
6707 write_c0_count(initcount);
6708
6709 - atomic_inc(&count_count_stop);
6710 - while (atomic_read(&count_count_stop) != 2)
6711 + atomic_inc_unchecked(&count_count_stop);
6712 + while (atomic_read_unchecked(&count_count_stop) != 2)
6713 mb();
6714 }
6715 /* Arrange for an interrupt in a short while */
6716 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6717 index aec3408..74d79d3 100644
6718 --- a/arch/mips/kernel/traps.c
6719 +++ b/arch/mips/kernel/traps.c
6720 @@ -683,7 +683,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6721 siginfo_t info;
6722
6723 prev_state = exception_enter();
6724 - die_if_kernel("Integer overflow", regs);
6725 + if (unlikely(!user_mode(regs))) {
6726 +
6727 +#ifdef CONFIG_PAX_REFCOUNT
6728 + if (fixup_exception(regs)) {
6729 + pax_report_refcount_overflow(regs);
6730 + exception_exit(prev_state);
6731 + return;
6732 + }
6733 +#endif
6734 +
6735 + die("Integer overflow", regs);
6736 + }
6737
6738 info.si_code = FPE_INTOVF;
6739 info.si_signo = SIGFPE;
6740 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6741 index 85df1cd..4f0a4de 100644
6742 --- a/arch/mips/mm/fault.c
6743 +++ b/arch/mips/mm/fault.c
6744 @@ -28,6 +28,23 @@
6745 #include <asm/highmem.h> /* For VMALLOC_END */
6746 #include <linux/kdebug.h>
6747
6748 +#ifdef CONFIG_PAX_PAGEEXEC
6749 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6750 +{
6751 + unsigned long i;
6752 +
6753 + printk(KERN_ERR "PAX: bytes at PC: ");
6754 + for (i = 0; i < 5; i++) {
6755 + unsigned int c;
6756 + if (get_user(c, (unsigned int *)pc+i))
6757 + printk(KERN_CONT "???????? ");
6758 + else
6759 + printk(KERN_CONT "%08x ", c);
6760 + }
6761 + printk("\n");
6762 +}
6763 +#endif
6764 +
6765 /*
6766 * This routine handles page faults. It determines the address,
6767 * and the problem, and then passes it off to one of the appropriate
6768 @@ -197,6 +214,14 @@ bad_area:
6769 bad_area_nosemaphore:
6770 /* User mode accesses just cause a SIGSEGV */
6771 if (user_mode(regs)) {
6772 +
6773 +#ifdef CONFIG_PAX_PAGEEXEC
6774 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6775 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6776 + do_group_exit(SIGKILL);
6777 + }
6778 +#endif
6779 +
6780 tsk->thread.cp0_badvaddr = address;
6781 tsk->thread.error_code = write;
6782 #if 0
6783 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6784 index f1baadd..8537544 100644
6785 --- a/arch/mips/mm/mmap.c
6786 +++ b/arch/mips/mm/mmap.c
6787 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6788 struct vm_area_struct *vma;
6789 unsigned long addr = addr0;
6790 int do_color_align;
6791 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6792 struct vm_unmapped_area_info info;
6793
6794 if (unlikely(len > TASK_SIZE))
6795 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6796 do_color_align = 1;
6797
6798 /* requesting a specific address */
6799 +
6800 +#ifdef CONFIG_PAX_RANDMMAP
6801 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6802 +#endif
6803 +
6804 if (addr) {
6805 if (do_color_align)
6806 addr = COLOUR_ALIGN(addr, pgoff);
6807 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6808 addr = PAGE_ALIGN(addr);
6809
6810 vma = find_vma(mm, addr);
6811 - if (TASK_SIZE - len >= addr &&
6812 - (!vma || addr + len <= vma->vm_start))
6813 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6814 return addr;
6815 }
6816
6817 info.length = len;
6818 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6819 info.align_offset = pgoff << PAGE_SHIFT;
6820 + info.threadstack_offset = offset;
6821
6822 if (dir == DOWN) {
6823 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6824 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6825 {
6826 unsigned long random_factor = 0UL;
6827
6828 +#ifdef CONFIG_PAX_RANDMMAP
6829 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6830 +#endif
6831 +
6832 if (current->flags & PF_RANDOMIZE) {
6833 random_factor = get_random_int();
6834 random_factor = random_factor << PAGE_SHIFT;
6835 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6836
6837 if (mmap_is_legacy()) {
6838 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6839 +
6840 +#ifdef CONFIG_PAX_RANDMMAP
6841 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6842 + mm->mmap_base += mm->delta_mmap;
6843 +#endif
6844 +
6845 mm->get_unmapped_area = arch_get_unmapped_area;
6846 } else {
6847 mm->mmap_base = mmap_base(random_factor);
6848 +
6849 +#ifdef CONFIG_PAX_RANDMMAP
6850 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6851 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6852 +#endif
6853 +
6854 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6855 }
6856 }
6857
6858 -static inline unsigned long brk_rnd(void)
6859 -{
6860 - unsigned long rnd = get_random_int();
6861 -
6862 - rnd = rnd << PAGE_SHIFT;
6863 - /* 8MB for 32bit, 256MB for 64bit */
6864 - if (TASK_IS_32BIT_ADDR)
6865 - rnd = rnd & 0x7ffffful;
6866 - else
6867 - rnd = rnd & 0xffffffful;
6868 -
6869 - return rnd;
6870 -}
6871 -
6872 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6873 -{
6874 - unsigned long base = mm->brk;
6875 - unsigned long ret;
6876 -
6877 - ret = PAGE_ALIGN(base + brk_rnd());
6878 -
6879 - if (ret < mm->brk)
6880 - return mm->brk;
6881 -
6882 - return ret;
6883 -}
6884 -
6885 int __virt_addr_valid(const volatile void *kaddr)
6886 {
6887 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6888 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6889 index a2358b4..7cead4f 100644
6890 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6891 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6892 @@ -187,9 +187,9 @@ void
6893 cont_nmi_dump(void)
6894 {
6895 #ifndef REAL_NMI_SIGNAL
6896 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6897 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6898
6899 - atomic_inc(&nmied_cpus);
6900 + atomic_inc_unchecked(&nmied_cpus);
6901 #endif
6902 /*
6903 * Only allow 1 cpu to proceed
6904 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6905 udelay(10000);
6906 }
6907 #else
6908 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6909 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6910 #endif
6911
6912 /*
6913 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6914 index 967d144..db12197 100644
6915 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6916 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6917 @@ -11,12 +11,14 @@
6918 #ifndef _ASM_PROC_CACHE_H
6919 #define _ASM_PROC_CACHE_H
6920
6921 +#include <linux/const.h>
6922 +
6923 /* L1 cache */
6924
6925 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6926 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6927 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6928 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6929 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6930 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6931
6932 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6933 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6934 index bcb5df2..84fabd2 100644
6935 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6936 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6937 @@ -16,13 +16,15 @@
6938 #ifndef _ASM_PROC_CACHE_H
6939 #define _ASM_PROC_CACHE_H
6940
6941 +#include <linux/const.h>
6942 +
6943 /*
6944 * L1 cache
6945 */
6946 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6947 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6948 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6949 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6950 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6951 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6952
6953 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6954 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6955 index 4ce7a01..449202a 100644
6956 --- a/arch/openrisc/include/asm/cache.h
6957 +++ b/arch/openrisc/include/asm/cache.h
6958 @@ -19,11 +19,13 @@
6959 #ifndef __ASM_OPENRISC_CACHE_H
6960 #define __ASM_OPENRISC_CACHE_H
6961
6962 +#include <linux/const.h>
6963 +
6964 /* FIXME: How can we replace these with values from the CPU...
6965 * they shouldn't be hard-coded!
6966 */
6967
6968 -#define L1_CACHE_BYTES 16
6969 #define L1_CACHE_SHIFT 4
6970 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6971
6972 #endif /* __ASM_OPENRISC_CACHE_H */
6973 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
6974 index 472886c..00e7df9 100644
6975 --- a/arch/parisc/include/asm/atomic.h
6976 +++ b/arch/parisc/include/asm/atomic.h
6977 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
6978 return dec;
6979 }
6980
6981 +#define atomic64_read_unchecked(v) atomic64_read(v)
6982 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6983 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6984 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6985 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6986 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6987 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6988 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6989 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6990 +
6991 #endif /* !CONFIG_64BIT */
6992
6993
6994 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
6995 index 47f11c7..3420df2 100644
6996 --- a/arch/parisc/include/asm/cache.h
6997 +++ b/arch/parisc/include/asm/cache.h
6998 @@ -5,6 +5,7 @@
6999 #ifndef __ARCH_PARISC_CACHE_H
7000 #define __ARCH_PARISC_CACHE_H
7001
7002 +#include <linux/const.h>
7003
7004 /*
7005 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7006 @@ -15,13 +16,13 @@
7007 * just ruin performance.
7008 */
7009 #ifdef CONFIG_PA20
7010 -#define L1_CACHE_BYTES 64
7011 #define L1_CACHE_SHIFT 6
7012 #else
7013 -#define L1_CACHE_BYTES 32
7014 #define L1_CACHE_SHIFT 5
7015 #endif
7016
7017 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7018 +
7019 #ifndef __ASSEMBLY__
7020
7021 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7022 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7023 index ad2b503..bdf1651 100644
7024 --- a/arch/parisc/include/asm/elf.h
7025 +++ b/arch/parisc/include/asm/elf.h
7026 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7027
7028 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7029
7030 +#ifdef CONFIG_PAX_ASLR
7031 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7032 +
7033 +#define PAX_DELTA_MMAP_LEN 16
7034 +#define PAX_DELTA_STACK_LEN 16
7035 +#endif
7036 +
7037 /* This yields a mask that user programs can use to figure out what
7038 instruction set this CPU supports. This could be done in user space,
7039 but it's not easy, and we've already done it here. */
7040 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7041 index fc987a1..6e068ef 100644
7042 --- a/arch/parisc/include/asm/pgalloc.h
7043 +++ b/arch/parisc/include/asm/pgalloc.h
7044 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7045 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7046 }
7047
7048 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7049 +{
7050 + pgd_populate(mm, pgd, pmd);
7051 +}
7052 +
7053 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7054 {
7055 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7056 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7057 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7058 #define pmd_free(mm, x) do { } while (0)
7059 #define pgd_populate(mm, pmd, pte) BUG()
7060 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7061
7062 #endif
7063
7064 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7065 index 34899b5..02dd060 100644
7066 --- a/arch/parisc/include/asm/pgtable.h
7067 +++ b/arch/parisc/include/asm/pgtable.h
7068 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7069 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7070 #define PAGE_COPY PAGE_EXECREAD
7071 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7072 +
7073 +#ifdef CONFIG_PAX_PAGEEXEC
7074 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7075 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7076 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7077 +#else
7078 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7079 +# define PAGE_COPY_NOEXEC PAGE_COPY
7080 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7081 +#endif
7082 +
7083 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7084 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7085 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7086 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7087 index e0a8235..ce2f1e1 100644
7088 --- a/arch/parisc/include/asm/uaccess.h
7089 +++ b/arch/parisc/include/asm/uaccess.h
7090 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7091 const void __user *from,
7092 unsigned long n)
7093 {
7094 - int sz = __compiletime_object_size(to);
7095 + size_t sz = __compiletime_object_size(to);
7096 int ret = -EFAULT;
7097
7098 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7099 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7100 ret = __copy_from_user(to, from, n);
7101 else
7102 copy_from_user_overflow();
7103 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7104 index 2a625fb..9908930 100644
7105 --- a/arch/parisc/kernel/module.c
7106 +++ b/arch/parisc/kernel/module.c
7107 @@ -98,16 +98,38 @@
7108
7109 /* three functions to determine where in the module core
7110 * or init pieces the location is */
7111 +static inline int in_init_rx(struct module *me, void *loc)
7112 +{
7113 + return (loc >= me->module_init_rx &&
7114 + loc < (me->module_init_rx + me->init_size_rx));
7115 +}
7116 +
7117 +static inline int in_init_rw(struct module *me, void *loc)
7118 +{
7119 + return (loc >= me->module_init_rw &&
7120 + loc < (me->module_init_rw + me->init_size_rw));
7121 +}
7122 +
7123 static inline int in_init(struct module *me, void *loc)
7124 {
7125 - return (loc >= me->module_init &&
7126 - loc <= (me->module_init + me->init_size));
7127 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7128 +}
7129 +
7130 +static inline int in_core_rx(struct module *me, void *loc)
7131 +{
7132 + return (loc >= me->module_core_rx &&
7133 + loc < (me->module_core_rx + me->core_size_rx));
7134 +}
7135 +
7136 +static inline int in_core_rw(struct module *me, void *loc)
7137 +{
7138 + return (loc >= me->module_core_rw &&
7139 + loc < (me->module_core_rw + me->core_size_rw));
7140 }
7141
7142 static inline int in_core(struct module *me, void *loc)
7143 {
7144 - return (loc >= me->module_core &&
7145 - loc <= (me->module_core + me->core_size));
7146 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7147 }
7148
7149 static inline int in_local(struct module *me, void *loc)
7150 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7151 }
7152
7153 /* align things a bit */
7154 - me->core_size = ALIGN(me->core_size, 16);
7155 - me->arch.got_offset = me->core_size;
7156 - me->core_size += gots * sizeof(struct got_entry);
7157 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7158 + me->arch.got_offset = me->core_size_rw;
7159 + me->core_size_rw += gots * sizeof(struct got_entry);
7160
7161 - me->core_size = ALIGN(me->core_size, 16);
7162 - me->arch.fdesc_offset = me->core_size;
7163 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7164 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7165 + me->arch.fdesc_offset = me->core_size_rw;
7166 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7167
7168 me->arch.got_max = gots;
7169 me->arch.fdesc_max = fdescs;
7170 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7171
7172 BUG_ON(value == 0);
7173
7174 - got = me->module_core + me->arch.got_offset;
7175 + got = me->module_core_rw + me->arch.got_offset;
7176 for (i = 0; got[i].addr; i++)
7177 if (got[i].addr == value)
7178 goto out;
7179 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7180 #ifdef CONFIG_64BIT
7181 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7182 {
7183 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7184 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7185
7186 if (!value) {
7187 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7188 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7189
7190 /* Create new one */
7191 fdesc->addr = value;
7192 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7193 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7194 return (Elf_Addr)fdesc;
7195 }
7196 #endif /* CONFIG_64BIT */
7197 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7198
7199 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7200 end = table + sechdrs[me->arch.unwind_section].sh_size;
7201 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7202 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7203
7204 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7205 me->arch.unwind_section, table, end, gp);
7206 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7207 index 5dfd248..64914ac 100644
7208 --- a/arch/parisc/kernel/sys_parisc.c
7209 +++ b/arch/parisc/kernel/sys_parisc.c
7210 @@ -33,9 +33,11 @@
7211 #include <linux/utsname.h>
7212 #include <linux/personality.h>
7213
7214 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7215 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7216 + unsigned long flags)
7217 {
7218 struct vm_unmapped_area_info info;
7219 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7220
7221 info.flags = 0;
7222 info.length = len;
7223 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7224 info.high_limit = TASK_SIZE;
7225 info.align_mask = 0;
7226 info.align_offset = 0;
7227 + info.threadstack_offset = offset;
7228 return vm_unmapped_area(&info);
7229 }
7230
7231 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
7232 return (unsigned long) mapping >> 8;
7233 }
7234
7235 -static unsigned long get_shared_area(struct address_space *mapping,
7236 - unsigned long addr, unsigned long len, unsigned long pgoff)
7237 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
7238 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
7239 {
7240 struct vm_unmapped_area_info info;
7241 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7242
7243 info.flags = 0;
7244 info.length = len;
7245 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
7246 info.high_limit = TASK_SIZE;
7247 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7248 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
7249 + info.threadstack_offset = offset;
7250 return vm_unmapped_area(&info);
7251 }
7252
7253 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7254 return -EINVAL;
7255 return addr;
7256 }
7257 - if (!addr)
7258 + if (!addr) {
7259 addr = TASK_UNMAPPED_BASE;
7260
7261 +#ifdef CONFIG_PAX_RANDMMAP
7262 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7263 + addr += current->mm->delta_mmap;
7264 +#endif
7265 +
7266 + }
7267 +
7268 if (filp) {
7269 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
7270 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
7271 } else if(flags & MAP_SHARED) {
7272 - addr = get_shared_area(NULL, addr, len, pgoff);
7273 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
7274 } else {
7275 - addr = get_unshared_area(addr, len);
7276 + addr = get_unshared_area(filp, addr, len, flags);
7277 }
7278 return addr;
7279 }
7280 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7281 index b3f87a3..5d5d03d 100644
7282 --- a/arch/parisc/kernel/traps.c
7283 +++ b/arch/parisc/kernel/traps.c
7284 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7285
7286 down_read(&current->mm->mmap_sem);
7287 vma = find_vma(current->mm,regs->iaoq[0]);
7288 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7289 - && (vma->vm_flags & VM_EXEC)) {
7290 -
7291 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7292 fault_address = regs->iaoq[0];
7293 fault_space = regs->iasq[0];
7294
7295 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7296 index f247a34..dc0f219 100644
7297 --- a/arch/parisc/mm/fault.c
7298 +++ b/arch/parisc/mm/fault.c
7299 @@ -15,6 +15,7 @@
7300 #include <linux/sched.h>
7301 #include <linux/interrupt.h>
7302 #include <linux/module.h>
7303 +#include <linux/unistd.h>
7304
7305 #include <asm/uaccess.h>
7306 #include <asm/traps.h>
7307 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7308 static unsigned long
7309 parisc_acctyp(unsigned long code, unsigned int inst)
7310 {
7311 - if (code == 6 || code == 16)
7312 + if (code == 6 || code == 7 || code == 16)
7313 return VM_EXEC;
7314
7315 switch (inst & 0xf0000000) {
7316 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7317 }
7318 #endif
7319
7320 +#ifdef CONFIG_PAX_PAGEEXEC
7321 +/*
7322 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7323 + *
7324 + * returns 1 when task should be killed
7325 + * 2 when rt_sigreturn trampoline was detected
7326 + * 3 when unpatched PLT trampoline was detected
7327 + */
7328 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7329 +{
7330 +
7331 +#ifdef CONFIG_PAX_EMUPLT
7332 + int err;
7333 +
7334 + do { /* PaX: unpatched PLT emulation */
7335 + unsigned int bl, depwi;
7336 +
7337 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7338 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7339 +
7340 + if (err)
7341 + break;
7342 +
7343 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7344 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7345 +
7346 + err = get_user(ldw, (unsigned int *)addr);
7347 + err |= get_user(bv, (unsigned int *)(addr+4));
7348 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7349 +
7350 + if (err)
7351 + break;
7352 +
7353 + if (ldw == 0x0E801096U &&
7354 + bv == 0xEAC0C000U &&
7355 + ldw2 == 0x0E881095U)
7356 + {
7357 + unsigned int resolver, map;
7358 +
7359 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7360 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7361 + if (err)
7362 + break;
7363 +
7364 + regs->gr[20] = instruction_pointer(regs)+8;
7365 + regs->gr[21] = map;
7366 + regs->gr[22] = resolver;
7367 + regs->iaoq[0] = resolver | 3UL;
7368 + regs->iaoq[1] = regs->iaoq[0] + 4;
7369 + return 3;
7370 + }
7371 + }
7372 + } while (0);
7373 +#endif
7374 +
7375 +#ifdef CONFIG_PAX_EMUTRAMP
7376 +
7377 +#ifndef CONFIG_PAX_EMUSIGRT
7378 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7379 + return 1;
7380 +#endif
7381 +
7382 + do { /* PaX: rt_sigreturn emulation */
7383 + unsigned int ldi1, ldi2, bel, nop;
7384 +
7385 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7386 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7387 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7388 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7389 +
7390 + if (err)
7391 + break;
7392 +
7393 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7394 + ldi2 == 0x3414015AU &&
7395 + bel == 0xE4008200U &&
7396 + nop == 0x08000240U)
7397 + {
7398 + regs->gr[25] = (ldi1 & 2) >> 1;
7399 + regs->gr[20] = __NR_rt_sigreturn;
7400 + regs->gr[31] = regs->iaoq[1] + 16;
7401 + regs->sr[0] = regs->iasq[1];
7402 + regs->iaoq[0] = 0x100UL;
7403 + regs->iaoq[1] = regs->iaoq[0] + 4;
7404 + regs->iasq[0] = regs->sr[2];
7405 + regs->iasq[1] = regs->sr[2];
7406 + return 2;
7407 + }
7408 + } while (0);
7409 +#endif
7410 +
7411 + return 1;
7412 +}
7413 +
7414 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7415 +{
7416 + unsigned long i;
7417 +
7418 + printk(KERN_ERR "PAX: bytes at PC: ");
7419 + for (i = 0; i < 5; i++) {
7420 + unsigned int c;
7421 + if (get_user(c, (unsigned int *)pc+i))
7422 + printk(KERN_CONT "???????? ");
7423 + else
7424 + printk(KERN_CONT "%08x ", c);
7425 + }
7426 + printk("\n");
7427 +}
7428 +#endif
7429 +
7430 int fixup_exception(struct pt_regs *regs)
7431 {
7432 const struct exception_table_entry *fix;
7433 @@ -194,8 +305,33 @@ good_area:
7434
7435 acc_type = parisc_acctyp(code,regs->iir);
7436
7437 - if ((vma->vm_flags & acc_type) != acc_type)
7438 + if ((vma->vm_flags & acc_type) != acc_type) {
7439 +
7440 +#ifdef CONFIG_PAX_PAGEEXEC
7441 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7442 + (address & ~3UL) == instruction_pointer(regs))
7443 + {
7444 + up_read(&mm->mmap_sem);
7445 + switch (pax_handle_fetch_fault(regs)) {
7446 +
7447 +#ifdef CONFIG_PAX_EMUPLT
7448 + case 3:
7449 + return;
7450 +#endif
7451 +
7452 +#ifdef CONFIG_PAX_EMUTRAMP
7453 + case 2:
7454 + return;
7455 +#endif
7456 +
7457 + }
7458 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7459 + do_group_exit(SIGKILL);
7460 + }
7461 +#endif
7462 +
7463 goto bad_area;
7464 + }
7465
7466 /*
7467 * If for any reason at all we couldn't handle the fault, make
7468 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7469 index e3b1d41..8e81edf 100644
7470 --- a/arch/powerpc/include/asm/atomic.h
7471 +++ b/arch/powerpc/include/asm/atomic.h
7472 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7473 return t1;
7474 }
7475
7476 +#define atomic64_read_unchecked(v) atomic64_read(v)
7477 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7478 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7479 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7480 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7481 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7482 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7483 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7484 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7485 +
7486 #endif /* __powerpc64__ */
7487
7488 #endif /* __KERNEL__ */
7489 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7490 index 9e495c9..b6878e5 100644
7491 --- a/arch/powerpc/include/asm/cache.h
7492 +++ b/arch/powerpc/include/asm/cache.h
7493 @@ -3,6 +3,7 @@
7494
7495 #ifdef __KERNEL__
7496
7497 +#include <linux/const.h>
7498
7499 /* bytes per L1 cache line */
7500 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7501 @@ -22,7 +23,7 @@
7502 #define L1_CACHE_SHIFT 7
7503 #endif
7504
7505 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7506 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7507
7508 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7509
7510 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7511 index cc0655a..13eac2e 100644
7512 --- a/arch/powerpc/include/asm/elf.h
7513 +++ b/arch/powerpc/include/asm/elf.h
7514 @@ -28,8 +28,19 @@
7515 the loader. We need to make sure that it is out of the way of the program
7516 that it will "exec", and that there is sufficient room for the brk. */
7517
7518 -extern unsigned long randomize_et_dyn(unsigned long base);
7519 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7520 +#define ELF_ET_DYN_BASE (0x20000000)
7521 +
7522 +#ifdef CONFIG_PAX_ASLR
7523 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7524 +
7525 +#ifdef __powerpc64__
7526 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7527 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7528 +#else
7529 +#define PAX_DELTA_MMAP_LEN 15
7530 +#define PAX_DELTA_STACK_LEN 15
7531 +#endif
7532 +#endif
7533
7534 /*
7535 * Our registers are always unsigned longs, whether we're a 32 bit
7536 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7537 (0x7ff >> (PAGE_SHIFT - 12)) : \
7538 (0x3ffff >> (PAGE_SHIFT - 12)))
7539
7540 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7541 -#define arch_randomize_brk arch_randomize_brk
7542 -
7543 -
7544 #ifdef CONFIG_SPU_BASE
7545 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7546 #define NT_SPU 1
7547 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7548 index 8196e9c..d83a9f3 100644
7549 --- a/arch/powerpc/include/asm/exec.h
7550 +++ b/arch/powerpc/include/asm/exec.h
7551 @@ -4,6 +4,6 @@
7552 #ifndef _ASM_POWERPC_EXEC_H
7553 #define _ASM_POWERPC_EXEC_H
7554
7555 -extern unsigned long arch_align_stack(unsigned long sp);
7556 +#define arch_align_stack(x) ((x) & ~0xfUL)
7557
7558 #endif /* _ASM_POWERPC_EXEC_H */
7559 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7560 index 5acabbd..7ea14fa 100644
7561 --- a/arch/powerpc/include/asm/kmap_types.h
7562 +++ b/arch/powerpc/include/asm/kmap_types.h
7563 @@ -10,7 +10,7 @@
7564 * 2 of the License, or (at your option) any later version.
7565 */
7566
7567 -#define KM_TYPE_NR 16
7568 +#define KM_TYPE_NR 17
7569
7570 #endif /* __KERNEL__ */
7571 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7572 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7573 index 8565c25..2865190 100644
7574 --- a/arch/powerpc/include/asm/mman.h
7575 +++ b/arch/powerpc/include/asm/mman.h
7576 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7577 }
7578 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7579
7580 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7581 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7582 {
7583 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7584 }
7585 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7586 index b9f4262..dcf04f7 100644
7587 --- a/arch/powerpc/include/asm/page.h
7588 +++ b/arch/powerpc/include/asm/page.h
7589 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7590 * and needs to be executable. This means the whole heap ends
7591 * up being executable.
7592 */
7593 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7594 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7595 +#define VM_DATA_DEFAULT_FLAGS32 \
7596 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7597 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7598
7599 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7600 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7601 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7602 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7603 #endif
7604
7605 +#define ktla_ktva(addr) (addr)
7606 +#define ktva_ktla(addr) (addr)
7607 +
7608 #ifndef CONFIG_PPC_BOOK3S_64
7609 /*
7610 * Use the top bit of the higher-level page table entries to indicate whether
7611 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7612 index 88693ce..ac6f9ab 100644
7613 --- a/arch/powerpc/include/asm/page_64.h
7614 +++ b/arch/powerpc/include/asm/page_64.h
7615 @@ -153,15 +153,18 @@ do { \
7616 * stack by default, so in the absence of a PT_GNU_STACK program header
7617 * we turn execute permission off.
7618 */
7619 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7620 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7621 +#define VM_STACK_DEFAULT_FLAGS32 \
7622 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7623 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7624
7625 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7626 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7627
7628 +#ifndef CONFIG_PAX_PAGEEXEC
7629 #define VM_STACK_DEFAULT_FLAGS \
7630 (is_32bit_task() ? \
7631 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7632 +#endif
7633
7634 #include <asm-generic/getorder.h>
7635
7636 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7637 index f65e27b..23ffb5b 100644
7638 --- a/arch/powerpc/include/asm/pgalloc-64.h
7639 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7640 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7641 #ifndef CONFIG_PPC_64K_PAGES
7642
7643 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7644 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7645
7646 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7647 {
7648 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7649 pud_set(pud, (unsigned long)pmd);
7650 }
7651
7652 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7653 +{
7654 + pud_populate(mm, pud, pmd);
7655 +}
7656 +
7657 #define pmd_populate(mm, pmd, pte_page) \
7658 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7659 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7660 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
7661 #endif
7662
7663 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7664 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7665
7666 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7667 pte_t *pte)
7668 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7669 index 7d6eacf..14c0240 100644
7670 --- a/arch/powerpc/include/asm/pgtable.h
7671 +++ b/arch/powerpc/include/asm/pgtable.h
7672 @@ -2,6 +2,7 @@
7673 #define _ASM_POWERPC_PGTABLE_H
7674 #ifdef __KERNEL__
7675
7676 +#include <linux/const.h>
7677 #ifndef __ASSEMBLY__
7678 #include <asm/processor.h> /* For TASK_SIZE */
7679 #include <asm/mmu.h>
7680 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7681 index 4aad413..85d86bf 100644
7682 --- a/arch/powerpc/include/asm/pte-hash32.h
7683 +++ b/arch/powerpc/include/asm/pte-hash32.h
7684 @@ -21,6 +21,7 @@
7685 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7686 #define _PAGE_USER 0x004 /* usermode access allowed */
7687 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7688 +#define _PAGE_EXEC _PAGE_GUARDED
7689 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7690 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7691 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7692 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7693 index 99222e2..f629aef 100644
7694 --- a/arch/powerpc/include/asm/reg.h
7695 +++ b/arch/powerpc/include/asm/reg.h
7696 @@ -234,6 +234,7 @@
7697 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7698 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7699 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7700 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7701 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7702 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7703 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7704 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7705 index 48cfc85..891382f 100644
7706 --- a/arch/powerpc/include/asm/smp.h
7707 +++ b/arch/powerpc/include/asm/smp.h
7708 @@ -50,7 +50,7 @@ struct smp_ops_t {
7709 int (*cpu_disable)(void);
7710 void (*cpu_die)(unsigned int nr);
7711 int (*cpu_bootable)(unsigned int nr);
7712 -};
7713 +} __no_const;
7714
7715 extern void smp_send_debugger_break(void);
7716 extern void start_secondary_resume(void);
7717 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7718 index ba7b197..d292e26 100644
7719 --- a/arch/powerpc/include/asm/thread_info.h
7720 +++ b/arch/powerpc/include/asm/thread_info.h
7721 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7722 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7723 TIF_NEED_RESCHED */
7724 #define TIF_32BIT 4 /* 32 bit binary */
7725 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7726 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7727 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7728 #define TIF_SINGLESTEP 8 /* singlestepping active */
7729 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7730 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7731 for stack store? */
7732 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7733 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7734 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7735 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7736
7737 /* as above, but as bit values */
7738 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7739 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7740 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7741 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7742 #define _TIF_NOHZ (1<<TIF_NOHZ)
7743 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7744 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7745 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7746 - _TIF_NOHZ)
7747 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7748
7749 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7750 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7751 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7752 index 9485b43..4718d50 100644
7753 --- a/arch/powerpc/include/asm/uaccess.h
7754 +++ b/arch/powerpc/include/asm/uaccess.h
7755 @@ -318,52 +318,6 @@ do { \
7756 extern unsigned long __copy_tofrom_user(void __user *to,
7757 const void __user *from, unsigned long size);
7758
7759 -#ifndef __powerpc64__
7760 -
7761 -static inline unsigned long copy_from_user(void *to,
7762 - const void __user *from, unsigned long n)
7763 -{
7764 - unsigned long over;
7765 -
7766 - if (access_ok(VERIFY_READ, from, n))
7767 - return __copy_tofrom_user((__force void __user *)to, from, n);
7768 - if ((unsigned long)from < TASK_SIZE) {
7769 - over = (unsigned long)from + n - TASK_SIZE;
7770 - return __copy_tofrom_user((__force void __user *)to, from,
7771 - n - over) + over;
7772 - }
7773 - return n;
7774 -}
7775 -
7776 -static inline unsigned long copy_to_user(void __user *to,
7777 - const void *from, unsigned long n)
7778 -{
7779 - unsigned long over;
7780 -
7781 - if (access_ok(VERIFY_WRITE, to, n))
7782 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7783 - if ((unsigned long)to < TASK_SIZE) {
7784 - over = (unsigned long)to + n - TASK_SIZE;
7785 - return __copy_tofrom_user(to, (__force void __user *)from,
7786 - n - over) + over;
7787 - }
7788 - return n;
7789 -}
7790 -
7791 -#else /* __powerpc64__ */
7792 -
7793 -#define __copy_in_user(to, from, size) \
7794 - __copy_tofrom_user((to), (from), (size))
7795 -
7796 -extern unsigned long copy_from_user(void *to, const void __user *from,
7797 - unsigned long n);
7798 -extern unsigned long copy_to_user(void __user *to, const void *from,
7799 - unsigned long n);
7800 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7801 - unsigned long n);
7802 -
7803 -#endif /* __powerpc64__ */
7804 -
7805 static inline unsigned long __copy_from_user_inatomic(void *to,
7806 const void __user *from, unsigned long n)
7807 {
7808 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7809 if (ret == 0)
7810 return 0;
7811 }
7812 +
7813 + if (!__builtin_constant_p(n))
7814 + check_object_size(to, n, false);
7815 +
7816 return __copy_tofrom_user((__force void __user *)to, from, n);
7817 }
7818
7819 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7820 if (ret == 0)
7821 return 0;
7822 }
7823 +
7824 + if (!__builtin_constant_p(n))
7825 + check_object_size(from, n, true);
7826 +
7827 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7828 }
7829
7830 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7831 return __copy_to_user_inatomic(to, from, size);
7832 }
7833
7834 +#ifndef __powerpc64__
7835 +
7836 +static inline unsigned long __must_check copy_from_user(void *to,
7837 + const void __user *from, unsigned long n)
7838 +{
7839 + unsigned long over;
7840 +
7841 + if ((long)n < 0)
7842 + return n;
7843 +
7844 + if (access_ok(VERIFY_READ, from, n)) {
7845 + if (!__builtin_constant_p(n))
7846 + check_object_size(to, n, false);
7847 + return __copy_tofrom_user((__force void __user *)to, from, n);
7848 + }
7849 + if ((unsigned long)from < TASK_SIZE) {
7850 + over = (unsigned long)from + n - TASK_SIZE;
7851 + if (!__builtin_constant_p(n - over))
7852 + check_object_size(to, n - over, false);
7853 + return __copy_tofrom_user((__force void __user *)to, from,
7854 + n - over) + over;
7855 + }
7856 + return n;
7857 +}
7858 +
7859 +static inline unsigned long __must_check copy_to_user(void __user *to,
7860 + const void *from, unsigned long n)
7861 +{
7862 + unsigned long over;
7863 +
7864 + if ((long)n < 0)
7865 + return n;
7866 +
7867 + if (access_ok(VERIFY_WRITE, to, n)) {
7868 + if (!__builtin_constant_p(n))
7869 + check_object_size(from, n, true);
7870 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7871 + }
7872 + if ((unsigned long)to < TASK_SIZE) {
7873 + over = (unsigned long)to + n - TASK_SIZE;
7874 + if (!__builtin_constant_p(n))
7875 + check_object_size(from, n - over, true);
7876 + return __copy_tofrom_user(to, (__force void __user *)from,
7877 + n - over) + over;
7878 + }
7879 + return n;
7880 +}
7881 +
7882 +#else /* __powerpc64__ */
7883 +
7884 +#define __copy_in_user(to, from, size) \
7885 + __copy_tofrom_user((to), (from), (size))
7886 +
7887 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7888 +{
7889 + if ((long)n < 0 || n > INT_MAX)
7890 + return n;
7891 +
7892 + if (!__builtin_constant_p(n))
7893 + check_object_size(to, n, false);
7894 +
7895 + if (likely(access_ok(VERIFY_READ, from, n)))
7896 + n = __copy_from_user(to, from, n);
7897 + else
7898 + memset(to, 0, n);
7899 + return n;
7900 +}
7901 +
7902 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7903 +{
7904 + if ((long)n < 0 || n > INT_MAX)
7905 + return n;
7906 +
7907 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7908 + if (!__builtin_constant_p(n))
7909 + check_object_size(from, n, true);
7910 + n = __copy_to_user(to, from, n);
7911 + }
7912 + return n;
7913 +}
7914 +
7915 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7916 + unsigned long n);
7917 +
7918 +#endif /* __powerpc64__ */
7919 +
7920 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7921
7922 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7923 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7924 index 645170a..6cf0271 100644
7925 --- a/arch/powerpc/kernel/exceptions-64e.S
7926 +++ b/arch/powerpc/kernel/exceptions-64e.S
7927 @@ -757,6 +757,7 @@ storage_fault_common:
7928 std r14,_DAR(r1)
7929 std r15,_DSISR(r1)
7930 addi r3,r1,STACK_FRAME_OVERHEAD
7931 + bl .save_nvgprs
7932 mr r4,r14
7933 mr r5,r15
7934 ld r14,PACA_EXGEN+EX_R14(r13)
7935 @@ -765,8 +766,7 @@ storage_fault_common:
7936 cmpdi r3,0
7937 bne- 1f
7938 b .ret_from_except_lite
7939 -1: bl .save_nvgprs
7940 - mr r5,r3
7941 +1: mr r5,r3
7942 addi r3,r1,STACK_FRAME_OVERHEAD
7943 ld r4,_DAR(r1)
7944 bl .bad_page_fault
7945 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7946 index 902ca3c..e942155 100644
7947 --- a/arch/powerpc/kernel/exceptions-64s.S
7948 +++ b/arch/powerpc/kernel/exceptions-64s.S
7949 @@ -1357,10 +1357,10 @@ handle_page_fault:
7950 11: ld r4,_DAR(r1)
7951 ld r5,_DSISR(r1)
7952 addi r3,r1,STACK_FRAME_OVERHEAD
7953 + bl .save_nvgprs
7954 bl .do_page_fault
7955 cmpdi r3,0
7956 beq+ 12f
7957 - bl .save_nvgprs
7958 mr r5,r3
7959 addi r3,r1,STACK_FRAME_OVERHEAD
7960 lwz r4,_DAR(r1)
7961 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
7962 index 2e3200c..72095ce 100644
7963 --- a/arch/powerpc/kernel/module_32.c
7964 +++ b/arch/powerpc/kernel/module_32.c
7965 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
7966 me->arch.core_plt_section = i;
7967 }
7968 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
7969 - printk("Module doesn't contain .plt or .init.plt sections.\n");
7970 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
7971 return -ENOEXEC;
7972 }
7973
7974 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
7975
7976 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
7977 /* Init, or core PLT? */
7978 - if (location >= mod->module_core
7979 - && location < mod->module_core + mod->core_size)
7980 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
7981 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
7982 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
7983 - else
7984 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
7985 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
7986 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
7987 + else {
7988 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
7989 + return ~0UL;
7990 + }
7991
7992 /* Find this entry, or if that fails, the next avail. entry */
7993 while (entry->jump[0]) {
7994 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
7995 index 8083be2..10aa352 100644
7996 --- a/arch/powerpc/kernel/process.c
7997 +++ b/arch/powerpc/kernel/process.c
7998 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
7999 * Lookup NIP late so we have the best change of getting the
8000 * above info out without failing
8001 */
8002 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8003 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8004 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8005 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8006 #endif
8007 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8008 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8009 @@ -1349,10 +1349,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8010 newsp = stack[0];
8011 ip = stack[STACK_FRAME_LR_SAVE];
8012 if (!firstframe || ip != lr) {
8013 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8014 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8015 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8016 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8017 - printk(" (%pS)",
8018 + printk(" (%pA)",
8019 (void *)current->ret_stack[curr_frame].ret);
8020 curr_frame--;
8021 }
8022 @@ -1372,7 +1372,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8023 struct pt_regs *regs = (struct pt_regs *)
8024 (sp + STACK_FRAME_OVERHEAD);
8025 lr = regs->link;
8026 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8027 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8028 regs->trap, (void *)regs->nip, (void *)lr);
8029 firstframe = 1;
8030 }
8031 @@ -1408,58 +1408,3 @@ void notrace __ppc64_runlatch_off(void)
8032 mtspr(SPRN_CTRLT, ctrl);
8033 }
8034 #endif /* CONFIG_PPC64 */
8035 -
8036 -unsigned long arch_align_stack(unsigned long sp)
8037 -{
8038 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8039 - sp -= get_random_int() & ~PAGE_MASK;
8040 - return sp & ~0xf;
8041 -}
8042 -
8043 -static inline unsigned long brk_rnd(void)
8044 -{
8045 - unsigned long rnd = 0;
8046 -
8047 - /* 8MB for 32bit, 1GB for 64bit */
8048 - if (is_32bit_task())
8049 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8050 - else
8051 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8052 -
8053 - return rnd << PAGE_SHIFT;
8054 -}
8055 -
8056 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8057 -{
8058 - unsigned long base = mm->brk;
8059 - unsigned long ret;
8060 -
8061 -#ifdef CONFIG_PPC_STD_MMU_64
8062 - /*
8063 - * If we are using 1TB segments and we are allowed to randomise
8064 - * the heap, we can put it above 1TB so it is backed by a 1TB
8065 - * segment. Otherwise the heap will be in the bottom 1TB
8066 - * which always uses 256MB segments and this may result in a
8067 - * performance penalty.
8068 - */
8069 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8070 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8071 -#endif
8072 -
8073 - ret = PAGE_ALIGN(base + brk_rnd());
8074 -
8075 - if (ret < mm->brk)
8076 - return mm->brk;
8077 -
8078 - return ret;
8079 -}
8080 -
8081 -unsigned long randomize_et_dyn(unsigned long base)
8082 -{
8083 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8084 -
8085 - if (ret < base)
8086 - return base;
8087 -
8088 - return ret;
8089 -}
8090 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8091 index 9a0d24c..e7fbedf 100644
8092 --- a/arch/powerpc/kernel/ptrace.c
8093 +++ b/arch/powerpc/kernel/ptrace.c
8094 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8095 return ret;
8096 }
8097
8098 +#ifdef CONFIG_GRKERNSEC_SETXID
8099 +extern void gr_delayed_cred_worker(void);
8100 +#endif
8101 +
8102 /*
8103 * We must return the syscall number to actually look up in the table.
8104 * This can be -1L to skip running any syscall at all.
8105 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8106
8107 secure_computing_strict(regs->gpr[0]);
8108
8109 +#ifdef CONFIG_GRKERNSEC_SETXID
8110 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8111 + gr_delayed_cred_worker();
8112 +#endif
8113 +
8114 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8115 tracehook_report_syscall_entry(regs))
8116 /*
8117 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8118 {
8119 int step;
8120
8121 +#ifdef CONFIG_GRKERNSEC_SETXID
8122 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8123 + gr_delayed_cred_worker();
8124 +#endif
8125 +
8126 audit_syscall_exit(regs);
8127
8128 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8129 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8130 index 0f83122..c0aca6a 100644
8131 --- a/arch/powerpc/kernel/signal_32.c
8132 +++ b/arch/powerpc/kernel/signal_32.c
8133 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8134 /* Save user registers on the stack */
8135 frame = &rt_sf->uc.uc_mcontext;
8136 addr = frame;
8137 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8138 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8139 sigret = 0;
8140 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8141 } else {
8142 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8143 index 887e99d..310bc11 100644
8144 --- a/arch/powerpc/kernel/signal_64.c
8145 +++ b/arch/powerpc/kernel/signal_64.c
8146 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8147 #endif
8148
8149 /* Set up to return from userspace. */
8150 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8151 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8152 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8153 } else {
8154 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8155 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8156 index e435bc0..41c2964 100644
8157 --- a/arch/powerpc/kernel/traps.c
8158 +++ b/arch/powerpc/kernel/traps.c
8159 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8160 return flags;
8161 }
8162
8163 +extern void gr_handle_kernel_exploit(void);
8164 +
8165 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8166 int signr)
8167 {
8168 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8169 panic("Fatal exception in interrupt");
8170 if (panic_on_oops)
8171 panic("Fatal exception");
8172 +
8173 + gr_handle_kernel_exploit();
8174 +
8175 do_exit(signr);
8176 }
8177
8178 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8179 index 1d9c926..25f4741 100644
8180 --- a/arch/powerpc/kernel/vdso.c
8181 +++ b/arch/powerpc/kernel/vdso.c
8182 @@ -34,6 +34,7 @@
8183 #include <asm/firmware.h>
8184 #include <asm/vdso.h>
8185 #include <asm/vdso_datapage.h>
8186 +#include <asm/mman.h>
8187
8188 #include "setup.h"
8189
8190 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8191 vdso_base = VDSO32_MBASE;
8192 #endif
8193
8194 - current->mm->context.vdso_base = 0;
8195 + current->mm->context.vdso_base = ~0UL;
8196
8197 /* vDSO has a problem and was disabled, just don't "enable" it for the
8198 * process
8199 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8200 vdso_base = get_unmapped_area(NULL, vdso_base,
8201 (vdso_pages << PAGE_SHIFT) +
8202 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8203 - 0, 0);
8204 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8205 if (IS_ERR_VALUE(vdso_base)) {
8206 rc = vdso_base;
8207 goto fail_mmapsem;
8208 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8209 index 5eea6f3..5d10396 100644
8210 --- a/arch/powerpc/lib/usercopy_64.c
8211 +++ b/arch/powerpc/lib/usercopy_64.c
8212 @@ -9,22 +9,6 @@
8213 #include <linux/module.h>
8214 #include <asm/uaccess.h>
8215
8216 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8217 -{
8218 - if (likely(access_ok(VERIFY_READ, from, n)))
8219 - n = __copy_from_user(to, from, n);
8220 - else
8221 - memset(to, 0, n);
8222 - return n;
8223 -}
8224 -
8225 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8226 -{
8227 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8228 - n = __copy_to_user(to, from, n);
8229 - return n;
8230 -}
8231 -
8232 unsigned long copy_in_user(void __user *to, const void __user *from,
8233 unsigned long n)
8234 {
8235 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8236 return n;
8237 }
8238
8239 -EXPORT_SYMBOL(copy_from_user);
8240 -EXPORT_SYMBOL(copy_to_user);
8241 EXPORT_SYMBOL(copy_in_user);
8242
8243 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8244 index 8726779..a33c512 100644
8245 --- a/arch/powerpc/mm/fault.c
8246 +++ b/arch/powerpc/mm/fault.c
8247 @@ -33,6 +33,10 @@
8248 #include <linux/magic.h>
8249 #include <linux/ratelimit.h>
8250 #include <linux/context_tracking.h>
8251 +#include <linux/slab.h>
8252 +#include <linux/pagemap.h>
8253 +#include <linux/compiler.h>
8254 +#include <linux/unistd.h>
8255
8256 #include <asm/firmware.h>
8257 #include <asm/page.h>
8258 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8259 }
8260 #endif
8261
8262 +#ifdef CONFIG_PAX_PAGEEXEC
8263 +/*
8264 + * PaX: decide what to do with offenders (regs->nip = fault address)
8265 + *
8266 + * returns 1 when task should be killed
8267 + */
8268 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8269 +{
8270 + return 1;
8271 +}
8272 +
8273 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8274 +{
8275 + unsigned long i;
8276 +
8277 + printk(KERN_ERR "PAX: bytes at PC: ");
8278 + for (i = 0; i < 5; i++) {
8279 + unsigned int c;
8280 + if (get_user(c, (unsigned int __user *)pc+i))
8281 + printk(KERN_CONT "???????? ");
8282 + else
8283 + printk(KERN_CONT "%08x ", c);
8284 + }
8285 + printk("\n");
8286 +}
8287 +#endif
8288 +
8289 /*
8290 * Check whether the instruction at regs->nip is a store using
8291 * an update addressing form which will update r1.
8292 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8293 * indicate errors in DSISR but can validly be set in SRR1.
8294 */
8295 if (trap == 0x400)
8296 - error_code &= 0x48200000;
8297 + error_code &= 0x58200000;
8298 else
8299 is_write = error_code & DSISR_ISSTORE;
8300 #else
8301 @@ -371,7 +402,7 @@ good_area:
8302 * "undefined". Of those that can be set, this is the only
8303 * one which seems bad.
8304 */
8305 - if (error_code & 0x10000000)
8306 + if (error_code & DSISR_GUARDED)
8307 /* Guarded storage error. */
8308 goto bad_area;
8309 #endif /* CONFIG_8xx */
8310 @@ -386,7 +417,7 @@ good_area:
8311 * processors use the same I/D cache coherency mechanism
8312 * as embedded.
8313 */
8314 - if (error_code & DSISR_PROTFAULT)
8315 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8316 goto bad_area;
8317 #endif /* CONFIG_PPC_STD_MMU */
8318
8319 @@ -471,6 +502,23 @@ bad_area:
8320 bad_area_nosemaphore:
8321 /* User mode accesses cause a SIGSEGV */
8322 if (user_mode(regs)) {
8323 +
8324 +#ifdef CONFIG_PAX_PAGEEXEC
8325 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8326 +#ifdef CONFIG_PPC_STD_MMU
8327 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8328 +#else
8329 + if (is_exec && regs->nip == address) {
8330 +#endif
8331 + switch (pax_handle_fetch_fault(regs)) {
8332 + }
8333 +
8334 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8335 + do_group_exit(SIGKILL);
8336 + }
8337 + }
8338 +#endif
8339 +
8340 _exception(SIGSEGV, regs, code, address);
8341 goto bail;
8342 }
8343 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8344 index cb8bdbe..d770680 100644
8345 --- a/arch/powerpc/mm/mmap.c
8346 +++ b/arch/powerpc/mm/mmap.c
8347 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8348 {
8349 unsigned long rnd = 0;
8350
8351 +#ifdef CONFIG_PAX_RANDMMAP
8352 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8353 +#endif
8354 +
8355 if (current->flags & PF_RANDOMIZE) {
8356 /* 8MB for 32bit, 1GB for 64bit */
8357 if (is_32bit_task())
8358 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8359 */
8360 if (mmap_is_legacy()) {
8361 mm->mmap_base = TASK_UNMAPPED_BASE;
8362 +
8363 +#ifdef CONFIG_PAX_RANDMMAP
8364 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8365 + mm->mmap_base += mm->delta_mmap;
8366 +#endif
8367 +
8368 mm->get_unmapped_area = arch_get_unmapped_area;
8369 } else {
8370 mm->mmap_base = mmap_base();
8371 +
8372 +#ifdef CONFIG_PAX_RANDMMAP
8373 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8374 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8375 +#endif
8376 +
8377 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8378 }
8379 }
8380 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8381 index 3e99c14..f00953c 100644
8382 --- a/arch/powerpc/mm/slice.c
8383 +++ b/arch/powerpc/mm/slice.c
8384 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8385 if ((mm->task_size - len) < addr)
8386 return 0;
8387 vma = find_vma(mm, addr);
8388 - return (!vma || (addr + len) <= vma->vm_start);
8389 + return check_heap_stack_gap(vma, addr, len, 0);
8390 }
8391
8392 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8393 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8394 info.align_offset = 0;
8395
8396 addr = TASK_UNMAPPED_BASE;
8397 +
8398 +#ifdef CONFIG_PAX_RANDMMAP
8399 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8400 + addr += mm->delta_mmap;
8401 +#endif
8402 +
8403 while (addr < TASK_SIZE) {
8404 info.low_limit = addr;
8405 if (!slice_scan_available(addr, available, 1, &addr))
8406 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8407 if (fixed && addr > (mm->task_size - len))
8408 return -EINVAL;
8409
8410 +#ifdef CONFIG_PAX_RANDMMAP
8411 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8412 + addr = 0;
8413 +#endif
8414 +
8415 /* If hint, make sure it matches our alignment restrictions */
8416 if (!fixed && addr) {
8417 addr = _ALIGN_UP(addr, 1ul << pshift);
8418 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8419 index 9098692..3d54cd1 100644
8420 --- a/arch/powerpc/platforms/cell/spufs/file.c
8421 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8422 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8423 return VM_FAULT_NOPAGE;
8424 }
8425
8426 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8427 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8428 unsigned long address,
8429 - void *buf, int len, int write)
8430 + void *buf, size_t len, int write)
8431 {
8432 struct spu_context *ctx = vma->vm_file->private_data;
8433 unsigned long offset = address - vma->vm_start;
8434 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8435 index c797832..ce575c8 100644
8436 --- a/arch/s390/include/asm/atomic.h
8437 +++ b/arch/s390/include/asm/atomic.h
8438 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8439 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8440 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8441
8442 +#define atomic64_read_unchecked(v) atomic64_read(v)
8443 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8444 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8445 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8446 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8447 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8448 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8449 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8450 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8451 +
8452 #define smp_mb__before_atomic_dec() smp_mb()
8453 #define smp_mb__after_atomic_dec() smp_mb()
8454 #define smp_mb__before_atomic_inc() smp_mb()
8455 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8456 index 4d7ccac..d03d0ad 100644
8457 --- a/arch/s390/include/asm/cache.h
8458 +++ b/arch/s390/include/asm/cache.h
8459 @@ -9,8 +9,10 @@
8460 #ifndef __ARCH_S390_CACHE_H
8461 #define __ARCH_S390_CACHE_H
8462
8463 -#define L1_CACHE_BYTES 256
8464 +#include <linux/const.h>
8465 +
8466 #define L1_CACHE_SHIFT 8
8467 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8468 #define NET_SKB_PAD 32
8469
8470 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8471 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8472 index 78f4f87..598ce39 100644
8473 --- a/arch/s390/include/asm/elf.h
8474 +++ b/arch/s390/include/asm/elf.h
8475 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8476 the loader. We need to make sure that it is out of the way of the program
8477 that it will "exec", and that there is sufficient room for the brk. */
8478
8479 -extern unsigned long randomize_et_dyn(unsigned long base);
8480 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8481 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8482 +
8483 +#ifdef CONFIG_PAX_ASLR
8484 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8485 +
8486 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8487 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8488 +#endif
8489
8490 /* This yields a mask that user programs can use to figure out what
8491 instruction set this CPU supports. */
8492 @@ -222,9 +228,6 @@ struct linux_binprm;
8493 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8494 int arch_setup_additional_pages(struct linux_binprm *, int);
8495
8496 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8497 -#define arch_randomize_brk arch_randomize_brk
8498 -
8499 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8500
8501 #endif
8502 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8503 index c4a93d6..4d2a9b4 100644
8504 --- a/arch/s390/include/asm/exec.h
8505 +++ b/arch/s390/include/asm/exec.h
8506 @@ -7,6 +7,6 @@
8507 #ifndef __ASM_EXEC_H
8508 #define __ASM_EXEC_H
8509
8510 -extern unsigned long arch_align_stack(unsigned long sp);
8511 +#define arch_align_stack(x) ((x) & ~0xfUL)
8512
8513 #endif /* __ASM_EXEC_H */
8514 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8515 index 9c33ed4..e40cbef 100644
8516 --- a/arch/s390/include/asm/uaccess.h
8517 +++ b/arch/s390/include/asm/uaccess.h
8518 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8519 copy_to_user(void __user *to, const void *from, unsigned long n)
8520 {
8521 might_fault();
8522 +
8523 + if ((long)n < 0)
8524 + return n;
8525 +
8526 return __copy_to_user(to, from, n);
8527 }
8528
8529 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8530 static inline unsigned long __must_check
8531 __copy_from_user(void *to, const void __user *from, unsigned long n)
8532 {
8533 + if ((long)n < 0)
8534 + return n;
8535 +
8536 if (__builtin_constant_p(n) && (n <= 256))
8537 return uaccess.copy_from_user_small(n, from, to);
8538 else
8539 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8540 static inline unsigned long __must_check
8541 copy_from_user(void *to, const void __user *from, unsigned long n)
8542 {
8543 - unsigned int sz = __compiletime_object_size(to);
8544 + size_t sz = __compiletime_object_size(to);
8545
8546 might_fault();
8547 - if (unlikely(sz != -1 && sz < n)) {
8548 +
8549 + if ((long)n < 0)
8550 + return n;
8551 +
8552 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8553 copy_from_user_overflow();
8554 return n;
8555 }
8556 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8557 index 7845e15..59c4353 100644
8558 --- a/arch/s390/kernel/module.c
8559 +++ b/arch/s390/kernel/module.c
8560 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8561
8562 /* Increase core size by size of got & plt and set start
8563 offsets for got and plt. */
8564 - me->core_size = ALIGN(me->core_size, 4);
8565 - me->arch.got_offset = me->core_size;
8566 - me->core_size += me->arch.got_size;
8567 - me->arch.plt_offset = me->core_size;
8568 - me->core_size += me->arch.plt_size;
8569 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8570 + me->arch.got_offset = me->core_size_rw;
8571 + me->core_size_rw += me->arch.got_size;
8572 + me->arch.plt_offset = me->core_size_rx;
8573 + me->core_size_rx += me->arch.plt_size;
8574 return 0;
8575 }
8576
8577 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8578 if (info->got_initialized == 0) {
8579 Elf_Addr *gotent;
8580
8581 - gotent = me->module_core + me->arch.got_offset +
8582 + gotent = me->module_core_rw + me->arch.got_offset +
8583 info->got_offset;
8584 *gotent = val;
8585 info->got_initialized = 1;
8586 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8587 rc = apply_rela_bits(loc, val, 0, 64, 0);
8588 else if (r_type == R_390_GOTENT ||
8589 r_type == R_390_GOTPLTENT) {
8590 - val += (Elf_Addr) me->module_core - loc;
8591 + val += (Elf_Addr) me->module_core_rw - loc;
8592 rc = apply_rela_bits(loc, val, 1, 32, 1);
8593 }
8594 break;
8595 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8596 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8597 if (info->plt_initialized == 0) {
8598 unsigned int *ip;
8599 - ip = me->module_core + me->arch.plt_offset +
8600 + ip = me->module_core_rx + me->arch.plt_offset +
8601 info->plt_offset;
8602 #ifndef CONFIG_64BIT
8603 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8604 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8605 val - loc + 0xffffUL < 0x1ffffeUL) ||
8606 (r_type == R_390_PLT32DBL &&
8607 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8608 - val = (Elf_Addr) me->module_core +
8609 + val = (Elf_Addr) me->module_core_rx +
8610 me->arch.plt_offset +
8611 info->plt_offset;
8612 val += rela->r_addend - loc;
8613 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8614 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8615 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8616 val = val + rela->r_addend -
8617 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8618 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8619 if (r_type == R_390_GOTOFF16)
8620 rc = apply_rela_bits(loc, val, 0, 16, 0);
8621 else if (r_type == R_390_GOTOFF32)
8622 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8623 break;
8624 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8625 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8626 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8627 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8628 rela->r_addend - loc;
8629 if (r_type == R_390_GOTPC)
8630 rc = apply_rela_bits(loc, val, 1, 32, 0);
8631 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8632 index 2bc3edd..ab9d598 100644
8633 --- a/arch/s390/kernel/process.c
8634 +++ b/arch/s390/kernel/process.c
8635 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
8636 }
8637 return 0;
8638 }
8639 -
8640 -unsigned long arch_align_stack(unsigned long sp)
8641 -{
8642 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8643 - sp -= get_random_int() & ~PAGE_MASK;
8644 - return sp & ~0xf;
8645 -}
8646 -
8647 -static inline unsigned long brk_rnd(void)
8648 -{
8649 - /* 8MB for 32bit, 1GB for 64bit */
8650 - if (is_32bit_task())
8651 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8652 - else
8653 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8654 -}
8655 -
8656 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8657 -{
8658 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8659 -
8660 - if (ret < mm->brk)
8661 - return mm->brk;
8662 - return ret;
8663 -}
8664 -
8665 -unsigned long randomize_et_dyn(unsigned long base)
8666 -{
8667 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8668 -
8669 - if (!(current->flags & PF_RANDOMIZE))
8670 - return base;
8671 - if (ret < base)
8672 - return base;
8673 - return ret;
8674 -}
8675 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8676 index 4002329..99b67cb 100644
8677 --- a/arch/s390/mm/mmap.c
8678 +++ b/arch/s390/mm/mmap.c
8679 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8680 */
8681 if (mmap_is_legacy()) {
8682 mm->mmap_base = TASK_UNMAPPED_BASE;
8683 +
8684 +#ifdef CONFIG_PAX_RANDMMAP
8685 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8686 + mm->mmap_base += mm->delta_mmap;
8687 +#endif
8688 +
8689 mm->get_unmapped_area = arch_get_unmapped_area;
8690 } else {
8691 mm->mmap_base = mmap_base();
8692 +
8693 +#ifdef CONFIG_PAX_RANDMMAP
8694 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8695 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8696 +#endif
8697 +
8698 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8699 }
8700 }
8701 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8702 */
8703 if (mmap_is_legacy()) {
8704 mm->mmap_base = TASK_UNMAPPED_BASE;
8705 +
8706 +#ifdef CONFIG_PAX_RANDMMAP
8707 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8708 + mm->mmap_base += mm->delta_mmap;
8709 +#endif
8710 +
8711 mm->get_unmapped_area = s390_get_unmapped_area;
8712 } else {
8713 mm->mmap_base = mmap_base();
8714 +
8715 +#ifdef CONFIG_PAX_RANDMMAP
8716 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8717 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8718 +#endif
8719 +
8720 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8721 }
8722 }
8723 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8724 index ae3d59f..f65f075 100644
8725 --- a/arch/score/include/asm/cache.h
8726 +++ b/arch/score/include/asm/cache.h
8727 @@ -1,7 +1,9 @@
8728 #ifndef _ASM_SCORE_CACHE_H
8729 #define _ASM_SCORE_CACHE_H
8730
8731 +#include <linux/const.h>
8732 +
8733 #define L1_CACHE_SHIFT 4
8734 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8735 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8736
8737 #endif /* _ASM_SCORE_CACHE_H */
8738 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8739 index f9f3cd5..58ff438 100644
8740 --- a/arch/score/include/asm/exec.h
8741 +++ b/arch/score/include/asm/exec.h
8742 @@ -1,6 +1,6 @@
8743 #ifndef _ASM_SCORE_EXEC_H
8744 #define _ASM_SCORE_EXEC_H
8745
8746 -extern unsigned long arch_align_stack(unsigned long sp);
8747 +#define arch_align_stack(x) (x)
8748
8749 #endif /* _ASM_SCORE_EXEC_H */
8750 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8751 index f4c6d02..e9355c3 100644
8752 --- a/arch/score/kernel/process.c
8753 +++ b/arch/score/kernel/process.c
8754 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8755
8756 return task_pt_regs(task)->cp0_epc;
8757 }
8758 -
8759 -unsigned long arch_align_stack(unsigned long sp)
8760 -{
8761 - return sp;
8762 -}
8763 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8764 index ef9e555..331bd29 100644
8765 --- a/arch/sh/include/asm/cache.h
8766 +++ b/arch/sh/include/asm/cache.h
8767 @@ -9,10 +9,11 @@
8768 #define __ASM_SH_CACHE_H
8769 #ifdef __KERNEL__
8770
8771 +#include <linux/const.h>
8772 #include <linux/init.h>
8773 #include <cpu/cache.h>
8774
8775 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8776 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8777
8778 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8779
8780 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8781 index 6777177..cb5e44f 100644
8782 --- a/arch/sh/mm/mmap.c
8783 +++ b/arch/sh/mm/mmap.c
8784 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8785 struct mm_struct *mm = current->mm;
8786 struct vm_area_struct *vma;
8787 int do_colour_align;
8788 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8789 struct vm_unmapped_area_info info;
8790
8791 if (flags & MAP_FIXED) {
8792 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8793 if (filp || (flags & MAP_SHARED))
8794 do_colour_align = 1;
8795
8796 +#ifdef CONFIG_PAX_RANDMMAP
8797 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8798 +#endif
8799 +
8800 if (addr) {
8801 if (do_colour_align)
8802 addr = COLOUR_ALIGN(addr, pgoff);
8803 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8804 addr = PAGE_ALIGN(addr);
8805
8806 vma = find_vma(mm, addr);
8807 - if (TASK_SIZE - len >= addr &&
8808 - (!vma || addr + len <= vma->vm_start))
8809 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8810 return addr;
8811 }
8812
8813 info.flags = 0;
8814 info.length = len;
8815 - info.low_limit = TASK_UNMAPPED_BASE;
8816 + info.low_limit = mm->mmap_base;
8817 info.high_limit = TASK_SIZE;
8818 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8819 info.align_offset = pgoff << PAGE_SHIFT;
8820 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8821 struct mm_struct *mm = current->mm;
8822 unsigned long addr = addr0;
8823 int do_colour_align;
8824 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8825 struct vm_unmapped_area_info info;
8826
8827 if (flags & MAP_FIXED) {
8828 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8829 if (filp || (flags & MAP_SHARED))
8830 do_colour_align = 1;
8831
8832 +#ifdef CONFIG_PAX_RANDMMAP
8833 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8834 +#endif
8835 +
8836 /* requesting a specific address */
8837 if (addr) {
8838 if (do_colour_align)
8839 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8840 addr = PAGE_ALIGN(addr);
8841
8842 vma = find_vma(mm, addr);
8843 - if (TASK_SIZE - len >= addr &&
8844 - (!vma || addr + len <= vma->vm_start))
8845 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8846 return addr;
8847 }
8848
8849 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8850 VM_BUG_ON(addr != -ENOMEM);
8851 info.flags = 0;
8852 info.low_limit = TASK_UNMAPPED_BASE;
8853 +
8854 +#ifdef CONFIG_PAX_RANDMMAP
8855 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8856 + info.low_limit += mm->delta_mmap;
8857 +#endif
8858 +
8859 info.high_limit = TASK_SIZE;
8860 addr = vm_unmapped_area(&info);
8861 }
8862 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8863 index be56a24..443328f 100644
8864 --- a/arch/sparc/include/asm/atomic_64.h
8865 +++ b/arch/sparc/include/asm/atomic_64.h
8866 @@ -14,18 +14,40 @@
8867 #define ATOMIC64_INIT(i) { (i) }
8868
8869 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8870 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8871 +{
8872 + return v->counter;
8873 +}
8874 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8875 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8876 +{
8877 + return v->counter;
8878 +}
8879
8880 #define atomic_set(v, i) (((v)->counter) = i)
8881 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8882 +{
8883 + v->counter = i;
8884 +}
8885 #define atomic64_set(v, i) (((v)->counter) = i)
8886 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8887 +{
8888 + v->counter = i;
8889 +}
8890
8891 extern void atomic_add(int, atomic_t *);
8892 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8893 extern void atomic64_add(long, atomic64_t *);
8894 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8895 extern void atomic_sub(int, atomic_t *);
8896 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8897 extern void atomic64_sub(long, atomic64_t *);
8898 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8899
8900 extern int atomic_add_ret(int, atomic_t *);
8901 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8902 extern long atomic64_add_ret(long, atomic64_t *);
8903 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8904 extern int atomic_sub_ret(int, atomic_t *);
8905 extern long atomic64_sub_ret(long, atomic64_t *);
8906
8907 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8908 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8909
8910 #define atomic_inc_return(v) atomic_add_ret(1, v)
8911 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8912 +{
8913 + return atomic_add_ret_unchecked(1, v);
8914 +}
8915 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8916 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8917 +{
8918 + return atomic64_add_ret_unchecked(1, v);
8919 +}
8920
8921 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8922 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8923
8924 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8925 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8926 +{
8927 + return atomic_add_ret_unchecked(i, v);
8928 +}
8929 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8930 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8931 +{
8932 + return atomic64_add_ret_unchecked(i, v);
8933 +}
8934
8935 /*
8936 * atomic_inc_and_test - increment and test
8937 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8938 * other cases.
8939 */
8940 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8941 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8942 +{
8943 + return atomic_inc_return_unchecked(v) == 0;
8944 +}
8945 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8946
8947 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8948 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8949 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8950
8951 #define atomic_inc(v) atomic_add(1, v)
8952 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8953 +{
8954 + atomic_add_unchecked(1, v);
8955 +}
8956 #define atomic64_inc(v) atomic64_add(1, v)
8957 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8958 +{
8959 + atomic64_add_unchecked(1, v);
8960 +}
8961
8962 #define atomic_dec(v) atomic_sub(1, v)
8963 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8964 +{
8965 + atomic_sub_unchecked(1, v);
8966 +}
8967 #define atomic64_dec(v) atomic64_sub(1, v)
8968 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8969 +{
8970 + atomic64_sub_unchecked(1, v);
8971 +}
8972
8973 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8974 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8975
8976 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8977 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8978 +{
8979 + return cmpxchg(&v->counter, old, new);
8980 +}
8981 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8982 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8983 +{
8984 + return xchg(&v->counter, new);
8985 +}
8986
8987 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8988 {
8989 - int c, old;
8990 + int c, old, new;
8991 c = atomic_read(v);
8992 for (;;) {
8993 - if (unlikely(c == (u)))
8994 + if (unlikely(c == u))
8995 break;
8996 - old = atomic_cmpxchg((v), c, c + (a));
8997 +
8998 + asm volatile("addcc %2, %0, %0\n"
8999 +
9000 +#ifdef CONFIG_PAX_REFCOUNT
9001 + "tvs %%icc, 6\n"
9002 +#endif
9003 +
9004 + : "=r" (new)
9005 + : "0" (c), "ir" (a)
9006 + : "cc");
9007 +
9008 + old = atomic_cmpxchg(v, c, new);
9009 if (likely(old == c))
9010 break;
9011 c = old;
9012 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9013 #define atomic64_cmpxchg(v, o, n) \
9014 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9015 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9016 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9017 +{
9018 + return xchg(&v->counter, new);
9019 +}
9020
9021 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9022 {
9023 - long c, old;
9024 + long c, old, new;
9025 c = atomic64_read(v);
9026 for (;;) {
9027 - if (unlikely(c == (u)))
9028 + if (unlikely(c == u))
9029 break;
9030 - old = atomic64_cmpxchg((v), c, c + (a));
9031 +
9032 + asm volatile("addcc %2, %0, %0\n"
9033 +
9034 +#ifdef CONFIG_PAX_REFCOUNT
9035 + "tvs %%xcc, 6\n"
9036 +#endif
9037 +
9038 + : "=r" (new)
9039 + : "0" (c), "ir" (a)
9040 + : "cc");
9041 +
9042 + old = atomic64_cmpxchg(v, c, new);
9043 if (likely(old == c))
9044 break;
9045 c = old;
9046 }
9047 - return c != (u);
9048 + return c != u;
9049 }
9050
9051 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9052 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9053 index 5bb6991..5c2132e 100644
9054 --- a/arch/sparc/include/asm/cache.h
9055 +++ b/arch/sparc/include/asm/cache.h
9056 @@ -7,10 +7,12 @@
9057 #ifndef _SPARC_CACHE_H
9058 #define _SPARC_CACHE_H
9059
9060 +#include <linux/const.h>
9061 +
9062 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9063
9064 #define L1_CACHE_SHIFT 5
9065 -#define L1_CACHE_BYTES 32
9066 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9067
9068 #ifdef CONFIG_SPARC32
9069 #define SMP_CACHE_BYTES_SHIFT 5
9070 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9071 index a24e41f..47677ff 100644
9072 --- a/arch/sparc/include/asm/elf_32.h
9073 +++ b/arch/sparc/include/asm/elf_32.h
9074 @@ -114,6 +114,13 @@ typedef struct {
9075
9076 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9077
9078 +#ifdef CONFIG_PAX_ASLR
9079 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9080 +
9081 +#define PAX_DELTA_MMAP_LEN 16
9082 +#define PAX_DELTA_STACK_LEN 16
9083 +#endif
9084 +
9085 /* This yields a mask that user programs can use to figure out what
9086 instruction set this cpu supports. This can NOT be done in userspace
9087 on Sparc. */
9088 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9089 index 370ca1e..d4f4a98 100644
9090 --- a/arch/sparc/include/asm/elf_64.h
9091 +++ b/arch/sparc/include/asm/elf_64.h
9092 @@ -189,6 +189,13 @@ typedef struct {
9093 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9094 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9095
9096 +#ifdef CONFIG_PAX_ASLR
9097 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9098 +
9099 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9100 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9101 +#endif
9102 +
9103 extern unsigned long sparc64_elf_hwcap;
9104 #define ELF_HWCAP sparc64_elf_hwcap
9105
9106 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9107 index 9b1c36d..209298b 100644
9108 --- a/arch/sparc/include/asm/pgalloc_32.h
9109 +++ b/arch/sparc/include/asm/pgalloc_32.h
9110 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9111 }
9112
9113 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9114 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9115
9116 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9117 unsigned long address)
9118 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9119 index bcfe063..b333142 100644
9120 --- a/arch/sparc/include/asm/pgalloc_64.h
9121 +++ b/arch/sparc/include/asm/pgalloc_64.h
9122 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9123 }
9124
9125 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9126 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9127
9128 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9129 {
9130 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9131 index 502f632..da1917f 100644
9132 --- a/arch/sparc/include/asm/pgtable_32.h
9133 +++ b/arch/sparc/include/asm/pgtable_32.h
9134 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9135 #define PAGE_SHARED SRMMU_PAGE_SHARED
9136 #define PAGE_COPY SRMMU_PAGE_COPY
9137 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9138 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9139 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9140 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9141 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9142
9143 /* Top-level page directory - dummy used by init-mm.
9144 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9145
9146 /* xwr */
9147 #define __P000 PAGE_NONE
9148 -#define __P001 PAGE_READONLY
9149 -#define __P010 PAGE_COPY
9150 -#define __P011 PAGE_COPY
9151 +#define __P001 PAGE_READONLY_NOEXEC
9152 +#define __P010 PAGE_COPY_NOEXEC
9153 +#define __P011 PAGE_COPY_NOEXEC
9154 #define __P100 PAGE_READONLY
9155 #define __P101 PAGE_READONLY
9156 #define __P110 PAGE_COPY
9157 #define __P111 PAGE_COPY
9158
9159 #define __S000 PAGE_NONE
9160 -#define __S001 PAGE_READONLY
9161 -#define __S010 PAGE_SHARED
9162 -#define __S011 PAGE_SHARED
9163 +#define __S001 PAGE_READONLY_NOEXEC
9164 +#define __S010 PAGE_SHARED_NOEXEC
9165 +#define __S011 PAGE_SHARED_NOEXEC
9166 #define __S100 PAGE_READONLY
9167 #define __S101 PAGE_READONLY
9168 #define __S110 PAGE_SHARED
9169 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9170 index 79da178..c2eede8 100644
9171 --- a/arch/sparc/include/asm/pgtsrmmu.h
9172 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9173 @@ -115,6 +115,11 @@
9174 SRMMU_EXEC | SRMMU_REF)
9175 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9176 SRMMU_EXEC | SRMMU_REF)
9177 +
9178 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9179 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9180 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9181 +
9182 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9183 SRMMU_DIRTY | SRMMU_REF)
9184
9185 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9186 index 9689176..63c18ea 100644
9187 --- a/arch/sparc/include/asm/spinlock_64.h
9188 +++ b/arch/sparc/include/asm/spinlock_64.h
9189 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9190
9191 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9192
9193 -static void inline arch_read_lock(arch_rwlock_t *lock)
9194 +static inline void arch_read_lock(arch_rwlock_t *lock)
9195 {
9196 unsigned long tmp1, tmp2;
9197
9198 __asm__ __volatile__ (
9199 "1: ldsw [%2], %0\n"
9200 " brlz,pn %0, 2f\n"
9201 -"4: add %0, 1, %1\n"
9202 +"4: addcc %0, 1, %1\n"
9203 +
9204 +#ifdef CONFIG_PAX_REFCOUNT
9205 +" tvs %%icc, 6\n"
9206 +#endif
9207 +
9208 " cas [%2], %0, %1\n"
9209 " cmp %0, %1\n"
9210 " bne,pn %%icc, 1b\n"
9211 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9212 " .previous"
9213 : "=&r" (tmp1), "=&r" (tmp2)
9214 : "r" (lock)
9215 - : "memory");
9216 + : "memory", "cc");
9217 }
9218
9219 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9220 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9221 {
9222 int tmp1, tmp2;
9223
9224 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9225 "1: ldsw [%2], %0\n"
9226 " brlz,a,pn %0, 2f\n"
9227 " mov 0, %0\n"
9228 -" add %0, 1, %1\n"
9229 +" addcc %0, 1, %1\n"
9230 +
9231 +#ifdef CONFIG_PAX_REFCOUNT
9232 +" tvs %%icc, 6\n"
9233 +#endif
9234 +
9235 " cas [%2], %0, %1\n"
9236 " cmp %0, %1\n"
9237 " bne,pn %%icc, 1b\n"
9238 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9239 return tmp1;
9240 }
9241
9242 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9243 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9244 {
9245 unsigned long tmp1, tmp2;
9246
9247 __asm__ __volatile__(
9248 "1: lduw [%2], %0\n"
9249 -" sub %0, 1, %1\n"
9250 +" subcc %0, 1, %1\n"
9251 +
9252 +#ifdef CONFIG_PAX_REFCOUNT
9253 +" tvs %%icc, 6\n"
9254 +#endif
9255 +
9256 " cas [%2], %0, %1\n"
9257 " cmp %0, %1\n"
9258 " bne,pn %%xcc, 1b\n"
9259 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9260 : "memory");
9261 }
9262
9263 -static void inline arch_write_lock(arch_rwlock_t *lock)
9264 +static inline void arch_write_lock(arch_rwlock_t *lock)
9265 {
9266 unsigned long mask, tmp1, tmp2;
9267
9268 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9269 : "memory");
9270 }
9271
9272 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9273 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9274 {
9275 __asm__ __volatile__(
9276 " stw %%g0, [%0]"
9277 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9278 : "memory");
9279 }
9280
9281 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9282 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9283 {
9284 unsigned long mask, tmp1, tmp2, result;
9285
9286 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9287 index dd38075..e7cac83 100644
9288 --- a/arch/sparc/include/asm/thread_info_32.h
9289 +++ b/arch/sparc/include/asm/thread_info_32.h
9290 @@ -49,6 +49,8 @@ struct thread_info {
9291 unsigned long w_saved;
9292
9293 struct restart_block restart_block;
9294 +
9295 + unsigned long lowest_stack;
9296 };
9297
9298 /*
9299 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9300 index d5e5042..9bfee76 100644
9301 --- a/arch/sparc/include/asm/thread_info_64.h
9302 +++ b/arch/sparc/include/asm/thread_info_64.h
9303 @@ -63,6 +63,8 @@ struct thread_info {
9304 struct pt_regs *kern_una_regs;
9305 unsigned int kern_una_insn;
9306
9307 + unsigned long lowest_stack;
9308 +
9309 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9310 };
9311
9312 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9313 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9314 /* flag bit 6 is available */
9315 #define TIF_32BIT 7 /* 32-bit binary */
9316 -/* flag bit 8 is available */
9317 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9318 #define TIF_SECCOMP 9 /* secure computing */
9319 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9320 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9321 +
9322 /* NOTE: Thread flags >= 12 should be ones we have no interest
9323 * in using in assembly, else we can't use the mask as
9324 * an immediate value in instructions such as andcc.
9325 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9326 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9327 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9328 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9329 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9330
9331 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9332 _TIF_DO_NOTIFY_RESUME_MASK | \
9333 _TIF_NEED_RESCHED)
9334 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9335
9336 +#define _TIF_WORK_SYSCALL \
9337 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9338 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9339 +
9340 +
9341 /*
9342 * Thread-synchronous status.
9343 *
9344 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9345 index 0167d26..767bb0c 100644
9346 --- a/arch/sparc/include/asm/uaccess.h
9347 +++ b/arch/sparc/include/asm/uaccess.h
9348 @@ -1,5 +1,6 @@
9349 #ifndef ___ASM_SPARC_UACCESS_H
9350 #define ___ASM_SPARC_UACCESS_H
9351 +
9352 #if defined(__sparc__) && defined(__arch64__)
9353 #include <asm/uaccess_64.h>
9354 #else
9355 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9356 index 53a28dd..50c38c3 100644
9357 --- a/arch/sparc/include/asm/uaccess_32.h
9358 +++ b/arch/sparc/include/asm/uaccess_32.h
9359 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9360
9361 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9362 {
9363 - if (n && __access_ok((unsigned long) to, n))
9364 + if ((long)n < 0)
9365 + return n;
9366 +
9367 + if (n && __access_ok((unsigned long) to, n)) {
9368 + if (!__builtin_constant_p(n))
9369 + check_object_size(from, n, true);
9370 return __copy_user(to, (__force void __user *) from, n);
9371 - else
9372 + } else
9373 return n;
9374 }
9375
9376 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9377 {
9378 + if ((long)n < 0)
9379 + return n;
9380 +
9381 + if (!__builtin_constant_p(n))
9382 + check_object_size(from, n, true);
9383 +
9384 return __copy_user(to, (__force void __user *) from, n);
9385 }
9386
9387 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9388 {
9389 - if (n && __access_ok((unsigned long) from, n))
9390 + if ((long)n < 0)
9391 + return n;
9392 +
9393 + if (n && __access_ok((unsigned long) from, n)) {
9394 + if (!__builtin_constant_p(n))
9395 + check_object_size(to, n, false);
9396 return __copy_user((__force void __user *) to, from, n);
9397 - else
9398 + } else
9399 return n;
9400 }
9401
9402 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9403 {
9404 + if ((long)n < 0)
9405 + return n;
9406 +
9407 return __copy_user((__force void __user *) to, from, n);
9408 }
9409
9410 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9411 index e562d3c..191f176 100644
9412 --- a/arch/sparc/include/asm/uaccess_64.h
9413 +++ b/arch/sparc/include/asm/uaccess_64.h
9414 @@ -10,6 +10,7 @@
9415 #include <linux/compiler.h>
9416 #include <linux/string.h>
9417 #include <linux/thread_info.h>
9418 +#include <linux/kernel.h>
9419 #include <asm/asi.h>
9420 #include <asm/spitfire.h>
9421 #include <asm-generic/uaccess-unaligned.h>
9422 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9423 static inline unsigned long __must_check
9424 copy_from_user(void *to, const void __user *from, unsigned long size)
9425 {
9426 - unsigned long ret = ___copy_from_user(to, from, size);
9427 + unsigned long ret;
9428
9429 + if ((long)size < 0 || size > INT_MAX)
9430 + return size;
9431 +
9432 + if (!__builtin_constant_p(size))
9433 + check_object_size(to, size, false);
9434 +
9435 + ret = ___copy_from_user(to, from, size);
9436 if (unlikely(ret))
9437 ret = copy_from_user_fixup(to, from, size);
9438
9439 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9440 static inline unsigned long __must_check
9441 copy_to_user(void __user *to, const void *from, unsigned long size)
9442 {
9443 - unsigned long ret = ___copy_to_user(to, from, size);
9444 + unsigned long ret;
9445
9446 + if ((long)size < 0 || size > INT_MAX)
9447 + return size;
9448 +
9449 + if (!__builtin_constant_p(size))
9450 + check_object_size(from, size, true);
9451 +
9452 + ret = ___copy_to_user(to, from, size);
9453 if (unlikely(ret))
9454 ret = copy_to_user_fixup(to, from, size);
9455 return ret;
9456 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9457 index d432fb2..6056af1 100644
9458 --- a/arch/sparc/kernel/Makefile
9459 +++ b/arch/sparc/kernel/Makefile
9460 @@ -3,7 +3,7 @@
9461 #
9462
9463 asflags-y := -ansi
9464 -ccflags-y := -Werror
9465 +#ccflags-y := -Werror
9466
9467 extra-y := head_$(BITS).o
9468
9469 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9470 index fdd819d..5af08c8 100644
9471 --- a/arch/sparc/kernel/process_32.c
9472 +++ b/arch/sparc/kernel/process_32.c
9473 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9474
9475 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9476 r->psr, r->pc, r->npc, r->y, print_tainted());
9477 - printk("PC: <%pS>\n", (void *) r->pc);
9478 + printk("PC: <%pA>\n", (void *) r->pc);
9479 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9480 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9481 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9482 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9483 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9484 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9485 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9486 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9487
9488 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9489 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9490 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9491 rw = (struct reg_window32 *) fp;
9492 pc = rw->ins[7];
9493 printk("[%08lx : ", pc);
9494 - printk("%pS ] ", (void *) pc);
9495 + printk("%pA ] ", (void *) pc);
9496 fp = rw->ins[6];
9497 } while (++count < 16);
9498 printk("\n");
9499 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9500 index baebab2..9cd13b1 100644
9501 --- a/arch/sparc/kernel/process_64.c
9502 +++ b/arch/sparc/kernel/process_64.c
9503 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9504 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9505 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9506 if (regs->tstate & TSTATE_PRIV)
9507 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9508 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9509 }
9510
9511 void show_regs(struct pt_regs *regs)
9512 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9513
9514 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9515 regs->tpc, regs->tnpc, regs->y, print_tainted());
9516 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9517 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9518 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9519 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9520 regs->u_regs[3]);
9521 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9522 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9523 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9524 regs->u_regs[15]);
9525 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9526 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9527 show_regwindow(regs);
9528 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9529 }
9530 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9531 ((tp && tp->task) ? tp->task->pid : -1));
9532
9533 if (gp->tstate & TSTATE_PRIV) {
9534 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9535 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9536 (void *) gp->tpc,
9537 (void *) gp->o7,
9538 (void *) gp->i7,
9539 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9540 index 79cc0d1..ec62734 100644
9541 --- a/arch/sparc/kernel/prom_common.c
9542 +++ b/arch/sparc/kernel/prom_common.c
9543 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9544
9545 unsigned int prom_early_allocated __initdata;
9546
9547 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9548 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9549 .nextprop = prom_common_nextprop,
9550 .getproplen = prom_getproplen,
9551 .getproperty = prom_getproperty,
9552 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9553 index 7ff45e4..a58f271 100644
9554 --- a/arch/sparc/kernel/ptrace_64.c
9555 +++ b/arch/sparc/kernel/ptrace_64.c
9556 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
9557 return ret;
9558 }
9559
9560 +#ifdef CONFIG_GRKERNSEC_SETXID
9561 +extern void gr_delayed_cred_worker(void);
9562 +#endif
9563 +
9564 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9565 {
9566 int ret = 0;
9567 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9568 /* do the secure computing check first */
9569 secure_computing_strict(regs->u_regs[UREG_G1]);
9570
9571 +#ifdef CONFIG_GRKERNSEC_SETXID
9572 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9573 + gr_delayed_cred_worker();
9574 +#endif
9575 +
9576 if (test_thread_flag(TIF_SYSCALL_TRACE))
9577 ret = tracehook_report_syscall_entry(regs);
9578
9579 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9580
9581 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9582 {
9583 +#ifdef CONFIG_GRKERNSEC_SETXID
9584 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9585 + gr_delayed_cred_worker();
9586 +#endif
9587 +
9588 audit_syscall_exit(regs);
9589
9590 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9591 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9592 index e142545..fd29654 100644
9593 --- a/arch/sparc/kernel/smp_64.c
9594 +++ b/arch/sparc/kernel/smp_64.c
9595 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9596 extern unsigned long xcall_flush_dcache_page_spitfire;
9597
9598 #ifdef CONFIG_DEBUG_DCFLUSH
9599 -extern atomic_t dcpage_flushes;
9600 -extern atomic_t dcpage_flushes_xcall;
9601 +extern atomic_unchecked_t dcpage_flushes;
9602 +extern atomic_unchecked_t dcpage_flushes_xcall;
9603 #endif
9604
9605 static inline void __local_flush_dcache_page(struct page *page)
9606 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9607 return;
9608
9609 #ifdef CONFIG_DEBUG_DCFLUSH
9610 - atomic_inc(&dcpage_flushes);
9611 + atomic_inc_unchecked(&dcpage_flushes);
9612 #endif
9613
9614 this_cpu = get_cpu();
9615 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9616 xcall_deliver(data0, __pa(pg_addr),
9617 (u64) pg_addr, cpumask_of(cpu));
9618 #ifdef CONFIG_DEBUG_DCFLUSH
9619 - atomic_inc(&dcpage_flushes_xcall);
9620 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9621 #endif
9622 }
9623 }
9624 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9625 preempt_disable();
9626
9627 #ifdef CONFIG_DEBUG_DCFLUSH
9628 - atomic_inc(&dcpage_flushes);
9629 + atomic_inc_unchecked(&dcpage_flushes);
9630 #endif
9631 data0 = 0;
9632 pg_addr = page_address(page);
9633 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9634 xcall_deliver(data0, __pa(pg_addr),
9635 (u64) pg_addr, cpu_online_mask);
9636 #ifdef CONFIG_DEBUG_DCFLUSH
9637 - atomic_inc(&dcpage_flushes_xcall);
9638 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9639 #endif
9640 }
9641 __local_flush_dcache_page(page);
9642 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9643 index 3a8d184..49498a8 100644
9644 --- a/arch/sparc/kernel/sys_sparc_32.c
9645 +++ b/arch/sparc/kernel/sys_sparc_32.c
9646 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9647 if (len > TASK_SIZE - PAGE_SIZE)
9648 return -ENOMEM;
9649 if (!addr)
9650 - addr = TASK_UNMAPPED_BASE;
9651 + addr = current->mm->mmap_base;
9652
9653 info.flags = 0;
9654 info.length = len;
9655 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9656 index 51561b8..8256764 100644
9657 --- a/arch/sparc/kernel/sys_sparc_64.c
9658 +++ b/arch/sparc/kernel/sys_sparc_64.c
9659 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9660 struct vm_area_struct * vma;
9661 unsigned long task_size = TASK_SIZE;
9662 int do_color_align;
9663 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9664 struct vm_unmapped_area_info info;
9665
9666 if (flags & MAP_FIXED) {
9667 /* We do not accept a shared mapping if it would violate
9668 * cache aliasing constraints.
9669 */
9670 - if ((flags & MAP_SHARED) &&
9671 + if ((filp || (flags & MAP_SHARED)) &&
9672 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9673 return -EINVAL;
9674 return addr;
9675 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9676 if (filp || (flags & MAP_SHARED))
9677 do_color_align = 1;
9678
9679 +#ifdef CONFIG_PAX_RANDMMAP
9680 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9681 +#endif
9682 +
9683 if (addr) {
9684 if (do_color_align)
9685 addr = COLOR_ALIGN(addr, pgoff);
9686 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9687 addr = PAGE_ALIGN(addr);
9688
9689 vma = find_vma(mm, addr);
9690 - if (task_size - len >= addr &&
9691 - (!vma || addr + len <= vma->vm_start))
9692 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9693 return addr;
9694 }
9695
9696 info.flags = 0;
9697 info.length = len;
9698 - info.low_limit = TASK_UNMAPPED_BASE;
9699 + info.low_limit = mm->mmap_base;
9700 info.high_limit = min(task_size, VA_EXCLUDE_START);
9701 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9702 info.align_offset = pgoff << PAGE_SHIFT;
9703 + info.threadstack_offset = offset;
9704 addr = vm_unmapped_area(&info);
9705
9706 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9707 VM_BUG_ON(addr != -ENOMEM);
9708 info.low_limit = VA_EXCLUDE_END;
9709 +
9710 +#ifdef CONFIG_PAX_RANDMMAP
9711 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9712 + info.low_limit += mm->delta_mmap;
9713 +#endif
9714 +
9715 info.high_limit = task_size;
9716 addr = vm_unmapped_area(&info);
9717 }
9718 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9719 unsigned long task_size = STACK_TOP32;
9720 unsigned long addr = addr0;
9721 int do_color_align;
9722 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9723 struct vm_unmapped_area_info info;
9724
9725 /* This should only ever run for 32-bit processes. */
9726 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9727 /* We do not accept a shared mapping if it would violate
9728 * cache aliasing constraints.
9729 */
9730 - if ((flags & MAP_SHARED) &&
9731 + if ((filp || (flags & MAP_SHARED)) &&
9732 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9733 return -EINVAL;
9734 return addr;
9735 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9736 if (filp || (flags & MAP_SHARED))
9737 do_color_align = 1;
9738
9739 +#ifdef CONFIG_PAX_RANDMMAP
9740 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9741 +#endif
9742 +
9743 /* requesting a specific address */
9744 if (addr) {
9745 if (do_color_align)
9746 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9747 addr = PAGE_ALIGN(addr);
9748
9749 vma = find_vma(mm, addr);
9750 - if (task_size - len >= addr &&
9751 - (!vma || addr + len <= vma->vm_start))
9752 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9753 return addr;
9754 }
9755
9756 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9757 info.high_limit = mm->mmap_base;
9758 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9759 info.align_offset = pgoff << PAGE_SHIFT;
9760 + info.threadstack_offset = offset;
9761 addr = vm_unmapped_area(&info);
9762
9763 /*
9764 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9765 VM_BUG_ON(addr != -ENOMEM);
9766 info.flags = 0;
9767 info.low_limit = TASK_UNMAPPED_BASE;
9768 +
9769 +#ifdef CONFIG_PAX_RANDMMAP
9770 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9771 + info.low_limit += mm->delta_mmap;
9772 +#endif
9773 +
9774 info.high_limit = STACK_TOP32;
9775 addr = vm_unmapped_area(&info);
9776 }
9777 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9778 EXPORT_SYMBOL(get_fb_unmapped_area);
9779
9780 /* Essentially the same as PowerPC. */
9781 -static unsigned long mmap_rnd(void)
9782 +static unsigned long mmap_rnd(struct mm_struct *mm)
9783 {
9784 unsigned long rnd = 0UL;
9785
9786 +#ifdef CONFIG_PAX_RANDMMAP
9787 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9788 +#endif
9789 +
9790 if (current->flags & PF_RANDOMIZE) {
9791 unsigned long val = get_random_int();
9792 if (test_thread_flag(TIF_32BIT))
9793 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9794
9795 void arch_pick_mmap_layout(struct mm_struct *mm)
9796 {
9797 - unsigned long random_factor = mmap_rnd();
9798 + unsigned long random_factor = mmap_rnd(mm);
9799 unsigned long gap;
9800
9801 /*
9802 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9803 gap == RLIM_INFINITY ||
9804 sysctl_legacy_va_layout) {
9805 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9806 +
9807 +#ifdef CONFIG_PAX_RANDMMAP
9808 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9809 + mm->mmap_base += mm->delta_mmap;
9810 +#endif
9811 +
9812 mm->get_unmapped_area = arch_get_unmapped_area;
9813 } else {
9814 /* We know it's 32-bit */
9815 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9816 gap = (task_size / 6 * 5);
9817
9818 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9819 +
9820 +#ifdef CONFIG_PAX_RANDMMAP
9821 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9822 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9823 +#endif
9824 +
9825 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9826 }
9827 }
9828 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9829 index 73ec8a7..4611979 100644
9830 --- a/arch/sparc/kernel/syscalls.S
9831 +++ b/arch/sparc/kernel/syscalls.S
9832 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9833 #endif
9834 .align 32
9835 1: ldx [%g6 + TI_FLAGS], %l5
9836 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9837 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9838 be,pt %icc, rtrap
9839 nop
9840 call syscall_trace_leave
9841 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9842
9843 srl %i3, 0, %o3 ! IEU0
9844 srl %i2, 0, %o2 ! IEU0 Group
9845 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9846 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9847 bne,pn %icc, linux_syscall_trace32 ! CTI
9848 mov %i0, %l5 ! IEU1
9849 5: call %l7 ! CTI Group brk forced
9850 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9851
9852 mov %i3, %o3 ! IEU1
9853 mov %i4, %o4 ! IEU0 Group
9854 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9855 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9856 bne,pn %icc, linux_syscall_trace ! CTI Group
9857 mov %i0, %l5 ! IEU0
9858 2: call %l7 ! CTI Group brk forced
9859 @@ -223,7 +223,7 @@ ret_sys_call:
9860
9861 cmp %o0, -ERESTART_RESTARTBLOCK
9862 bgeu,pn %xcc, 1f
9863 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9864 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9865 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9866
9867 2:
9868 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9869 index 6629829..036032d 100644
9870 --- a/arch/sparc/kernel/traps_32.c
9871 +++ b/arch/sparc/kernel/traps_32.c
9872 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9873 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9874 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9875
9876 +extern void gr_handle_kernel_exploit(void);
9877 +
9878 void die_if_kernel(char *str, struct pt_regs *regs)
9879 {
9880 static int die_counter;
9881 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9882 count++ < 30 &&
9883 (((unsigned long) rw) >= PAGE_OFFSET) &&
9884 !(((unsigned long) rw) & 0x7)) {
9885 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9886 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9887 (void *) rw->ins[7]);
9888 rw = (struct reg_window32 *)rw->ins[6];
9889 }
9890 }
9891 printk("Instruction DUMP:");
9892 instruction_dump ((unsigned long *) regs->pc);
9893 - if(regs->psr & PSR_PS)
9894 + if(regs->psr & PSR_PS) {
9895 + gr_handle_kernel_exploit();
9896 do_exit(SIGKILL);
9897 + }
9898 do_exit(SIGSEGV);
9899 }
9900
9901 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9902 index b3f833a..f485f80 100644
9903 --- a/arch/sparc/kernel/traps_64.c
9904 +++ b/arch/sparc/kernel/traps_64.c
9905 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9906 i + 1,
9907 p->trapstack[i].tstate, p->trapstack[i].tpc,
9908 p->trapstack[i].tnpc, p->trapstack[i].tt);
9909 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9910 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9911 }
9912 }
9913
9914 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9915
9916 lvl -= 0x100;
9917 if (regs->tstate & TSTATE_PRIV) {
9918 +
9919 +#ifdef CONFIG_PAX_REFCOUNT
9920 + if (lvl == 6)
9921 + pax_report_refcount_overflow(regs);
9922 +#endif
9923 +
9924 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9925 die_if_kernel(buffer, regs);
9926 }
9927 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9928 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9929 {
9930 char buffer[32];
9931 -
9932 +
9933 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9934 0, lvl, SIGTRAP) == NOTIFY_STOP)
9935 return;
9936
9937 +#ifdef CONFIG_PAX_REFCOUNT
9938 + if (lvl == 6)
9939 + pax_report_refcount_overflow(regs);
9940 +#endif
9941 +
9942 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9943
9944 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9945 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9946 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
9947 printk("%s" "ERROR(%d): ",
9948 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
9949 - printk("TPC<%pS>\n", (void *) regs->tpc);
9950 + printk("TPC<%pA>\n", (void *) regs->tpc);
9951 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
9952 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
9953 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
9954 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9955 smp_processor_id(),
9956 (type & 0x1) ? 'I' : 'D',
9957 regs->tpc);
9958 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
9959 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
9960 panic("Irrecoverable Cheetah+ parity error.");
9961 }
9962
9963 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
9964 smp_processor_id(),
9965 (type & 0x1) ? 'I' : 'D',
9966 regs->tpc);
9967 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
9968 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
9969 }
9970
9971 struct sun4v_error_entry {
9972 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
9973 /*0x38*/u64 reserved_5;
9974 };
9975
9976 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9977 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9978 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
9979 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
9980
9981 static const char *sun4v_err_type_to_str(u8 type)
9982 {
9983 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
9984 }
9985
9986 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9987 - int cpu, const char *pfx, atomic_t *ocnt)
9988 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
9989 {
9990 u64 *raw_ptr = (u64 *) ent;
9991 u32 attrs;
9992 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
9993
9994 show_regs(regs);
9995
9996 - if ((cnt = atomic_read(ocnt)) != 0) {
9997 - atomic_set(ocnt, 0);
9998 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
9999 + atomic_set_unchecked(ocnt, 0);
10000 wmb();
10001 printk("%s: Queue overflowed %d times.\n",
10002 pfx, cnt);
10003 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
10004 */
10005 void sun4v_resum_overflow(struct pt_regs *regs)
10006 {
10007 - atomic_inc(&sun4v_resum_oflow_cnt);
10008 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10009 }
10010
10011 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10012 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10013 /* XXX Actually even this can make not that much sense. Perhaps
10014 * XXX we should just pull the plug and panic directly from here?
10015 */
10016 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10017 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10018 }
10019
10020 unsigned long sun4v_err_itlb_vaddr;
10021 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10022
10023 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10024 regs->tpc, tl);
10025 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10026 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10027 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10028 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10029 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10030 (void *) regs->u_regs[UREG_I7]);
10031 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10032 "pte[%lx] error[%lx]\n",
10033 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10034
10035 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10036 regs->tpc, tl);
10037 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10038 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10039 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10040 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10041 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10042 (void *) regs->u_regs[UREG_I7]);
10043 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10044 "pte[%lx] error[%lx]\n",
10045 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10046 fp = (unsigned long)sf->fp + STACK_BIAS;
10047 }
10048
10049 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10050 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10051 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10052 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10053 int index = tsk->curr_ret_stack;
10054 if (tsk->ret_stack && index >= graph) {
10055 pc = tsk->ret_stack[index - graph].ret;
10056 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10057 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10058 graph++;
10059 }
10060 }
10061 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10062 return (struct reg_window *) (fp + STACK_BIAS);
10063 }
10064
10065 +extern void gr_handle_kernel_exploit(void);
10066 +
10067 void die_if_kernel(char *str, struct pt_regs *regs)
10068 {
10069 static int die_counter;
10070 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10071 while (rw &&
10072 count++ < 30 &&
10073 kstack_valid(tp, (unsigned long) rw)) {
10074 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10075 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10076 (void *) rw->ins[7]);
10077
10078 rw = kernel_stack_up(rw);
10079 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10080 }
10081 user_instruction_dump ((unsigned int __user *) regs->tpc);
10082 }
10083 - if (regs->tstate & TSTATE_PRIV)
10084 + if (regs->tstate & TSTATE_PRIV) {
10085 + gr_handle_kernel_exploit();
10086 do_exit(SIGKILL);
10087 + }
10088 do_exit(SIGSEGV);
10089 }
10090 EXPORT_SYMBOL(die_if_kernel);
10091 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10092 index 8201c25e..072a2a7 100644
10093 --- a/arch/sparc/kernel/unaligned_64.c
10094 +++ b/arch/sparc/kernel/unaligned_64.c
10095 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10096 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10097
10098 if (__ratelimit(&ratelimit)) {
10099 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10100 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10101 regs->tpc, (void *) regs->tpc);
10102 }
10103 }
10104 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10105 index dbe119b..089c7c1 100644
10106 --- a/arch/sparc/lib/Makefile
10107 +++ b/arch/sparc/lib/Makefile
10108 @@ -2,7 +2,7 @@
10109 #
10110
10111 asflags-y := -ansi -DST_DIV0=0x02
10112 -ccflags-y := -Werror
10113 +#ccflags-y := -Werror
10114
10115 lib-$(CONFIG_SPARC32) += ashrdi3.o
10116 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10117 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10118 index 85c233d..68500e0 100644
10119 --- a/arch/sparc/lib/atomic_64.S
10120 +++ b/arch/sparc/lib/atomic_64.S
10121 @@ -17,7 +17,12 @@
10122 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10123 BACKOFF_SETUP(%o2)
10124 1: lduw [%o1], %g1
10125 - add %g1, %o0, %g7
10126 + addcc %g1, %o0, %g7
10127 +
10128 +#ifdef CONFIG_PAX_REFCOUNT
10129 + tvs %icc, 6
10130 +#endif
10131 +
10132 cas [%o1], %g1, %g7
10133 cmp %g1, %g7
10134 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10135 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10136 2: BACKOFF_SPIN(%o2, %o3, 1b)
10137 ENDPROC(atomic_add)
10138
10139 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10140 + BACKOFF_SETUP(%o2)
10141 +1: lduw [%o1], %g1
10142 + add %g1, %o0, %g7
10143 + cas [%o1], %g1, %g7
10144 + cmp %g1, %g7
10145 + bne,pn %icc, 2f
10146 + nop
10147 + retl
10148 + nop
10149 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10150 +ENDPROC(atomic_add_unchecked)
10151 +
10152 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10153 BACKOFF_SETUP(%o2)
10154 1: lduw [%o1], %g1
10155 - sub %g1, %o0, %g7
10156 + subcc %g1, %o0, %g7
10157 +
10158 +#ifdef CONFIG_PAX_REFCOUNT
10159 + tvs %icc, 6
10160 +#endif
10161 +
10162 cas [%o1], %g1, %g7
10163 cmp %g1, %g7
10164 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10165 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10166 2: BACKOFF_SPIN(%o2, %o3, 1b)
10167 ENDPROC(atomic_sub)
10168
10169 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10170 + BACKOFF_SETUP(%o2)
10171 +1: lduw [%o1], %g1
10172 + sub %g1, %o0, %g7
10173 + cas [%o1], %g1, %g7
10174 + cmp %g1, %g7
10175 + bne,pn %icc, 2f
10176 + nop
10177 + retl
10178 + nop
10179 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10180 +ENDPROC(atomic_sub_unchecked)
10181 +
10182 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10183 BACKOFF_SETUP(%o2)
10184 1: lduw [%o1], %g1
10185 - add %g1, %o0, %g7
10186 + addcc %g1, %o0, %g7
10187 +
10188 +#ifdef CONFIG_PAX_REFCOUNT
10189 + tvs %icc, 6
10190 +#endif
10191 +
10192 cas [%o1], %g1, %g7
10193 cmp %g1, %g7
10194 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10195 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10196 2: BACKOFF_SPIN(%o2, %o3, 1b)
10197 ENDPROC(atomic_add_ret)
10198
10199 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10200 + BACKOFF_SETUP(%o2)
10201 +1: lduw [%o1], %g1
10202 + addcc %g1, %o0, %g7
10203 + cas [%o1], %g1, %g7
10204 + cmp %g1, %g7
10205 + bne,pn %icc, 2f
10206 + add %g7, %o0, %g7
10207 + sra %g7, 0, %o0
10208 + retl
10209 + nop
10210 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10211 +ENDPROC(atomic_add_ret_unchecked)
10212 +
10213 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10214 BACKOFF_SETUP(%o2)
10215 1: lduw [%o1], %g1
10216 - sub %g1, %o0, %g7
10217 + subcc %g1, %o0, %g7
10218 +
10219 +#ifdef CONFIG_PAX_REFCOUNT
10220 + tvs %icc, 6
10221 +#endif
10222 +
10223 cas [%o1], %g1, %g7
10224 cmp %g1, %g7
10225 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10226 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10227 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10228 BACKOFF_SETUP(%o2)
10229 1: ldx [%o1], %g1
10230 - add %g1, %o0, %g7
10231 + addcc %g1, %o0, %g7
10232 +
10233 +#ifdef CONFIG_PAX_REFCOUNT
10234 + tvs %xcc, 6
10235 +#endif
10236 +
10237 casx [%o1], %g1, %g7
10238 cmp %g1, %g7
10239 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10240 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10241 2: BACKOFF_SPIN(%o2, %o3, 1b)
10242 ENDPROC(atomic64_add)
10243
10244 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10245 + BACKOFF_SETUP(%o2)
10246 +1: ldx [%o1], %g1
10247 + addcc %g1, %o0, %g7
10248 + casx [%o1], %g1, %g7
10249 + cmp %g1, %g7
10250 + bne,pn %xcc, 2f
10251 + nop
10252 + retl
10253 + nop
10254 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10255 +ENDPROC(atomic64_add_unchecked)
10256 +
10257 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10258 BACKOFF_SETUP(%o2)
10259 1: ldx [%o1], %g1
10260 - sub %g1, %o0, %g7
10261 + subcc %g1, %o0, %g7
10262 +
10263 +#ifdef CONFIG_PAX_REFCOUNT
10264 + tvs %xcc, 6
10265 +#endif
10266 +
10267 casx [%o1], %g1, %g7
10268 cmp %g1, %g7
10269 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10270 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10271 2: BACKOFF_SPIN(%o2, %o3, 1b)
10272 ENDPROC(atomic64_sub)
10273
10274 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10275 + BACKOFF_SETUP(%o2)
10276 +1: ldx [%o1], %g1
10277 + subcc %g1, %o0, %g7
10278 + casx [%o1], %g1, %g7
10279 + cmp %g1, %g7
10280 + bne,pn %xcc, 2f
10281 + nop
10282 + retl
10283 + nop
10284 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10285 +ENDPROC(atomic64_sub_unchecked)
10286 +
10287 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10288 BACKOFF_SETUP(%o2)
10289 1: ldx [%o1], %g1
10290 - add %g1, %o0, %g7
10291 + addcc %g1, %o0, %g7
10292 +
10293 +#ifdef CONFIG_PAX_REFCOUNT
10294 + tvs %xcc, 6
10295 +#endif
10296 +
10297 casx [%o1], %g1, %g7
10298 cmp %g1, %g7
10299 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10300 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10301 2: BACKOFF_SPIN(%o2, %o3, 1b)
10302 ENDPROC(atomic64_add_ret)
10303
10304 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10305 + BACKOFF_SETUP(%o2)
10306 +1: ldx [%o1], %g1
10307 + addcc %g1, %o0, %g7
10308 + casx [%o1], %g1, %g7
10309 + cmp %g1, %g7
10310 + bne,pn %xcc, 2f
10311 + add %g7, %o0, %g7
10312 + mov %g7, %o0
10313 + retl
10314 + nop
10315 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10316 +ENDPROC(atomic64_add_ret_unchecked)
10317 +
10318 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10319 BACKOFF_SETUP(%o2)
10320 1: ldx [%o1], %g1
10321 - sub %g1, %o0, %g7
10322 + subcc %g1, %o0, %g7
10323 +
10324 +#ifdef CONFIG_PAX_REFCOUNT
10325 + tvs %xcc, 6
10326 +#endif
10327 +
10328 casx [%o1], %g1, %g7
10329 cmp %g1, %g7
10330 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10331 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10332 index 323335b..ed85ea2 100644
10333 --- a/arch/sparc/lib/ksyms.c
10334 +++ b/arch/sparc/lib/ksyms.c
10335 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10336
10337 /* Atomic counter implementation. */
10338 EXPORT_SYMBOL(atomic_add);
10339 +EXPORT_SYMBOL(atomic_add_unchecked);
10340 EXPORT_SYMBOL(atomic_add_ret);
10341 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10342 EXPORT_SYMBOL(atomic_sub);
10343 +EXPORT_SYMBOL(atomic_sub_unchecked);
10344 EXPORT_SYMBOL(atomic_sub_ret);
10345 EXPORT_SYMBOL(atomic64_add);
10346 +EXPORT_SYMBOL(atomic64_add_unchecked);
10347 EXPORT_SYMBOL(atomic64_add_ret);
10348 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10349 EXPORT_SYMBOL(atomic64_sub);
10350 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10351 EXPORT_SYMBOL(atomic64_sub_ret);
10352 EXPORT_SYMBOL(atomic64_dec_if_positive);
10353
10354 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10355 index 30c3ecc..736f015 100644
10356 --- a/arch/sparc/mm/Makefile
10357 +++ b/arch/sparc/mm/Makefile
10358 @@ -2,7 +2,7 @@
10359 #
10360
10361 asflags-y := -ansi
10362 -ccflags-y := -Werror
10363 +#ccflags-y := -Werror
10364
10365 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10366 obj-y += fault_$(BITS).o
10367 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10368 index e98bfda..ea8d221 100644
10369 --- a/arch/sparc/mm/fault_32.c
10370 +++ b/arch/sparc/mm/fault_32.c
10371 @@ -21,6 +21,9 @@
10372 #include <linux/perf_event.h>
10373 #include <linux/interrupt.h>
10374 #include <linux/kdebug.h>
10375 +#include <linux/slab.h>
10376 +#include <linux/pagemap.h>
10377 +#include <linux/compiler.h>
10378
10379 #include <asm/page.h>
10380 #include <asm/pgtable.h>
10381 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10382 return safe_compute_effective_address(regs, insn);
10383 }
10384
10385 +#ifdef CONFIG_PAX_PAGEEXEC
10386 +#ifdef CONFIG_PAX_DLRESOLVE
10387 +static void pax_emuplt_close(struct vm_area_struct *vma)
10388 +{
10389 + vma->vm_mm->call_dl_resolve = 0UL;
10390 +}
10391 +
10392 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10393 +{
10394 + unsigned int *kaddr;
10395 +
10396 + vmf->page = alloc_page(GFP_HIGHUSER);
10397 + if (!vmf->page)
10398 + return VM_FAULT_OOM;
10399 +
10400 + kaddr = kmap(vmf->page);
10401 + memset(kaddr, 0, PAGE_SIZE);
10402 + kaddr[0] = 0x9DE3BFA8U; /* save */
10403 + flush_dcache_page(vmf->page);
10404 + kunmap(vmf->page);
10405 + return VM_FAULT_MAJOR;
10406 +}
10407 +
10408 +static const struct vm_operations_struct pax_vm_ops = {
10409 + .close = pax_emuplt_close,
10410 + .fault = pax_emuplt_fault
10411 +};
10412 +
10413 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10414 +{
10415 + int ret;
10416 +
10417 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10418 + vma->vm_mm = current->mm;
10419 + vma->vm_start = addr;
10420 + vma->vm_end = addr + PAGE_SIZE;
10421 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10422 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10423 + vma->vm_ops = &pax_vm_ops;
10424 +
10425 + ret = insert_vm_struct(current->mm, vma);
10426 + if (ret)
10427 + return ret;
10428 +
10429 + ++current->mm->total_vm;
10430 + return 0;
10431 +}
10432 +#endif
10433 +
10434 +/*
10435 + * PaX: decide what to do with offenders (regs->pc = fault address)
10436 + *
10437 + * returns 1 when task should be killed
10438 + * 2 when patched PLT trampoline was detected
10439 + * 3 when unpatched PLT trampoline was detected
10440 + */
10441 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10442 +{
10443 +
10444 +#ifdef CONFIG_PAX_EMUPLT
10445 + int err;
10446 +
10447 + do { /* PaX: patched PLT emulation #1 */
10448 + unsigned int sethi1, sethi2, jmpl;
10449 +
10450 + err = get_user(sethi1, (unsigned int *)regs->pc);
10451 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10452 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10453 +
10454 + if (err)
10455 + break;
10456 +
10457 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10458 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10459 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10460 + {
10461 + unsigned int addr;
10462 +
10463 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10464 + addr = regs->u_regs[UREG_G1];
10465 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10466 + regs->pc = addr;
10467 + regs->npc = addr+4;
10468 + return 2;
10469 + }
10470 + } while (0);
10471 +
10472 + do { /* PaX: patched PLT emulation #2 */
10473 + unsigned int ba;
10474 +
10475 + err = get_user(ba, (unsigned int *)regs->pc);
10476 +
10477 + if (err)
10478 + break;
10479 +
10480 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10481 + unsigned int addr;
10482 +
10483 + if ((ba & 0xFFC00000U) == 0x30800000U)
10484 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10485 + else
10486 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10487 + regs->pc = addr;
10488 + regs->npc = addr+4;
10489 + return 2;
10490 + }
10491 + } while (0);
10492 +
10493 + do { /* PaX: patched PLT emulation #3 */
10494 + unsigned int sethi, bajmpl, nop;
10495 +
10496 + err = get_user(sethi, (unsigned int *)regs->pc);
10497 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10498 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10499 +
10500 + if (err)
10501 + break;
10502 +
10503 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10504 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10505 + nop == 0x01000000U)
10506 + {
10507 + unsigned int addr;
10508 +
10509 + addr = (sethi & 0x003FFFFFU) << 10;
10510 + regs->u_regs[UREG_G1] = addr;
10511 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10512 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10513 + else
10514 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10515 + regs->pc = addr;
10516 + regs->npc = addr+4;
10517 + return 2;
10518 + }
10519 + } while (0);
10520 +
10521 + do { /* PaX: unpatched PLT emulation step 1 */
10522 + unsigned int sethi, ba, nop;
10523 +
10524 + err = get_user(sethi, (unsigned int *)regs->pc);
10525 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10526 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10527 +
10528 + if (err)
10529 + break;
10530 +
10531 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10532 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10533 + nop == 0x01000000U)
10534 + {
10535 + unsigned int addr, save, call;
10536 +
10537 + if ((ba & 0xFFC00000U) == 0x30800000U)
10538 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10539 + else
10540 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10541 +
10542 + err = get_user(save, (unsigned int *)addr);
10543 + err |= get_user(call, (unsigned int *)(addr+4));
10544 + err |= get_user(nop, (unsigned int *)(addr+8));
10545 + if (err)
10546 + break;
10547 +
10548 +#ifdef CONFIG_PAX_DLRESOLVE
10549 + if (save == 0x9DE3BFA8U &&
10550 + (call & 0xC0000000U) == 0x40000000U &&
10551 + nop == 0x01000000U)
10552 + {
10553 + struct vm_area_struct *vma;
10554 + unsigned long call_dl_resolve;
10555 +
10556 + down_read(&current->mm->mmap_sem);
10557 + call_dl_resolve = current->mm->call_dl_resolve;
10558 + up_read(&current->mm->mmap_sem);
10559 + if (likely(call_dl_resolve))
10560 + goto emulate;
10561 +
10562 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10563 +
10564 + down_write(&current->mm->mmap_sem);
10565 + if (current->mm->call_dl_resolve) {
10566 + call_dl_resolve = current->mm->call_dl_resolve;
10567 + up_write(&current->mm->mmap_sem);
10568 + if (vma)
10569 + kmem_cache_free(vm_area_cachep, vma);
10570 + goto emulate;
10571 + }
10572 +
10573 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10574 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10575 + up_write(&current->mm->mmap_sem);
10576 + if (vma)
10577 + kmem_cache_free(vm_area_cachep, vma);
10578 + return 1;
10579 + }
10580 +
10581 + if (pax_insert_vma(vma, call_dl_resolve)) {
10582 + up_write(&current->mm->mmap_sem);
10583 + kmem_cache_free(vm_area_cachep, vma);
10584 + return 1;
10585 + }
10586 +
10587 + current->mm->call_dl_resolve = call_dl_resolve;
10588 + up_write(&current->mm->mmap_sem);
10589 +
10590 +emulate:
10591 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10592 + regs->pc = call_dl_resolve;
10593 + regs->npc = addr+4;
10594 + return 3;
10595 + }
10596 +#endif
10597 +
10598 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10599 + if ((save & 0xFFC00000U) == 0x05000000U &&
10600 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10601 + nop == 0x01000000U)
10602 + {
10603 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10604 + regs->u_regs[UREG_G2] = addr + 4;
10605 + addr = (save & 0x003FFFFFU) << 10;
10606 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10607 + regs->pc = addr;
10608 + regs->npc = addr+4;
10609 + return 3;
10610 + }
10611 + }
10612 + } while (0);
10613 +
10614 + do { /* PaX: unpatched PLT emulation step 2 */
10615 + unsigned int save, call, nop;
10616 +
10617 + err = get_user(save, (unsigned int *)(regs->pc-4));
10618 + err |= get_user(call, (unsigned int *)regs->pc);
10619 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10620 + if (err)
10621 + break;
10622 +
10623 + if (save == 0x9DE3BFA8U &&
10624 + (call & 0xC0000000U) == 0x40000000U &&
10625 + nop == 0x01000000U)
10626 + {
10627 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10628 +
10629 + regs->u_regs[UREG_RETPC] = regs->pc;
10630 + regs->pc = dl_resolve;
10631 + regs->npc = dl_resolve+4;
10632 + return 3;
10633 + }
10634 + } while (0);
10635 +#endif
10636 +
10637 + return 1;
10638 +}
10639 +
10640 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10641 +{
10642 + unsigned long i;
10643 +
10644 + printk(KERN_ERR "PAX: bytes at PC: ");
10645 + for (i = 0; i < 8; i++) {
10646 + unsigned int c;
10647 + if (get_user(c, (unsigned int *)pc+i))
10648 + printk(KERN_CONT "???????? ");
10649 + else
10650 + printk(KERN_CONT "%08x ", c);
10651 + }
10652 + printk("\n");
10653 +}
10654 +#endif
10655 +
10656 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10657 int text_fault)
10658 {
10659 @@ -230,6 +504,24 @@ good_area:
10660 if (!(vma->vm_flags & VM_WRITE))
10661 goto bad_area;
10662 } else {
10663 +
10664 +#ifdef CONFIG_PAX_PAGEEXEC
10665 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10666 + up_read(&mm->mmap_sem);
10667 + switch (pax_handle_fetch_fault(regs)) {
10668 +
10669 +#ifdef CONFIG_PAX_EMUPLT
10670 + case 2:
10671 + case 3:
10672 + return;
10673 +#endif
10674 +
10675 + }
10676 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10677 + do_group_exit(SIGKILL);
10678 + }
10679 +#endif
10680 +
10681 /* Allow reads even for write-only mappings */
10682 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10683 goto bad_area;
10684 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10685 index 5062ff3..e0b75f3 100644
10686 --- a/arch/sparc/mm/fault_64.c
10687 +++ b/arch/sparc/mm/fault_64.c
10688 @@ -21,6 +21,9 @@
10689 #include <linux/kprobes.h>
10690 #include <linux/kdebug.h>
10691 #include <linux/percpu.h>
10692 +#include <linux/slab.h>
10693 +#include <linux/pagemap.h>
10694 +#include <linux/compiler.h>
10695
10696 #include <asm/page.h>
10697 #include <asm/pgtable.h>
10698 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10699 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10700 regs->tpc);
10701 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10702 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10703 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10704 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10705 dump_stack();
10706 unhandled_fault(regs->tpc, current, regs);
10707 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10708 show_regs(regs);
10709 }
10710
10711 +#ifdef CONFIG_PAX_PAGEEXEC
10712 +#ifdef CONFIG_PAX_DLRESOLVE
10713 +static void pax_emuplt_close(struct vm_area_struct *vma)
10714 +{
10715 + vma->vm_mm->call_dl_resolve = 0UL;
10716 +}
10717 +
10718 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10719 +{
10720 + unsigned int *kaddr;
10721 +
10722 + vmf->page = alloc_page(GFP_HIGHUSER);
10723 + if (!vmf->page)
10724 + return VM_FAULT_OOM;
10725 +
10726 + kaddr = kmap(vmf->page);
10727 + memset(kaddr, 0, PAGE_SIZE);
10728 + kaddr[0] = 0x9DE3BFA8U; /* save */
10729 + flush_dcache_page(vmf->page);
10730 + kunmap(vmf->page);
10731 + return VM_FAULT_MAJOR;
10732 +}
10733 +
10734 +static const struct vm_operations_struct pax_vm_ops = {
10735 + .close = pax_emuplt_close,
10736 + .fault = pax_emuplt_fault
10737 +};
10738 +
10739 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10740 +{
10741 + int ret;
10742 +
10743 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10744 + vma->vm_mm = current->mm;
10745 + vma->vm_start = addr;
10746 + vma->vm_end = addr + PAGE_SIZE;
10747 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10748 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10749 + vma->vm_ops = &pax_vm_ops;
10750 +
10751 + ret = insert_vm_struct(current->mm, vma);
10752 + if (ret)
10753 + return ret;
10754 +
10755 + ++current->mm->total_vm;
10756 + return 0;
10757 +}
10758 +#endif
10759 +
10760 +/*
10761 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10762 + *
10763 + * returns 1 when task should be killed
10764 + * 2 when patched PLT trampoline was detected
10765 + * 3 when unpatched PLT trampoline was detected
10766 + */
10767 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10768 +{
10769 +
10770 +#ifdef CONFIG_PAX_EMUPLT
10771 + int err;
10772 +
10773 + do { /* PaX: patched PLT emulation #1 */
10774 + unsigned int sethi1, sethi2, jmpl;
10775 +
10776 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10777 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10778 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10779 +
10780 + if (err)
10781 + break;
10782 +
10783 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10784 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10785 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10786 + {
10787 + unsigned long addr;
10788 +
10789 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10790 + addr = regs->u_regs[UREG_G1];
10791 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10792 +
10793 + if (test_thread_flag(TIF_32BIT))
10794 + addr &= 0xFFFFFFFFUL;
10795 +
10796 + regs->tpc = addr;
10797 + regs->tnpc = addr+4;
10798 + return 2;
10799 + }
10800 + } while (0);
10801 +
10802 + do { /* PaX: patched PLT emulation #2 */
10803 + unsigned int ba;
10804 +
10805 + err = get_user(ba, (unsigned int *)regs->tpc);
10806 +
10807 + if (err)
10808 + break;
10809 +
10810 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10811 + unsigned long addr;
10812 +
10813 + if ((ba & 0xFFC00000U) == 0x30800000U)
10814 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10815 + else
10816 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10817 +
10818 + if (test_thread_flag(TIF_32BIT))
10819 + addr &= 0xFFFFFFFFUL;
10820 +
10821 + regs->tpc = addr;
10822 + regs->tnpc = addr+4;
10823 + return 2;
10824 + }
10825 + } while (0);
10826 +
10827 + do { /* PaX: patched PLT emulation #3 */
10828 + unsigned int sethi, bajmpl, nop;
10829 +
10830 + err = get_user(sethi, (unsigned int *)regs->tpc);
10831 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10832 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10833 +
10834 + if (err)
10835 + break;
10836 +
10837 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10838 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10839 + nop == 0x01000000U)
10840 + {
10841 + unsigned long addr;
10842 +
10843 + addr = (sethi & 0x003FFFFFU) << 10;
10844 + regs->u_regs[UREG_G1] = addr;
10845 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10846 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10847 + else
10848 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10849 +
10850 + if (test_thread_flag(TIF_32BIT))
10851 + addr &= 0xFFFFFFFFUL;
10852 +
10853 + regs->tpc = addr;
10854 + regs->tnpc = addr+4;
10855 + return 2;
10856 + }
10857 + } while (0);
10858 +
10859 + do { /* PaX: patched PLT emulation #4 */
10860 + unsigned int sethi, mov1, call, mov2;
10861 +
10862 + err = get_user(sethi, (unsigned int *)regs->tpc);
10863 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10864 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10865 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10866 +
10867 + if (err)
10868 + break;
10869 +
10870 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10871 + mov1 == 0x8210000FU &&
10872 + (call & 0xC0000000U) == 0x40000000U &&
10873 + mov2 == 0x9E100001U)
10874 + {
10875 + unsigned long addr;
10876 +
10877 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10878 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10879 +
10880 + if (test_thread_flag(TIF_32BIT))
10881 + addr &= 0xFFFFFFFFUL;
10882 +
10883 + regs->tpc = addr;
10884 + regs->tnpc = addr+4;
10885 + return 2;
10886 + }
10887 + } while (0);
10888 +
10889 + do { /* PaX: patched PLT emulation #5 */
10890 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10891 +
10892 + err = get_user(sethi, (unsigned int *)regs->tpc);
10893 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10894 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10895 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10896 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10897 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10898 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10899 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10900 +
10901 + if (err)
10902 + break;
10903 +
10904 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10905 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10906 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10907 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10908 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10909 + sllx == 0x83287020U &&
10910 + jmpl == 0x81C04005U &&
10911 + nop == 0x01000000U)
10912 + {
10913 + unsigned long addr;
10914 +
10915 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10916 + regs->u_regs[UREG_G1] <<= 32;
10917 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10918 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10919 + regs->tpc = addr;
10920 + regs->tnpc = addr+4;
10921 + return 2;
10922 + }
10923 + } while (0);
10924 +
10925 + do { /* PaX: patched PLT emulation #6 */
10926 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10927 +
10928 + err = get_user(sethi, (unsigned int *)regs->tpc);
10929 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10930 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10931 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10932 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10933 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10934 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10935 +
10936 + if (err)
10937 + break;
10938 +
10939 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10940 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10941 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10942 + sllx == 0x83287020U &&
10943 + (or & 0xFFFFE000U) == 0x8A116000U &&
10944 + jmpl == 0x81C04005U &&
10945 + nop == 0x01000000U)
10946 + {
10947 + unsigned long addr;
10948 +
10949 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10950 + regs->u_regs[UREG_G1] <<= 32;
10951 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10952 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10953 + regs->tpc = addr;
10954 + regs->tnpc = addr+4;
10955 + return 2;
10956 + }
10957 + } while (0);
10958 +
10959 + do { /* PaX: unpatched PLT emulation step 1 */
10960 + unsigned int sethi, ba, nop;
10961 +
10962 + err = get_user(sethi, (unsigned int *)regs->tpc);
10963 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10964 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10965 +
10966 + if (err)
10967 + break;
10968 +
10969 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10970 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10971 + nop == 0x01000000U)
10972 + {
10973 + unsigned long addr;
10974 + unsigned int save, call;
10975 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10976 +
10977 + if ((ba & 0xFFC00000U) == 0x30800000U)
10978 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10979 + else
10980 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10981 +
10982 + if (test_thread_flag(TIF_32BIT))
10983 + addr &= 0xFFFFFFFFUL;
10984 +
10985 + err = get_user(save, (unsigned int *)addr);
10986 + err |= get_user(call, (unsigned int *)(addr+4));
10987 + err |= get_user(nop, (unsigned int *)(addr+8));
10988 + if (err)
10989 + break;
10990 +
10991 +#ifdef CONFIG_PAX_DLRESOLVE
10992 + if (save == 0x9DE3BFA8U &&
10993 + (call & 0xC0000000U) == 0x40000000U &&
10994 + nop == 0x01000000U)
10995 + {
10996 + struct vm_area_struct *vma;
10997 + unsigned long call_dl_resolve;
10998 +
10999 + down_read(&current->mm->mmap_sem);
11000 + call_dl_resolve = current->mm->call_dl_resolve;
11001 + up_read(&current->mm->mmap_sem);
11002 + if (likely(call_dl_resolve))
11003 + goto emulate;
11004 +
11005 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11006 +
11007 + down_write(&current->mm->mmap_sem);
11008 + if (current->mm->call_dl_resolve) {
11009 + call_dl_resolve = current->mm->call_dl_resolve;
11010 + up_write(&current->mm->mmap_sem);
11011 + if (vma)
11012 + kmem_cache_free(vm_area_cachep, vma);
11013 + goto emulate;
11014 + }
11015 +
11016 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11017 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11018 + up_write(&current->mm->mmap_sem);
11019 + if (vma)
11020 + kmem_cache_free(vm_area_cachep, vma);
11021 + return 1;
11022 + }
11023 +
11024 + if (pax_insert_vma(vma, call_dl_resolve)) {
11025 + up_write(&current->mm->mmap_sem);
11026 + kmem_cache_free(vm_area_cachep, vma);
11027 + return 1;
11028 + }
11029 +
11030 + current->mm->call_dl_resolve = call_dl_resolve;
11031 + up_write(&current->mm->mmap_sem);
11032 +
11033 +emulate:
11034 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11035 + regs->tpc = call_dl_resolve;
11036 + regs->tnpc = addr+4;
11037 + return 3;
11038 + }
11039 +#endif
11040 +
11041 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11042 + if ((save & 0xFFC00000U) == 0x05000000U &&
11043 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11044 + nop == 0x01000000U)
11045 + {
11046 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11047 + regs->u_regs[UREG_G2] = addr + 4;
11048 + addr = (save & 0x003FFFFFU) << 10;
11049 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11050 +
11051 + if (test_thread_flag(TIF_32BIT))
11052 + addr &= 0xFFFFFFFFUL;
11053 +
11054 + regs->tpc = addr;
11055 + regs->tnpc = addr+4;
11056 + return 3;
11057 + }
11058 +
11059 + /* PaX: 64-bit PLT stub */
11060 + err = get_user(sethi1, (unsigned int *)addr);
11061 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11062 + err |= get_user(or1, (unsigned int *)(addr+8));
11063 + err |= get_user(or2, (unsigned int *)(addr+12));
11064 + err |= get_user(sllx, (unsigned int *)(addr+16));
11065 + err |= get_user(add, (unsigned int *)(addr+20));
11066 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11067 + err |= get_user(nop, (unsigned int *)(addr+28));
11068 + if (err)
11069 + break;
11070 +
11071 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11072 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11073 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11074 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11075 + sllx == 0x89293020U &&
11076 + add == 0x8A010005U &&
11077 + jmpl == 0x89C14000U &&
11078 + nop == 0x01000000U)
11079 + {
11080 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11081 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11082 + regs->u_regs[UREG_G4] <<= 32;
11083 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11084 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11085 + regs->u_regs[UREG_G4] = addr + 24;
11086 + addr = regs->u_regs[UREG_G5];
11087 + regs->tpc = addr;
11088 + regs->tnpc = addr+4;
11089 + return 3;
11090 + }
11091 + }
11092 + } while (0);
11093 +
11094 +#ifdef CONFIG_PAX_DLRESOLVE
11095 + do { /* PaX: unpatched PLT emulation step 2 */
11096 + unsigned int save, call, nop;
11097 +
11098 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11099 + err |= get_user(call, (unsigned int *)regs->tpc);
11100 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11101 + if (err)
11102 + break;
11103 +
11104 + if (save == 0x9DE3BFA8U &&
11105 + (call & 0xC0000000U) == 0x40000000U &&
11106 + nop == 0x01000000U)
11107 + {
11108 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11109 +
11110 + if (test_thread_flag(TIF_32BIT))
11111 + dl_resolve &= 0xFFFFFFFFUL;
11112 +
11113 + regs->u_regs[UREG_RETPC] = regs->tpc;
11114 + regs->tpc = dl_resolve;
11115 + regs->tnpc = dl_resolve+4;
11116 + return 3;
11117 + }
11118 + } while (0);
11119 +#endif
11120 +
11121 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11122 + unsigned int sethi, ba, nop;
11123 +
11124 + err = get_user(sethi, (unsigned int *)regs->tpc);
11125 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11126 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11127 +
11128 + if (err)
11129 + break;
11130 +
11131 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11132 + (ba & 0xFFF00000U) == 0x30600000U &&
11133 + nop == 0x01000000U)
11134 + {
11135 + unsigned long addr;
11136 +
11137 + addr = (sethi & 0x003FFFFFU) << 10;
11138 + regs->u_regs[UREG_G1] = addr;
11139 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11140 +
11141 + if (test_thread_flag(TIF_32BIT))
11142 + addr &= 0xFFFFFFFFUL;
11143 +
11144 + regs->tpc = addr;
11145 + regs->tnpc = addr+4;
11146 + return 2;
11147 + }
11148 + } while (0);
11149 +
11150 +#endif
11151 +
11152 + return 1;
11153 +}
11154 +
11155 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11156 +{
11157 + unsigned long i;
11158 +
11159 + printk(KERN_ERR "PAX: bytes at PC: ");
11160 + for (i = 0; i < 8; i++) {
11161 + unsigned int c;
11162 + if (get_user(c, (unsigned int *)pc+i))
11163 + printk(KERN_CONT "???????? ");
11164 + else
11165 + printk(KERN_CONT "%08x ", c);
11166 + }
11167 + printk("\n");
11168 +}
11169 +#endif
11170 +
11171 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11172 {
11173 struct mm_struct *mm = current->mm;
11174 @@ -341,6 +804,29 @@ retry:
11175 if (!vma)
11176 goto bad_area;
11177
11178 +#ifdef CONFIG_PAX_PAGEEXEC
11179 + /* PaX: detect ITLB misses on non-exec pages */
11180 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11181 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11182 + {
11183 + if (address != regs->tpc)
11184 + goto good_area;
11185 +
11186 + up_read(&mm->mmap_sem);
11187 + switch (pax_handle_fetch_fault(regs)) {
11188 +
11189 +#ifdef CONFIG_PAX_EMUPLT
11190 + case 2:
11191 + case 3:
11192 + return;
11193 +#endif
11194 +
11195 + }
11196 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11197 + do_group_exit(SIGKILL);
11198 + }
11199 +#endif
11200 +
11201 /* Pure DTLB misses do not tell us whether the fault causing
11202 * load/store/atomic was a write or not, it only says that there
11203 * was no match. So in such a case we (carefully) read the
11204 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11205 index d2b5944..d878f3c 100644
11206 --- a/arch/sparc/mm/hugetlbpage.c
11207 +++ b/arch/sparc/mm/hugetlbpage.c
11208 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11209 unsigned long addr,
11210 unsigned long len,
11211 unsigned long pgoff,
11212 - unsigned long flags)
11213 + unsigned long flags,
11214 + unsigned long offset)
11215 {
11216 unsigned long task_size = TASK_SIZE;
11217 struct vm_unmapped_area_info info;
11218 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11219
11220 info.flags = 0;
11221 info.length = len;
11222 - info.low_limit = TASK_UNMAPPED_BASE;
11223 + info.low_limit = mm->mmap_base;
11224 info.high_limit = min(task_size, VA_EXCLUDE_START);
11225 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11226 info.align_offset = 0;
11227 + info.threadstack_offset = offset;
11228 addr = vm_unmapped_area(&info);
11229
11230 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11231 VM_BUG_ON(addr != -ENOMEM);
11232 info.low_limit = VA_EXCLUDE_END;
11233 +
11234 +#ifdef CONFIG_PAX_RANDMMAP
11235 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11236 + info.low_limit += mm->delta_mmap;
11237 +#endif
11238 +
11239 info.high_limit = task_size;
11240 addr = vm_unmapped_area(&info);
11241 }
11242 @@ -58,7 +66,8 @@ static unsigned long
11243 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11244 const unsigned long len,
11245 const unsigned long pgoff,
11246 - const unsigned long flags)
11247 + const unsigned long flags,
11248 + const unsigned long offset)
11249 {
11250 struct mm_struct *mm = current->mm;
11251 unsigned long addr = addr0;
11252 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11253 info.high_limit = mm->mmap_base;
11254 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11255 info.align_offset = 0;
11256 + info.threadstack_offset = offset;
11257 addr = vm_unmapped_area(&info);
11258
11259 /*
11260 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11261 VM_BUG_ON(addr != -ENOMEM);
11262 info.flags = 0;
11263 info.low_limit = TASK_UNMAPPED_BASE;
11264 +
11265 +#ifdef CONFIG_PAX_RANDMMAP
11266 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11267 + info.low_limit += mm->delta_mmap;
11268 +#endif
11269 +
11270 info.high_limit = STACK_TOP32;
11271 addr = vm_unmapped_area(&info);
11272 }
11273 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11274 struct mm_struct *mm = current->mm;
11275 struct vm_area_struct *vma;
11276 unsigned long task_size = TASK_SIZE;
11277 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11278
11279 if (test_thread_flag(TIF_32BIT))
11280 task_size = STACK_TOP32;
11281 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11282 return addr;
11283 }
11284
11285 +#ifdef CONFIG_PAX_RANDMMAP
11286 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11287 +#endif
11288 +
11289 if (addr) {
11290 addr = ALIGN(addr, HPAGE_SIZE);
11291 vma = find_vma(mm, addr);
11292 - if (task_size - len >= addr &&
11293 - (!vma || addr + len <= vma->vm_start))
11294 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11295 return addr;
11296 }
11297 if (mm->get_unmapped_area == arch_get_unmapped_area)
11298 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11299 - pgoff, flags);
11300 + pgoff, flags, offset);
11301 else
11302 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11303 - pgoff, flags);
11304 + pgoff, flags, offset);
11305 }
11306
11307 pte_t *huge_pte_alloc(struct mm_struct *mm,
11308 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11309 index ed82eda..0d80e77 100644
11310 --- a/arch/sparc/mm/init_64.c
11311 +++ b/arch/sparc/mm/init_64.c
11312 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11313 int num_kernel_image_mappings;
11314
11315 #ifdef CONFIG_DEBUG_DCFLUSH
11316 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11317 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11318 #ifdef CONFIG_SMP
11319 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11320 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11321 #endif
11322 #endif
11323
11324 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11325 {
11326 BUG_ON(tlb_type == hypervisor);
11327 #ifdef CONFIG_DEBUG_DCFLUSH
11328 - atomic_inc(&dcpage_flushes);
11329 + atomic_inc_unchecked(&dcpage_flushes);
11330 #endif
11331
11332 #ifdef DCACHE_ALIASING_POSSIBLE
11333 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11334
11335 #ifdef CONFIG_DEBUG_DCFLUSH
11336 seq_printf(m, "DCPageFlushes\t: %d\n",
11337 - atomic_read(&dcpage_flushes));
11338 + atomic_read_unchecked(&dcpage_flushes));
11339 #ifdef CONFIG_SMP
11340 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11341 - atomic_read(&dcpage_flushes_xcall));
11342 + atomic_read_unchecked(&dcpage_flushes_xcall));
11343 #endif /* CONFIG_SMP */
11344 #endif /* CONFIG_DEBUG_DCFLUSH */
11345 }
11346 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11347 index f4500c6..889656c 100644
11348 --- a/arch/tile/include/asm/atomic_64.h
11349 +++ b/arch/tile/include/asm/atomic_64.h
11350 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11351
11352 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11353
11354 +#define atomic64_read_unchecked(v) atomic64_read(v)
11355 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11356 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11357 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11358 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11359 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11360 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11361 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11362 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11363 +
11364 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11365 #define smp_mb__before_atomic_dec() smp_mb()
11366 #define smp_mb__after_atomic_dec() smp_mb()
11367 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11368 index a9a5299..0fce79e 100644
11369 --- a/arch/tile/include/asm/cache.h
11370 +++ b/arch/tile/include/asm/cache.h
11371 @@ -15,11 +15,12 @@
11372 #ifndef _ASM_TILE_CACHE_H
11373 #define _ASM_TILE_CACHE_H
11374
11375 +#include <linux/const.h>
11376 #include <arch/chip.h>
11377
11378 /* bytes per L1 data cache line */
11379 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11380 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11381 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11382
11383 /* bytes per L2 cache line */
11384 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11385 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11386 index e4d44bd..99927a3 100644
11387 --- a/arch/tile/include/asm/uaccess.h
11388 +++ b/arch/tile/include/asm/uaccess.h
11389 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11390 const void __user *from,
11391 unsigned long n)
11392 {
11393 - int sz = __compiletime_object_size(to);
11394 + size_t sz = __compiletime_object_size(to);
11395
11396 - if (likely(sz == -1 || sz >= n))
11397 + if (likely(sz == (size_t)-1 || sz >= n))
11398 n = _copy_from_user(to, from, n);
11399 else
11400 copy_from_user_overflow();
11401 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11402 index 650ccff..45fe2d6 100644
11403 --- a/arch/tile/mm/hugetlbpage.c
11404 +++ b/arch/tile/mm/hugetlbpage.c
11405 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11406 info.high_limit = TASK_SIZE;
11407 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11408 info.align_offset = 0;
11409 + info.threadstack_offset = 0;
11410 return vm_unmapped_area(&info);
11411 }
11412
11413 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11414 info.high_limit = current->mm->mmap_base;
11415 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11416 info.align_offset = 0;
11417 + info.threadstack_offset = 0;
11418 addr = vm_unmapped_area(&info);
11419
11420 /*
11421 diff --git a/arch/um/Makefile b/arch/um/Makefile
11422 index 133f7de..1d6f2f1 100644
11423 --- a/arch/um/Makefile
11424 +++ b/arch/um/Makefile
11425 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11426 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11427 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11428
11429 +ifdef CONSTIFY_PLUGIN
11430 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11431 +endif
11432 +
11433 #This will adjust *FLAGS accordingly to the platform.
11434 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11435
11436 diff --git a/arch/um/defconfig b/arch/um/defconfig
11437 index 08107a7..ab22afe 100644
11438 --- a/arch/um/defconfig
11439 +++ b/arch/um/defconfig
11440 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11441 CONFIG_X86_L1_CACHE_SHIFT=5
11442 CONFIG_X86_XADD=y
11443 CONFIG_X86_PPRO_FENCE=y
11444 -CONFIG_X86_WP_WORKS_OK=y
11445 CONFIG_X86_INVLPG=y
11446 CONFIG_X86_BSWAP=y
11447 CONFIG_X86_POPAD_OK=y
11448 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11449 index 19e1bdd..3665b77 100644
11450 --- a/arch/um/include/asm/cache.h
11451 +++ b/arch/um/include/asm/cache.h
11452 @@ -1,6 +1,7 @@
11453 #ifndef __UM_CACHE_H
11454 #define __UM_CACHE_H
11455
11456 +#include <linux/const.h>
11457
11458 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11459 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11460 @@ -12,6 +13,6 @@
11461 # define L1_CACHE_SHIFT 5
11462 #endif
11463
11464 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11465 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11466
11467 #endif
11468 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11469 index 2e0a6b1..a64d0f5 100644
11470 --- a/arch/um/include/asm/kmap_types.h
11471 +++ b/arch/um/include/asm/kmap_types.h
11472 @@ -8,6 +8,6 @@
11473
11474 /* No more #include "asm/arch/kmap_types.h" ! */
11475
11476 -#define KM_TYPE_NR 14
11477 +#define KM_TYPE_NR 15
11478
11479 #endif
11480 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11481 index 5ff53d9..5850cdf 100644
11482 --- a/arch/um/include/asm/page.h
11483 +++ b/arch/um/include/asm/page.h
11484 @@ -14,6 +14,9 @@
11485 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11486 #define PAGE_MASK (~(PAGE_SIZE-1))
11487
11488 +#define ktla_ktva(addr) (addr)
11489 +#define ktva_ktla(addr) (addr)
11490 +
11491 #ifndef __ASSEMBLY__
11492
11493 struct page;
11494 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11495 index 0032f92..cd151e0 100644
11496 --- a/arch/um/include/asm/pgtable-3level.h
11497 +++ b/arch/um/include/asm/pgtable-3level.h
11498 @@ -58,6 +58,7 @@
11499 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11500 #define pud_populate(mm, pud, pmd) \
11501 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11502 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11503
11504 #ifdef CONFIG_64BIT
11505 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11506 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11507 index bbcef52..6a2a483 100644
11508 --- a/arch/um/kernel/process.c
11509 +++ b/arch/um/kernel/process.c
11510 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11511 return 2;
11512 }
11513
11514 -/*
11515 - * Only x86 and x86_64 have an arch_align_stack().
11516 - * All other arches have "#define arch_align_stack(x) (x)"
11517 - * in their asm/system.h
11518 - * As this is included in UML from asm-um/system-generic.h,
11519 - * we can use it to behave as the subarch does.
11520 - */
11521 -#ifndef arch_align_stack
11522 -unsigned long arch_align_stack(unsigned long sp)
11523 -{
11524 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11525 - sp -= get_random_int() % 8192;
11526 - return sp & ~0xf;
11527 -}
11528 -#endif
11529 -
11530 unsigned long get_wchan(struct task_struct *p)
11531 {
11532 unsigned long stack_page, sp, ip;
11533 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11534 index ad8f795..2c7eec6 100644
11535 --- a/arch/unicore32/include/asm/cache.h
11536 +++ b/arch/unicore32/include/asm/cache.h
11537 @@ -12,8 +12,10 @@
11538 #ifndef __UNICORE_CACHE_H__
11539 #define __UNICORE_CACHE_H__
11540
11541 -#define L1_CACHE_SHIFT (5)
11542 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11543 +#include <linux/const.h>
11544 +
11545 +#define L1_CACHE_SHIFT 5
11546 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11547
11548 /*
11549 * Memory returned by kmalloc() may be used for DMA, so we must make
11550 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11551 index b32ebf9..5704f98 100644
11552 --- a/arch/x86/Kconfig
11553 +++ b/arch/x86/Kconfig
11554 @@ -248,7 +248,7 @@ config X86_HT
11555
11556 config X86_32_LAZY_GS
11557 def_bool y
11558 - depends on X86_32 && !CC_STACKPROTECTOR
11559 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11560
11561 config ARCH_HWEIGHT_CFLAGS
11562 string
11563 @@ -1088,6 +1088,7 @@ config MICROCODE_EARLY
11564
11565 config X86_MSR
11566 tristate "/dev/cpu/*/msr - Model-specific register support"
11567 + depends on !GRKERNSEC_KMEM
11568 ---help---
11569 This device gives privileged processes access to the x86
11570 Model-Specific Registers (MSRs). It is a character device with
11571 @@ -1111,7 +1112,7 @@ choice
11572
11573 config NOHIGHMEM
11574 bool "off"
11575 - depends on !X86_NUMAQ
11576 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11577 ---help---
11578 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11579 However, the address space of 32-bit x86 processors is only 4
11580 @@ -1148,7 +1149,7 @@ config NOHIGHMEM
11581
11582 config HIGHMEM4G
11583 bool "4GB"
11584 - depends on !X86_NUMAQ
11585 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11586 ---help---
11587 Select this if you have a 32-bit processor and between 1 and 4
11588 gigabytes of physical RAM.
11589 @@ -1201,7 +1202,7 @@ config PAGE_OFFSET
11590 hex
11591 default 0xB0000000 if VMSPLIT_3G_OPT
11592 default 0x80000000 if VMSPLIT_2G
11593 - default 0x78000000 if VMSPLIT_2G_OPT
11594 + default 0x70000000 if VMSPLIT_2G_OPT
11595 default 0x40000000 if VMSPLIT_1G
11596 default 0xC0000000
11597 depends on X86_32
11598 @@ -1599,6 +1600,7 @@ config SECCOMP
11599
11600 config CC_STACKPROTECTOR
11601 bool "Enable -fstack-protector buffer overflow detection"
11602 + depends on X86_64 || !PAX_MEMORY_UDEREF
11603 ---help---
11604 This option turns on the -fstack-protector GCC feature. This
11605 feature puts, at the beginning of functions, a canary value on
11606 @@ -1718,6 +1720,8 @@ config X86_NEED_RELOCS
11607 config PHYSICAL_ALIGN
11608 hex "Alignment value to which kernel should be aligned" if X86_32
11609 default "0x1000000"
11610 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11611 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11612 range 0x2000 0x1000000
11613 ---help---
11614 This value puts the alignment restrictions on physical address
11615 @@ -1793,9 +1797,10 @@ config DEBUG_HOTPLUG_CPU0
11616 If unsure, say N.
11617
11618 config COMPAT_VDSO
11619 - def_bool y
11620 + def_bool n
11621 prompt "Compat VDSO support"
11622 depends on X86_32 || IA32_EMULATION
11623 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11624 ---help---
11625 Map the 32-bit VDSO to the predictable old-style address too.
11626
11627 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11628 index c026cca..14657ae 100644
11629 --- a/arch/x86/Kconfig.cpu
11630 +++ b/arch/x86/Kconfig.cpu
11631 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11632
11633 config X86_F00F_BUG
11634 def_bool y
11635 - depends on M586MMX || M586TSC || M586 || M486
11636 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11637
11638 config X86_INVD_BUG
11639 def_bool y
11640 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11641
11642 config X86_ALIGNMENT_16
11643 def_bool y
11644 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11645 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11646
11647 config X86_INTEL_USERCOPY
11648 def_bool y
11649 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11650 # generates cmov.
11651 config X86_CMOV
11652 def_bool y
11653 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11654 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11655
11656 config X86_MINIMUM_CPU_FAMILY
11657 int
11658 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11659 index 78d91af..8ceb94b 100644
11660 --- a/arch/x86/Kconfig.debug
11661 +++ b/arch/x86/Kconfig.debug
11662 @@ -74,7 +74,7 @@ config X86_PTDUMP
11663 config DEBUG_RODATA
11664 bool "Write protect kernel read-only data structures"
11665 default y
11666 - depends on DEBUG_KERNEL
11667 + depends on DEBUG_KERNEL && BROKEN
11668 ---help---
11669 Mark the kernel read-only data as write-protected in the pagetables,
11670 in order to catch accidental (and incorrect) writes to such const
11671 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11672
11673 config DEBUG_SET_MODULE_RONX
11674 bool "Set loadable kernel module data as NX and text as RO"
11675 - depends on MODULES
11676 + depends on MODULES && BROKEN
11677 ---help---
11678 This option helps catch unintended modifications to loadable
11679 kernel module's text and read-only data. It also prevents execution
11680 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11681 index 07639c6..6f2c901 100644
11682 --- a/arch/x86/Makefile
11683 +++ b/arch/x86/Makefile
11684 @@ -54,6 +54,7 @@ else
11685 UTS_MACHINE := x86_64
11686 CHECKFLAGS += -D__x86_64__ -m64
11687
11688 + biarch := $(call cc-option,-m64)
11689 KBUILD_AFLAGS += -m64
11690 KBUILD_CFLAGS += -m64
11691
11692 @@ -241,3 +242,12 @@ define archhelp
11693 echo ' FDINITRD=file initrd for the booted kernel'
11694 echo ' kvmconfig - Enable additional options for guest kernel support'
11695 endef
11696 +
11697 +define OLD_LD
11698 +
11699 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11700 +*** Please upgrade your binutils to 2.18 or newer
11701 +endef
11702 +
11703 +archprepare:
11704 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11705 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11706 index 379814b..add62ce 100644
11707 --- a/arch/x86/boot/Makefile
11708 +++ b/arch/x86/boot/Makefile
11709 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
11710 $(call cc-option, -fno-stack-protector) \
11711 $(call cc-option, -mpreferred-stack-boundary=2)
11712 KBUILD_CFLAGS += $(call cc-option, -m32)
11713 +ifdef CONSTIFY_PLUGIN
11714 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11715 +endif
11716 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11717 GCOV_PROFILE := n
11718
11719 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11720 index 878e4b9..20537ab 100644
11721 --- a/arch/x86/boot/bitops.h
11722 +++ b/arch/x86/boot/bitops.h
11723 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11724 u8 v;
11725 const u32 *p = (const u32 *)addr;
11726
11727 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11728 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11729 return v;
11730 }
11731
11732 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11733
11734 static inline void set_bit(int nr, void *addr)
11735 {
11736 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11737 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11738 }
11739
11740 #endif /* BOOT_BITOPS_H */
11741 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11742 index 5b75319..331a4ca 100644
11743 --- a/arch/x86/boot/boot.h
11744 +++ b/arch/x86/boot/boot.h
11745 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11746 static inline u16 ds(void)
11747 {
11748 u16 seg;
11749 - asm("movw %%ds,%0" : "=rm" (seg));
11750 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11751 return seg;
11752 }
11753
11754 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11755 static inline int memcmp(const void *s1, const void *s2, size_t len)
11756 {
11757 u8 diff;
11758 - asm("repe; cmpsb; setnz %0"
11759 + asm volatile("repe; cmpsb; setnz %0"
11760 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11761 return diff;
11762 }
11763 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11764 index dcd90df..c830d7d 100644
11765 --- a/arch/x86/boot/compressed/Makefile
11766 +++ b/arch/x86/boot/compressed/Makefile
11767 @@ -15,6 +15,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
11768 KBUILD_CFLAGS += $(cflags-y)
11769 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11770 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11771 +ifdef CONSTIFY_PLUGIN
11772 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11773 +endif
11774
11775 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11776 GCOV_PROFILE := n
11777 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11778 index b7388a4..03844ec 100644
11779 --- a/arch/x86/boot/compressed/eboot.c
11780 +++ b/arch/x86/boot/compressed/eboot.c
11781 @@ -150,7 +150,6 @@ again:
11782 *addr = max_addr;
11783 }
11784
11785 -free_pool:
11786 efi_call_phys1(sys_table->boottime->free_pool, map);
11787
11788 fail:
11789 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11790 if (i == map_size / desc_size)
11791 status = EFI_NOT_FOUND;
11792
11793 -free_pool:
11794 efi_call_phys1(sys_table->boottime->free_pool, map);
11795 fail:
11796 return status;
11797 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11798 index a53440e..c3dbf1e 100644
11799 --- a/arch/x86/boot/compressed/efi_stub_32.S
11800 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11801 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11802 * parameter 2, ..., param n. To make things easy, we save the return
11803 * address of efi_call_phys in a global variable.
11804 */
11805 - popl %ecx
11806 - movl %ecx, saved_return_addr(%edx)
11807 - /* get the function pointer into ECX*/
11808 - popl %ecx
11809 - movl %ecx, efi_rt_function_ptr(%edx)
11810 + popl saved_return_addr(%edx)
11811 + popl efi_rt_function_ptr(%edx)
11812
11813 /*
11814 * 3. Call the physical function.
11815 */
11816 - call *%ecx
11817 + call *efi_rt_function_ptr(%edx)
11818
11819 /*
11820 * 4. Balance the stack. And because EAX contain the return value,
11821 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11822 1: popl %edx
11823 subl $1b, %edx
11824
11825 - movl efi_rt_function_ptr(%edx), %ecx
11826 - pushl %ecx
11827 + pushl efi_rt_function_ptr(%edx)
11828
11829 /*
11830 * 10. Push the saved return address onto the stack and return.
11831 */
11832 - movl saved_return_addr(%edx), %ecx
11833 - pushl %ecx
11834 - ret
11835 + jmpl *saved_return_addr(%edx)
11836 ENDPROC(efi_call_phys)
11837 .previous
11838
11839 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11840 index 1e3184f..0d11e2e 100644
11841 --- a/arch/x86/boot/compressed/head_32.S
11842 +++ b/arch/x86/boot/compressed/head_32.S
11843 @@ -118,7 +118,7 @@ preferred_addr:
11844 notl %eax
11845 andl %eax, %ebx
11846 #else
11847 - movl $LOAD_PHYSICAL_ADDR, %ebx
11848 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11849 #endif
11850
11851 /* Target address to relocate to for decompression */
11852 @@ -204,7 +204,7 @@ relocated:
11853 * and where it was actually loaded.
11854 */
11855 movl %ebp, %ebx
11856 - subl $LOAD_PHYSICAL_ADDR, %ebx
11857 + subl $____LOAD_PHYSICAL_ADDR, %ebx
11858 jz 2f /* Nothing to be done if loaded at compiled addr. */
11859 /*
11860 * Process relocations.
11861 @@ -212,8 +212,7 @@ relocated:
11862
11863 1: subl $4, %edi
11864 movl (%edi), %ecx
11865 - testl %ecx, %ecx
11866 - jz 2f
11867 + jecxz 2f
11868 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
11869 jmp 1b
11870 2:
11871 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11872 index 06e71c2..88a98264 100644
11873 --- a/arch/x86/boot/compressed/head_64.S
11874 +++ b/arch/x86/boot/compressed/head_64.S
11875 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11876 notl %eax
11877 andl %eax, %ebx
11878 #else
11879 - movl $LOAD_PHYSICAL_ADDR, %ebx
11880 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11881 #endif
11882
11883 /* Target address to relocate to for decompression */
11884 @@ -270,7 +270,7 @@ preferred_addr:
11885 notq %rax
11886 andq %rax, %rbp
11887 #else
11888 - movq $LOAD_PHYSICAL_ADDR, %rbp
11889 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11890 #endif
11891
11892 /* Target address to relocate to for decompression */
11893 @@ -361,8 +361,8 @@ gdt:
11894 .long gdt
11895 .word 0
11896 .quad 0x0000000000000000 /* NULL descriptor */
11897 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11898 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11899 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11900 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11901 .quad 0x0080890000000000 /* TS descriptor */
11902 .quad 0x0000000000000000 /* TS continued */
11903 gdt_end:
11904 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11905 index 0319c88..7c1931f 100644
11906 --- a/arch/x86/boot/compressed/misc.c
11907 +++ b/arch/x86/boot/compressed/misc.c
11908 @@ -307,7 +307,7 @@ static void parse_elf(void *output)
11909 case PT_LOAD:
11910 #ifdef CONFIG_RELOCATABLE
11911 dest = output;
11912 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11913 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11914 #else
11915 dest = (void *)(phdr->p_paddr);
11916 #endif
11917 @@ -358,7 +358,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11918 error("Destination address too large");
11919 #endif
11920 #ifndef CONFIG_RELOCATABLE
11921 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
11922 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
11923 error("Wrong destination address");
11924 #endif
11925
11926 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
11927 index 4d3ff03..e4972ff 100644
11928 --- a/arch/x86/boot/cpucheck.c
11929 +++ b/arch/x86/boot/cpucheck.c
11930 @@ -74,7 +74,7 @@ static int has_fpu(void)
11931 u16 fcw = -1, fsw = -1;
11932 u32 cr0;
11933
11934 - asm("movl %%cr0,%0" : "=r" (cr0));
11935 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
11936 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
11937 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
11938 asm volatile("movl %0,%%cr0" : : "r" (cr0));
11939 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
11940 {
11941 u32 f0, f1;
11942
11943 - asm("pushfl ; "
11944 + asm volatile("pushfl ; "
11945 "pushfl ; "
11946 "popl %0 ; "
11947 "movl %0,%1 ; "
11948 @@ -115,7 +115,7 @@ static void get_flags(void)
11949 set_bit(X86_FEATURE_FPU, cpu.flags);
11950
11951 if (has_eflag(X86_EFLAGS_ID)) {
11952 - asm("cpuid"
11953 + asm volatile("cpuid"
11954 : "=a" (max_intel_level),
11955 "=b" (cpu_vendor[0]),
11956 "=d" (cpu_vendor[1]),
11957 @@ -124,7 +124,7 @@ static void get_flags(void)
11958
11959 if (max_intel_level >= 0x00000001 &&
11960 max_intel_level <= 0x0000ffff) {
11961 - asm("cpuid"
11962 + asm volatile("cpuid"
11963 : "=a" (tfms),
11964 "=c" (cpu.flags[4]),
11965 "=d" (cpu.flags[0])
11966 @@ -136,7 +136,7 @@ static void get_flags(void)
11967 cpu.model += ((tfms >> 16) & 0xf) << 4;
11968 }
11969
11970 - asm("cpuid"
11971 + asm volatile("cpuid"
11972 : "=a" (max_amd_level)
11973 : "a" (0x80000000)
11974 : "ebx", "ecx", "edx");
11975 @@ -144,7 +144,7 @@ static void get_flags(void)
11976 if (max_amd_level >= 0x80000001 &&
11977 max_amd_level <= 0x8000ffff) {
11978 u32 eax = 0x80000001;
11979 - asm("cpuid"
11980 + asm volatile("cpuid"
11981 : "+a" (eax),
11982 "=c" (cpu.flags[6]),
11983 "=d" (cpu.flags[1])
11984 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11985 u32 ecx = MSR_K7_HWCR;
11986 u32 eax, edx;
11987
11988 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11989 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
11990 eax &= ~(1 << 15);
11991 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11992 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
11993
11994 get_flags(); /* Make sure it really did something */
11995 err = check_flags();
11996 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
11997 u32 ecx = MSR_VIA_FCR;
11998 u32 eax, edx;
11999
12000 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12001 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12002 eax |= (1<<1)|(1<<7);
12003 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12004 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12005
12006 set_bit(X86_FEATURE_CX8, cpu.flags);
12007 err = check_flags();
12008 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12009 u32 eax, edx;
12010 u32 level = 1;
12011
12012 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12013 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12014 - asm("cpuid"
12015 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12016 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12017 + asm volatile("cpuid"
12018 : "+a" (level), "=d" (cpu.flags[0])
12019 : : "ecx", "ebx");
12020 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12021 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12022
12023 err = check_flags();
12024 }
12025 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12026 index 9ec06a1..2c25e79 100644
12027 --- a/arch/x86/boot/header.S
12028 +++ b/arch/x86/boot/header.S
12029 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12030 # single linked list of
12031 # struct setup_data
12032
12033 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12034 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12035
12036 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12037 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12038 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12039 +#else
12040 #define VO_INIT_SIZE (VO__end - VO__text)
12041 +#endif
12042 #if ZO_INIT_SIZE > VO_INIT_SIZE
12043 #define INIT_SIZE ZO_INIT_SIZE
12044 #else
12045 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12046 index db75d07..8e6d0af 100644
12047 --- a/arch/x86/boot/memory.c
12048 +++ b/arch/x86/boot/memory.c
12049 @@ -19,7 +19,7 @@
12050
12051 static int detect_memory_e820(void)
12052 {
12053 - int count = 0;
12054 + unsigned int count = 0;
12055 struct biosregs ireg, oreg;
12056 struct e820entry *desc = boot_params.e820_map;
12057 static struct e820entry buf; /* static so it is zeroed */
12058 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12059 index 11e8c6e..fdbb1ed 100644
12060 --- a/arch/x86/boot/video-vesa.c
12061 +++ b/arch/x86/boot/video-vesa.c
12062 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12063
12064 boot_params.screen_info.vesapm_seg = oreg.es;
12065 boot_params.screen_info.vesapm_off = oreg.di;
12066 + boot_params.screen_info.vesapm_size = oreg.cx;
12067 }
12068
12069 /*
12070 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12071 index 43eda28..5ab5fdb 100644
12072 --- a/arch/x86/boot/video.c
12073 +++ b/arch/x86/boot/video.c
12074 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12075 static unsigned int get_entry(void)
12076 {
12077 char entry_buf[4];
12078 - int i, len = 0;
12079 + unsigned int i, len = 0;
12080 int key;
12081 unsigned int v;
12082
12083 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12084 index 9105655..5e37f27 100644
12085 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12086 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12087 @@ -8,6 +8,8 @@
12088 * including this sentence is retained in full.
12089 */
12090
12091 +#include <asm/alternative-asm.h>
12092 +
12093 .extern crypto_ft_tab
12094 .extern crypto_it_tab
12095 .extern crypto_fl_tab
12096 @@ -70,6 +72,8 @@
12097 je B192; \
12098 leaq 32(r9),r9;
12099
12100 +#define ret pax_force_retaddr 0, 1; ret
12101 +
12102 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12103 movq r1,r2; \
12104 movq r3,r4; \
12105 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12106 index 477e9d7..3ab339f 100644
12107 --- a/arch/x86/crypto/aesni-intel_asm.S
12108 +++ b/arch/x86/crypto/aesni-intel_asm.S
12109 @@ -31,6 +31,7 @@
12110
12111 #include <linux/linkage.h>
12112 #include <asm/inst.h>
12113 +#include <asm/alternative-asm.h>
12114
12115 #ifdef __x86_64__
12116 .data
12117 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
12118 pop %r14
12119 pop %r13
12120 pop %r12
12121 + pax_force_retaddr 0, 1
12122 ret
12123 ENDPROC(aesni_gcm_dec)
12124
12125 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
12126 pop %r14
12127 pop %r13
12128 pop %r12
12129 + pax_force_retaddr 0, 1
12130 ret
12131 ENDPROC(aesni_gcm_enc)
12132
12133 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12134 pxor %xmm1, %xmm0
12135 movaps %xmm0, (TKEYP)
12136 add $0x10, TKEYP
12137 + pax_force_retaddr_bts
12138 ret
12139 ENDPROC(_key_expansion_128)
12140 ENDPROC(_key_expansion_256a)
12141 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12142 shufps $0b01001110, %xmm2, %xmm1
12143 movaps %xmm1, 0x10(TKEYP)
12144 add $0x20, TKEYP
12145 + pax_force_retaddr_bts
12146 ret
12147 ENDPROC(_key_expansion_192a)
12148
12149 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12150
12151 movaps %xmm0, (TKEYP)
12152 add $0x10, TKEYP
12153 + pax_force_retaddr_bts
12154 ret
12155 ENDPROC(_key_expansion_192b)
12156
12157 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12158 pxor %xmm1, %xmm2
12159 movaps %xmm2, (TKEYP)
12160 add $0x10, TKEYP
12161 + pax_force_retaddr_bts
12162 ret
12163 ENDPROC(_key_expansion_256b)
12164
12165 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12166 #ifndef __x86_64__
12167 popl KEYP
12168 #endif
12169 + pax_force_retaddr 0, 1
12170 ret
12171 ENDPROC(aesni_set_key)
12172
12173 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12174 popl KLEN
12175 popl KEYP
12176 #endif
12177 + pax_force_retaddr 0, 1
12178 ret
12179 ENDPROC(aesni_enc)
12180
12181 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12182 AESENC KEY STATE
12183 movaps 0x70(TKEYP), KEY
12184 AESENCLAST KEY STATE
12185 + pax_force_retaddr_bts
12186 ret
12187 ENDPROC(_aesni_enc1)
12188
12189 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12190 AESENCLAST KEY STATE2
12191 AESENCLAST KEY STATE3
12192 AESENCLAST KEY STATE4
12193 + pax_force_retaddr_bts
12194 ret
12195 ENDPROC(_aesni_enc4)
12196
12197 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12198 popl KLEN
12199 popl KEYP
12200 #endif
12201 + pax_force_retaddr 0, 1
12202 ret
12203 ENDPROC(aesni_dec)
12204
12205 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12206 AESDEC KEY STATE
12207 movaps 0x70(TKEYP), KEY
12208 AESDECLAST KEY STATE
12209 + pax_force_retaddr_bts
12210 ret
12211 ENDPROC(_aesni_dec1)
12212
12213 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12214 AESDECLAST KEY STATE2
12215 AESDECLAST KEY STATE3
12216 AESDECLAST KEY STATE4
12217 + pax_force_retaddr_bts
12218 ret
12219 ENDPROC(_aesni_dec4)
12220
12221 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12222 popl KEYP
12223 popl LEN
12224 #endif
12225 + pax_force_retaddr 0, 1
12226 ret
12227 ENDPROC(aesni_ecb_enc)
12228
12229 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12230 popl KEYP
12231 popl LEN
12232 #endif
12233 + pax_force_retaddr 0, 1
12234 ret
12235 ENDPROC(aesni_ecb_dec)
12236
12237 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12238 popl LEN
12239 popl IVP
12240 #endif
12241 + pax_force_retaddr 0, 1
12242 ret
12243 ENDPROC(aesni_cbc_enc)
12244
12245 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12246 popl LEN
12247 popl IVP
12248 #endif
12249 + pax_force_retaddr 0, 1
12250 ret
12251 ENDPROC(aesni_cbc_dec)
12252
12253 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12254 mov $1, TCTR_LOW
12255 MOVQ_R64_XMM TCTR_LOW INC
12256 MOVQ_R64_XMM CTR TCTR_LOW
12257 + pax_force_retaddr_bts
12258 ret
12259 ENDPROC(_aesni_inc_init)
12260
12261 @@ -2579,6 +2598,7 @@ _aesni_inc:
12262 .Linc_low:
12263 movaps CTR, IV
12264 PSHUFB_XMM BSWAP_MASK IV
12265 + pax_force_retaddr_bts
12266 ret
12267 ENDPROC(_aesni_inc)
12268
12269 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12270 .Lctr_enc_ret:
12271 movups IV, (IVP)
12272 .Lctr_enc_just_ret:
12273 + pax_force_retaddr 0, 1
12274 ret
12275 ENDPROC(aesni_ctr_enc)
12276
12277 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12278 pxor INC, STATE4
12279 movdqu STATE4, 0x70(OUTP)
12280
12281 + pax_force_retaddr 0, 1
12282 ret
12283 ENDPROC(aesni_xts_crypt8)
12284
12285 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12286 index 246c670..4d1ed00 100644
12287 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12288 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12289 @@ -21,6 +21,7 @@
12290 */
12291
12292 #include <linux/linkage.h>
12293 +#include <asm/alternative-asm.h>
12294
12295 .file "blowfish-x86_64-asm.S"
12296 .text
12297 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12298 jnz .L__enc_xor;
12299
12300 write_block();
12301 + pax_force_retaddr 0, 1
12302 ret;
12303 .L__enc_xor:
12304 xor_block();
12305 + pax_force_retaddr 0, 1
12306 ret;
12307 ENDPROC(__blowfish_enc_blk)
12308
12309 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12310
12311 movq %r11, %rbp;
12312
12313 + pax_force_retaddr 0, 1
12314 ret;
12315 ENDPROC(blowfish_dec_blk)
12316
12317 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12318
12319 popq %rbx;
12320 popq %rbp;
12321 + pax_force_retaddr 0, 1
12322 ret;
12323
12324 .L__enc_xor4:
12325 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12326
12327 popq %rbx;
12328 popq %rbp;
12329 + pax_force_retaddr 0, 1
12330 ret;
12331 ENDPROC(__blowfish_enc_blk_4way)
12332
12333 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12334 popq %rbx;
12335 popq %rbp;
12336
12337 + pax_force_retaddr 0, 1
12338 ret;
12339 ENDPROC(blowfish_dec_blk_4way)
12340 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12341 index ce71f92..2dd5b1e 100644
12342 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12343 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12344 @@ -16,6 +16,7 @@
12345 */
12346
12347 #include <linux/linkage.h>
12348 +#include <asm/alternative-asm.h>
12349
12350 #define CAMELLIA_TABLE_BYTE_LEN 272
12351
12352 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12353 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12354 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12355 %rcx, (%r9));
12356 + pax_force_retaddr_bts
12357 ret;
12358 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12359
12360 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12361 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12362 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12363 %rax, (%r9));
12364 + pax_force_retaddr_bts
12365 ret;
12366 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12367
12368 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12369 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12370 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12371
12372 + pax_force_retaddr_bts
12373 ret;
12374
12375 .align 8
12376 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12377 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12378 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12379
12380 + pax_force_retaddr_bts
12381 ret;
12382
12383 .align 8
12384 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12385 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12386 %xmm8, %rsi);
12387
12388 + pax_force_retaddr 0, 1
12389 ret;
12390 ENDPROC(camellia_ecb_enc_16way)
12391
12392 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12393 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12394 %xmm8, %rsi);
12395
12396 + pax_force_retaddr 0, 1
12397 ret;
12398 ENDPROC(camellia_ecb_dec_16way)
12399
12400 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12401 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12402 %xmm8, %rsi);
12403
12404 + pax_force_retaddr 0, 1
12405 ret;
12406 ENDPROC(camellia_cbc_dec_16way)
12407
12408 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12409 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12410 %xmm8, %rsi);
12411
12412 + pax_force_retaddr 0, 1
12413 ret;
12414 ENDPROC(camellia_ctr_16way)
12415
12416 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12417 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12418 %xmm8, %rsi);
12419
12420 + pax_force_retaddr 0, 1
12421 ret;
12422 ENDPROC(camellia_xts_crypt_16way)
12423
12424 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12425 index 0e0b886..8fc756a 100644
12426 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12427 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12428 @@ -11,6 +11,7 @@
12429 */
12430
12431 #include <linux/linkage.h>
12432 +#include <asm/alternative-asm.h>
12433
12434 #define CAMELLIA_TABLE_BYTE_LEN 272
12435
12436 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12437 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12438 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12439 %rcx, (%r9));
12440 + pax_force_retaddr_bts
12441 ret;
12442 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12443
12444 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12445 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12446 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12447 %rax, (%r9));
12448 + pax_force_retaddr_bts
12449 ret;
12450 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12451
12452 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12453 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12454 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12455
12456 + pax_force_retaddr_bts
12457 ret;
12458
12459 .align 8
12460 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12461 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12462 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12463
12464 + pax_force_retaddr_bts
12465 ret;
12466
12467 .align 8
12468 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12469
12470 vzeroupper;
12471
12472 + pax_force_retaddr 0, 1
12473 ret;
12474 ENDPROC(camellia_ecb_enc_32way)
12475
12476 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12477
12478 vzeroupper;
12479
12480 + pax_force_retaddr 0, 1
12481 ret;
12482 ENDPROC(camellia_ecb_dec_32way)
12483
12484 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12485
12486 vzeroupper;
12487
12488 + pax_force_retaddr 0, 1
12489 ret;
12490 ENDPROC(camellia_cbc_dec_32way)
12491
12492 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12493
12494 vzeroupper;
12495
12496 + pax_force_retaddr 0, 1
12497 ret;
12498 ENDPROC(camellia_ctr_32way)
12499
12500 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12501
12502 vzeroupper;
12503
12504 + pax_force_retaddr 0, 1
12505 ret;
12506 ENDPROC(camellia_xts_crypt_32way)
12507
12508 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12509 index 310319c..ce174a4 100644
12510 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12511 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12512 @@ -21,6 +21,7 @@
12513 */
12514
12515 #include <linux/linkage.h>
12516 +#include <asm/alternative-asm.h>
12517
12518 .file "camellia-x86_64-asm_64.S"
12519 .text
12520 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12521 enc_outunpack(mov, RT1);
12522
12523 movq RRBP, %rbp;
12524 + pax_force_retaddr 0, 1
12525 ret;
12526
12527 .L__enc_xor:
12528 enc_outunpack(xor, RT1);
12529
12530 movq RRBP, %rbp;
12531 + pax_force_retaddr 0, 1
12532 ret;
12533 ENDPROC(__camellia_enc_blk)
12534
12535 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12536 dec_outunpack();
12537
12538 movq RRBP, %rbp;
12539 + pax_force_retaddr 0, 1
12540 ret;
12541 ENDPROC(camellia_dec_blk)
12542
12543 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12544
12545 movq RRBP, %rbp;
12546 popq %rbx;
12547 + pax_force_retaddr 0, 1
12548 ret;
12549
12550 .L__enc2_xor:
12551 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12552
12553 movq RRBP, %rbp;
12554 popq %rbx;
12555 + pax_force_retaddr 0, 1
12556 ret;
12557 ENDPROC(__camellia_enc_blk_2way)
12558
12559 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12560
12561 movq RRBP, %rbp;
12562 movq RXOR, %rbx;
12563 + pax_force_retaddr 0, 1
12564 ret;
12565 ENDPROC(camellia_dec_blk_2way)
12566 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12567 index c35fd5d..c1ee236 100644
12568 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12569 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12570 @@ -24,6 +24,7 @@
12571 */
12572
12573 #include <linux/linkage.h>
12574 +#include <asm/alternative-asm.h>
12575
12576 .file "cast5-avx-x86_64-asm_64.S"
12577
12578 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12579 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12580 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12581
12582 + pax_force_retaddr 0, 1
12583 ret;
12584 ENDPROC(__cast5_enc_blk16)
12585
12586 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12587 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12588 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12589
12590 + pax_force_retaddr 0, 1
12591 ret;
12592
12593 .L__skip_dec:
12594 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12595 vmovdqu RR4, (6*4*4)(%r11);
12596 vmovdqu RL4, (7*4*4)(%r11);
12597
12598 + pax_force_retaddr
12599 ret;
12600 ENDPROC(cast5_ecb_enc_16way)
12601
12602 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12603 vmovdqu RR4, (6*4*4)(%r11);
12604 vmovdqu RL4, (7*4*4)(%r11);
12605
12606 + pax_force_retaddr
12607 ret;
12608 ENDPROC(cast5_ecb_dec_16way)
12609
12610 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
12611
12612 popq %r12;
12613
12614 + pax_force_retaddr
12615 ret;
12616 ENDPROC(cast5_cbc_dec_16way)
12617
12618 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
12619
12620 popq %r12;
12621
12622 + pax_force_retaddr
12623 ret;
12624 ENDPROC(cast5_ctr_16way)
12625 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12626 index e3531f8..18ded3a 100644
12627 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12628 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
12629 @@ -24,6 +24,7 @@
12630 */
12631
12632 #include <linux/linkage.h>
12633 +#include <asm/alternative-asm.h>
12634 #include "glue_helper-asm-avx.S"
12635
12636 .file "cast6-avx-x86_64-asm_64.S"
12637 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
12638 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12639 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12640
12641 + pax_force_retaddr 0, 1
12642 ret;
12643 ENDPROC(__cast6_enc_blk8)
12644
12645 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
12646 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
12647 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
12648
12649 + pax_force_retaddr 0, 1
12650 ret;
12651 ENDPROC(__cast6_dec_blk8)
12652
12653 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
12654
12655 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12656
12657 + pax_force_retaddr
12658 ret;
12659 ENDPROC(cast6_ecb_enc_8way)
12660
12661 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
12662
12663 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12664
12665 + pax_force_retaddr
12666 ret;
12667 ENDPROC(cast6_ecb_dec_8way)
12668
12669 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
12670
12671 popq %r12;
12672
12673 + pax_force_retaddr
12674 ret;
12675 ENDPROC(cast6_cbc_dec_8way)
12676
12677 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
12678
12679 popq %r12;
12680
12681 + pax_force_retaddr
12682 ret;
12683 ENDPROC(cast6_ctr_8way)
12684
12685 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
12686 /* dst <= regs xor IVs(in dst) */
12687 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12688
12689 + pax_force_retaddr
12690 ret;
12691 ENDPROC(cast6_xts_enc_8way)
12692
12693 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
12694 /* dst <= regs xor IVs(in dst) */
12695 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12696
12697 + pax_force_retaddr
12698 ret;
12699 ENDPROC(cast6_xts_dec_8way)
12700 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12701 index dbc4339..3d868c5 100644
12702 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12703 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
12704 @@ -45,6 +45,7 @@
12705
12706 #include <asm/inst.h>
12707 #include <linux/linkage.h>
12708 +#include <asm/alternative-asm.h>
12709
12710 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
12711
12712 @@ -312,6 +313,7 @@ do_return:
12713 popq %rsi
12714 popq %rdi
12715 popq %rbx
12716 + pax_force_retaddr 0, 1
12717 ret
12718
12719 ################################################################
12720 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12721 index 586f41a..d02851e 100644
12722 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
12723 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
12724 @@ -18,6 +18,7 @@
12725
12726 #include <linux/linkage.h>
12727 #include <asm/inst.h>
12728 +#include <asm/alternative-asm.h>
12729
12730 .data
12731
12732 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
12733 psrlq $1, T2
12734 pxor T2, T1
12735 pxor T1, DATA
12736 + pax_force_retaddr
12737 ret
12738 ENDPROC(__clmul_gf128mul_ble)
12739
12740 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
12741 call __clmul_gf128mul_ble
12742 PSHUFB_XMM BSWAP DATA
12743 movups DATA, (%rdi)
12744 + pax_force_retaddr
12745 ret
12746 ENDPROC(clmul_ghash_mul)
12747
12748 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
12749 PSHUFB_XMM BSWAP DATA
12750 movups DATA, (%rdi)
12751 .Lupdate_just_ret:
12752 + pax_force_retaddr
12753 ret
12754 ENDPROC(clmul_ghash_update)
12755
12756 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
12757 pand .Lpoly, %xmm1
12758 pxor %xmm1, %xmm0
12759 movups %xmm0, (%rdi)
12760 + pax_force_retaddr
12761 ret
12762 ENDPROC(clmul_ghash_setkey)
12763 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12764 index 9279e0b..9270820 100644
12765 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
12766 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
12767 @@ -1,4 +1,5 @@
12768 #include <linux/linkage.h>
12769 +#include <asm/alternative-asm.h>
12770
12771 # enter salsa20_encrypt_bytes
12772 ENTRY(salsa20_encrypt_bytes)
12773 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
12774 add %r11,%rsp
12775 mov %rdi,%rax
12776 mov %rsi,%rdx
12777 + pax_force_retaddr 0, 1
12778 ret
12779 # bytesatleast65:
12780 ._bytesatleast65:
12781 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
12782 add %r11,%rsp
12783 mov %rdi,%rax
12784 mov %rsi,%rdx
12785 + pax_force_retaddr
12786 ret
12787 ENDPROC(salsa20_keysetup)
12788
12789 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
12790 add %r11,%rsp
12791 mov %rdi,%rax
12792 mov %rsi,%rdx
12793 + pax_force_retaddr
12794 ret
12795 ENDPROC(salsa20_ivsetup)
12796 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12797 index 2f202f4..d9164d6 100644
12798 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12799 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
12800 @@ -24,6 +24,7 @@
12801 */
12802
12803 #include <linux/linkage.h>
12804 +#include <asm/alternative-asm.h>
12805 #include "glue_helper-asm-avx.S"
12806
12807 .file "serpent-avx-x86_64-asm_64.S"
12808 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
12809 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12810 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12811
12812 + pax_force_retaddr
12813 ret;
12814 ENDPROC(__serpent_enc_blk8_avx)
12815
12816 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
12817 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12818 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12819
12820 + pax_force_retaddr
12821 ret;
12822 ENDPROC(__serpent_dec_blk8_avx)
12823
12824 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
12825
12826 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12827
12828 + pax_force_retaddr
12829 ret;
12830 ENDPROC(serpent_ecb_enc_8way_avx)
12831
12832 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
12833
12834 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12835
12836 + pax_force_retaddr
12837 ret;
12838 ENDPROC(serpent_ecb_dec_8way_avx)
12839
12840 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
12841
12842 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12843
12844 + pax_force_retaddr
12845 ret;
12846 ENDPROC(serpent_cbc_dec_8way_avx)
12847
12848 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
12849
12850 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12851
12852 + pax_force_retaddr
12853 ret;
12854 ENDPROC(serpent_ctr_8way_avx)
12855
12856 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
12857 /* dst <= regs xor IVs(in dst) */
12858 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12859
12860 + pax_force_retaddr
12861 ret;
12862 ENDPROC(serpent_xts_enc_8way_avx)
12863
12864 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
12865 /* dst <= regs xor IVs(in dst) */
12866 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
12867
12868 + pax_force_retaddr
12869 ret;
12870 ENDPROC(serpent_xts_dec_8way_avx)
12871 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
12872 index b222085..abd483c 100644
12873 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
12874 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
12875 @@ -15,6 +15,7 @@
12876 */
12877
12878 #include <linux/linkage.h>
12879 +#include <asm/alternative-asm.h>
12880 #include "glue_helper-asm-avx2.S"
12881
12882 .file "serpent-avx2-asm_64.S"
12883 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
12884 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12885 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12886
12887 + pax_force_retaddr
12888 ret;
12889 ENDPROC(__serpent_enc_blk16)
12890
12891 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
12892 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12893 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12894
12895 + pax_force_retaddr
12896 ret;
12897 ENDPROC(__serpent_dec_blk16)
12898
12899 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
12900
12901 vzeroupper;
12902
12903 + pax_force_retaddr
12904 ret;
12905 ENDPROC(serpent_ecb_enc_16way)
12906
12907 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
12908
12909 vzeroupper;
12910
12911 + pax_force_retaddr
12912 ret;
12913 ENDPROC(serpent_ecb_dec_16way)
12914
12915 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
12916
12917 vzeroupper;
12918
12919 + pax_force_retaddr
12920 ret;
12921 ENDPROC(serpent_cbc_dec_16way)
12922
12923 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
12924
12925 vzeroupper;
12926
12927 + pax_force_retaddr
12928 ret;
12929 ENDPROC(serpent_ctr_16way)
12930
12931 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
12932
12933 vzeroupper;
12934
12935 + pax_force_retaddr
12936 ret;
12937 ENDPROC(serpent_xts_enc_16way)
12938
12939 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
12940
12941 vzeroupper;
12942
12943 + pax_force_retaddr
12944 ret;
12945 ENDPROC(serpent_xts_dec_16way)
12946 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12947 index acc066c..1559cc4 100644
12948 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12949 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
12950 @@ -25,6 +25,7 @@
12951 */
12952
12953 #include <linux/linkage.h>
12954 +#include <asm/alternative-asm.h>
12955
12956 .file "serpent-sse2-x86_64-asm_64.S"
12957 .text
12958 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
12959 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12960 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12961
12962 + pax_force_retaddr
12963 ret;
12964
12965 .L__enc_xor8:
12966 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
12967 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
12968
12969 + pax_force_retaddr
12970 ret;
12971 ENDPROC(__serpent_enc_blk_8way)
12972
12973 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
12974 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
12975 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
12976
12977 + pax_force_retaddr
12978 ret;
12979 ENDPROC(serpent_dec_blk_8way)
12980 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
12981 index a410950..3356d42 100644
12982 --- a/arch/x86/crypto/sha1_ssse3_asm.S
12983 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
12984 @@ -29,6 +29,7 @@
12985 */
12986
12987 #include <linux/linkage.h>
12988 +#include <asm/alternative-asm.h>
12989
12990 #define CTX %rdi // arg1
12991 #define BUF %rsi // arg2
12992 @@ -104,6 +105,7 @@
12993 pop %r12
12994 pop %rbp
12995 pop %rbx
12996 + pax_force_retaddr 0, 1
12997 ret
12998
12999 ENDPROC(\name)
13000 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13001 index 642f156..4ab07b9 100644
13002 --- a/arch/x86/crypto/sha256-avx-asm.S
13003 +++ b/arch/x86/crypto/sha256-avx-asm.S
13004 @@ -49,6 +49,7 @@
13005
13006 #ifdef CONFIG_AS_AVX
13007 #include <linux/linkage.h>
13008 +#include <asm/alternative-asm.h>
13009
13010 ## assume buffers not aligned
13011 #define VMOVDQ vmovdqu
13012 @@ -460,6 +461,7 @@ done_hash:
13013 popq %r13
13014 popq %rbp
13015 popq %rbx
13016 + pax_force_retaddr 0, 1
13017 ret
13018 ENDPROC(sha256_transform_avx)
13019
13020 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13021 index 9e86944..2e7f95a 100644
13022 --- a/arch/x86/crypto/sha256-avx2-asm.S
13023 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13024 @@ -50,6 +50,7 @@
13025
13026 #ifdef CONFIG_AS_AVX2
13027 #include <linux/linkage.h>
13028 +#include <asm/alternative-asm.h>
13029
13030 ## assume buffers not aligned
13031 #define VMOVDQ vmovdqu
13032 @@ -720,6 +721,7 @@ done_hash:
13033 popq %r12
13034 popq %rbp
13035 popq %rbx
13036 + pax_force_retaddr 0, 1
13037 ret
13038 ENDPROC(sha256_transform_rorx)
13039
13040 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13041 index f833b74..c36ed14 100644
13042 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13043 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13044 @@ -47,6 +47,7 @@
13045 ########################################################################
13046
13047 #include <linux/linkage.h>
13048 +#include <asm/alternative-asm.h>
13049
13050 ## assume buffers not aligned
13051 #define MOVDQ movdqu
13052 @@ -471,6 +472,7 @@ done_hash:
13053 popq %rbp
13054 popq %rbx
13055
13056 + pax_force_retaddr 0, 1
13057 ret
13058 ENDPROC(sha256_transform_ssse3)
13059
13060 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13061 index 974dde9..4533d34 100644
13062 --- a/arch/x86/crypto/sha512-avx-asm.S
13063 +++ b/arch/x86/crypto/sha512-avx-asm.S
13064 @@ -49,6 +49,7 @@
13065
13066 #ifdef CONFIG_AS_AVX
13067 #include <linux/linkage.h>
13068 +#include <asm/alternative-asm.h>
13069
13070 .text
13071
13072 @@ -364,6 +365,7 @@ updateblock:
13073 mov frame_RSPSAVE(%rsp), %rsp
13074
13075 nowork:
13076 + pax_force_retaddr 0, 1
13077 ret
13078 ENDPROC(sha512_transform_avx)
13079
13080 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13081 index 568b961..061ef1d 100644
13082 --- a/arch/x86/crypto/sha512-avx2-asm.S
13083 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13084 @@ -51,6 +51,7 @@
13085
13086 #ifdef CONFIG_AS_AVX2
13087 #include <linux/linkage.h>
13088 +#include <asm/alternative-asm.h>
13089
13090 .text
13091
13092 @@ -678,6 +679,7 @@ done_hash:
13093
13094 # Restore Stack Pointer
13095 mov frame_RSPSAVE(%rsp), %rsp
13096 + pax_force_retaddr 0, 1
13097 ret
13098 ENDPROC(sha512_transform_rorx)
13099
13100 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13101 index fb56855..e23914f 100644
13102 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13103 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13104 @@ -48,6 +48,7 @@
13105 ########################################################################
13106
13107 #include <linux/linkage.h>
13108 +#include <asm/alternative-asm.h>
13109
13110 .text
13111
13112 @@ -363,6 +364,7 @@ updateblock:
13113 mov frame_RSPSAVE(%rsp), %rsp
13114
13115 nowork:
13116 + pax_force_retaddr 0, 1
13117 ret
13118 ENDPROC(sha512_transform_ssse3)
13119
13120 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13121 index 0505813..63b1d00 100644
13122 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13123 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13124 @@ -24,6 +24,7 @@
13125 */
13126
13127 #include <linux/linkage.h>
13128 +#include <asm/alternative-asm.h>
13129 #include "glue_helper-asm-avx.S"
13130
13131 .file "twofish-avx-x86_64-asm_64.S"
13132 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13133 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13134 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13135
13136 + pax_force_retaddr 0, 1
13137 ret;
13138 ENDPROC(__twofish_enc_blk8)
13139
13140 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13141 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13142 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13143
13144 + pax_force_retaddr 0, 1
13145 ret;
13146 ENDPROC(__twofish_dec_blk8)
13147
13148 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13149
13150 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13151
13152 + pax_force_retaddr 0, 1
13153 ret;
13154 ENDPROC(twofish_ecb_enc_8way)
13155
13156 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13157
13158 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13159
13160 + pax_force_retaddr 0, 1
13161 ret;
13162 ENDPROC(twofish_ecb_dec_8way)
13163
13164 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
13165
13166 popq %r12;
13167
13168 + pax_force_retaddr 0, 1
13169 ret;
13170 ENDPROC(twofish_cbc_dec_8way)
13171
13172 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
13173
13174 popq %r12;
13175
13176 + pax_force_retaddr 0, 1
13177 ret;
13178 ENDPROC(twofish_ctr_8way)
13179
13180 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13181 /* dst <= regs xor IVs(in dst) */
13182 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13183
13184 + pax_force_retaddr 0, 1
13185 ret;
13186 ENDPROC(twofish_xts_enc_8way)
13187
13188 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13189 /* dst <= regs xor IVs(in dst) */
13190 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13191
13192 + pax_force_retaddr 0, 1
13193 ret;
13194 ENDPROC(twofish_xts_dec_8way)
13195 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13196 index 1c3b7ce..b365c5e 100644
13197 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13198 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13199 @@ -21,6 +21,7 @@
13200 */
13201
13202 #include <linux/linkage.h>
13203 +#include <asm/alternative-asm.h>
13204
13205 .file "twofish-x86_64-asm-3way.S"
13206 .text
13207 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13208 popq %r13;
13209 popq %r14;
13210 popq %r15;
13211 + pax_force_retaddr 0, 1
13212 ret;
13213
13214 .L__enc_xor3:
13215 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13216 popq %r13;
13217 popq %r14;
13218 popq %r15;
13219 + pax_force_retaddr 0, 1
13220 ret;
13221 ENDPROC(__twofish_enc_blk_3way)
13222
13223 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13224 popq %r13;
13225 popq %r14;
13226 popq %r15;
13227 + pax_force_retaddr 0, 1
13228 ret;
13229 ENDPROC(twofish_dec_blk_3way)
13230 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13231 index a039d21..29e7615 100644
13232 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13233 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13234 @@ -22,6 +22,7 @@
13235
13236 #include <linux/linkage.h>
13237 #include <asm/asm-offsets.h>
13238 +#include <asm/alternative-asm.h>
13239
13240 #define a_offset 0
13241 #define b_offset 4
13242 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13243
13244 popq R1
13245 movq $1,%rax
13246 + pax_force_retaddr 0, 1
13247 ret
13248 ENDPROC(twofish_enc_blk)
13249
13250 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13251
13252 popq R1
13253 movq $1,%rax
13254 + pax_force_retaddr 0, 1
13255 ret
13256 ENDPROC(twofish_dec_blk)
13257 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13258 index bae3aba..c1788c1 100644
13259 --- a/arch/x86/ia32/ia32_aout.c
13260 +++ b/arch/x86/ia32/ia32_aout.c
13261 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13262 unsigned long dump_start, dump_size;
13263 struct user32 dump;
13264
13265 + memset(&dump, 0, sizeof(dump));
13266 +
13267 fs = get_fs();
13268 set_fs(KERNEL_DS);
13269 has_dumped = 1;
13270 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13271 index 665a730..8e7a67a 100644
13272 --- a/arch/x86/ia32/ia32_signal.c
13273 +++ b/arch/x86/ia32/ia32_signal.c
13274 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13275 sp -= frame_size;
13276 /* Align the stack pointer according to the i386 ABI,
13277 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13278 - sp = ((sp + 4) & -16ul) - 4;
13279 + sp = ((sp - 12) & -16ul) - 4;
13280 return (void __user *) sp;
13281 }
13282
13283 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13284 * These are actually not used anymore, but left because some
13285 * gdb versions depend on them as a marker.
13286 */
13287 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13288 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13289 } put_user_catch(err);
13290
13291 if (err)
13292 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13293 0xb8,
13294 __NR_ia32_rt_sigreturn,
13295 0x80cd,
13296 - 0,
13297 + 0
13298 };
13299
13300 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13301 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13302
13303 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13304 restorer = ksig->ka.sa.sa_restorer;
13305 + else if (current->mm->context.vdso)
13306 + /* Return stub is in 32bit vsyscall page */
13307 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13308 else
13309 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13310 - rt_sigreturn);
13311 + restorer = &frame->retcode;
13312 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13313
13314 /*
13315 * Not actually used anymore, but left because some gdb
13316 * versions need it.
13317 */
13318 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13319 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13320 } put_user_catch(err);
13321
13322 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13323 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13324 index 474dc1b..9297c58 100644
13325 --- a/arch/x86/ia32/ia32entry.S
13326 +++ b/arch/x86/ia32/ia32entry.S
13327 @@ -15,8 +15,10 @@
13328 #include <asm/irqflags.h>
13329 #include <asm/asm.h>
13330 #include <asm/smap.h>
13331 +#include <asm/pgtable.h>
13332 #include <linux/linkage.h>
13333 #include <linux/err.h>
13334 +#include <asm/alternative-asm.h>
13335
13336 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13337 #include <linux/elf-em.h>
13338 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13339 ENDPROC(native_irq_enable_sysexit)
13340 #endif
13341
13342 + .macro pax_enter_kernel_user
13343 + pax_set_fptr_mask
13344 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13345 + call pax_enter_kernel_user
13346 +#endif
13347 + .endm
13348 +
13349 + .macro pax_exit_kernel_user
13350 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13351 + call pax_exit_kernel_user
13352 +#endif
13353 +#ifdef CONFIG_PAX_RANDKSTACK
13354 + pushq %rax
13355 + pushq %r11
13356 + call pax_randomize_kstack
13357 + popq %r11
13358 + popq %rax
13359 +#endif
13360 + .endm
13361 +
13362 + .macro pax_erase_kstack
13363 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13364 + call pax_erase_kstack
13365 +#endif
13366 + .endm
13367 +
13368 /*
13369 * 32bit SYSENTER instruction entry.
13370 *
13371 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13372 CFI_REGISTER rsp,rbp
13373 SWAPGS_UNSAFE_STACK
13374 movq PER_CPU_VAR(kernel_stack), %rsp
13375 - addq $(KERNEL_STACK_OFFSET),%rsp
13376 - /*
13377 - * No need to follow this irqs on/off section: the syscall
13378 - * disabled irqs, here we enable it straight after entry:
13379 - */
13380 - ENABLE_INTERRUPTS(CLBR_NONE)
13381 movl %ebp,%ebp /* zero extension */
13382 pushq_cfi $__USER32_DS
13383 /*CFI_REL_OFFSET ss,0*/
13384 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13385 CFI_REL_OFFSET rsp,0
13386 pushfq_cfi
13387 /*CFI_REL_OFFSET rflags,0*/
13388 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13389 - CFI_REGISTER rip,r10
13390 + orl $X86_EFLAGS_IF,(%rsp)
13391 + GET_THREAD_INFO(%r11)
13392 + movl TI_sysenter_return(%r11), %r11d
13393 + CFI_REGISTER rip,r11
13394 pushq_cfi $__USER32_CS
13395 /*CFI_REL_OFFSET cs,0*/
13396 movl %eax, %eax
13397 - pushq_cfi %r10
13398 + pushq_cfi %r11
13399 CFI_REL_OFFSET rip,0
13400 pushq_cfi %rax
13401 cld
13402 SAVE_ARGS 0,1,0
13403 + pax_enter_kernel_user
13404 +
13405 +#ifdef CONFIG_PAX_RANDKSTACK
13406 + pax_erase_kstack
13407 +#endif
13408 +
13409 + /*
13410 + * No need to follow this irqs on/off section: the syscall
13411 + * disabled irqs, here we enable it straight after entry:
13412 + */
13413 + ENABLE_INTERRUPTS(CLBR_NONE)
13414 /* no need to do an access_ok check here because rbp has been
13415 32bit zero extended */
13416 +
13417 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13418 + addq pax_user_shadow_base,%rbp
13419 + ASM_PAX_OPEN_USERLAND
13420 +#endif
13421 +
13422 ASM_STAC
13423 1: movl (%rbp),%ebp
13424 _ASM_EXTABLE(1b,ia32_badarg)
13425 ASM_CLAC
13426 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13427 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13428 +
13429 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13430 + ASM_PAX_CLOSE_USERLAND
13431 +#endif
13432 +
13433 + GET_THREAD_INFO(%r11)
13434 + orl $TS_COMPAT,TI_status(%r11)
13435 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13436 CFI_REMEMBER_STATE
13437 jnz sysenter_tracesys
13438 cmpq $(IA32_NR_syscalls-1),%rax
13439 @@ -162,12 +209,15 @@ sysenter_do_call:
13440 sysenter_dispatch:
13441 call *ia32_sys_call_table(,%rax,8)
13442 movq %rax,RAX-ARGOFFSET(%rsp)
13443 + GET_THREAD_INFO(%r11)
13444 DISABLE_INTERRUPTS(CLBR_NONE)
13445 TRACE_IRQS_OFF
13446 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13447 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13448 jnz sysexit_audit
13449 sysexit_from_sys_call:
13450 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13451 + pax_exit_kernel_user
13452 + pax_erase_kstack
13453 + andl $~TS_COMPAT,TI_status(%r11)
13454 /* clear IF, that popfq doesn't enable interrupts early */
13455 andl $~0x200,EFLAGS-R11(%rsp)
13456 movl RIP-R11(%rsp),%edx /* User %eip */
13457 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13458 movl %eax,%esi /* 2nd arg: syscall number */
13459 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13460 call __audit_syscall_entry
13461 +
13462 + pax_erase_kstack
13463 +
13464 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13465 cmpq $(IA32_NR_syscalls-1),%rax
13466 ja ia32_badsys
13467 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13468 .endm
13469
13470 .macro auditsys_exit exit
13471 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13472 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13473 jnz ia32_ret_from_sys_call
13474 TRACE_IRQS_ON
13475 ENABLE_INTERRUPTS(CLBR_NONE)
13476 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13477 1: setbe %al /* 1 if error, 0 if not */
13478 movzbl %al,%edi /* zero-extend that into %edi */
13479 call __audit_syscall_exit
13480 + GET_THREAD_INFO(%r11)
13481 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13482 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13483 DISABLE_INTERRUPTS(CLBR_NONE)
13484 TRACE_IRQS_OFF
13485 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13486 + testl %edi,TI_flags(%r11)
13487 jz \exit
13488 CLEAR_RREGS -ARGOFFSET
13489 jmp int_with_check
13490 @@ -237,7 +291,7 @@ sysexit_audit:
13491
13492 sysenter_tracesys:
13493 #ifdef CONFIG_AUDITSYSCALL
13494 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13495 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13496 jz sysenter_auditsys
13497 #endif
13498 SAVE_REST
13499 @@ -249,6 +303,9 @@ sysenter_tracesys:
13500 RESTORE_REST
13501 cmpq $(IA32_NR_syscalls-1),%rax
13502 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13503 +
13504 + pax_erase_kstack
13505 +
13506 jmp sysenter_do_call
13507 CFI_ENDPROC
13508 ENDPROC(ia32_sysenter_target)
13509 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
13510 ENTRY(ia32_cstar_target)
13511 CFI_STARTPROC32 simple
13512 CFI_SIGNAL_FRAME
13513 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
13514 + CFI_DEF_CFA rsp,0
13515 CFI_REGISTER rip,rcx
13516 /*CFI_REGISTER rflags,r11*/
13517 SWAPGS_UNSAFE_STACK
13518 movl %esp,%r8d
13519 CFI_REGISTER rsp,r8
13520 movq PER_CPU_VAR(kernel_stack),%rsp
13521 + SAVE_ARGS 8*6,0,0
13522 + pax_enter_kernel_user
13523 +
13524 +#ifdef CONFIG_PAX_RANDKSTACK
13525 + pax_erase_kstack
13526 +#endif
13527 +
13528 /*
13529 * No need to follow this irqs on/off section: the syscall
13530 * disabled irqs and here we enable it straight after entry:
13531 */
13532 ENABLE_INTERRUPTS(CLBR_NONE)
13533 - SAVE_ARGS 8,0,0
13534 movl %eax,%eax /* zero extension */
13535 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
13536 movq %rcx,RIP-ARGOFFSET(%rsp)
13537 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
13538 /* no need to do an access_ok check here because r8 has been
13539 32bit zero extended */
13540 /* hardware stack frame is complete now */
13541 +
13542 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13543 + ASM_PAX_OPEN_USERLAND
13544 + movq pax_user_shadow_base,%r8
13545 + addq RSP-ARGOFFSET(%rsp),%r8
13546 +#endif
13547 +
13548 ASM_STAC
13549 1: movl (%r8),%r9d
13550 _ASM_EXTABLE(1b,ia32_badarg)
13551 ASM_CLAC
13552 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13553 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13554 +
13555 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13556 + ASM_PAX_CLOSE_USERLAND
13557 +#endif
13558 +
13559 + GET_THREAD_INFO(%r11)
13560 + orl $TS_COMPAT,TI_status(%r11)
13561 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13562 CFI_REMEMBER_STATE
13563 jnz cstar_tracesys
13564 cmpq $IA32_NR_syscalls-1,%rax
13565 @@ -319,12 +395,15 @@ cstar_do_call:
13566 cstar_dispatch:
13567 call *ia32_sys_call_table(,%rax,8)
13568 movq %rax,RAX-ARGOFFSET(%rsp)
13569 + GET_THREAD_INFO(%r11)
13570 DISABLE_INTERRUPTS(CLBR_NONE)
13571 TRACE_IRQS_OFF
13572 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13573 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13574 jnz sysretl_audit
13575 sysretl_from_sys_call:
13576 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13577 + pax_exit_kernel_user
13578 + pax_erase_kstack
13579 + andl $~TS_COMPAT,TI_status(%r11)
13580 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
13581 movl RIP-ARGOFFSET(%rsp),%ecx
13582 CFI_REGISTER rip,rcx
13583 @@ -352,7 +431,7 @@ sysretl_audit:
13584
13585 cstar_tracesys:
13586 #ifdef CONFIG_AUDITSYSCALL
13587 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13588 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13589 jz cstar_auditsys
13590 #endif
13591 xchgl %r9d,%ebp
13592 @@ -366,11 +445,19 @@ cstar_tracesys:
13593 xchgl %ebp,%r9d
13594 cmpq $(IA32_NR_syscalls-1),%rax
13595 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
13596 +
13597 + pax_erase_kstack
13598 +
13599 jmp cstar_do_call
13600 END(ia32_cstar_target)
13601
13602 ia32_badarg:
13603 ASM_CLAC
13604 +
13605 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13606 + ASM_PAX_CLOSE_USERLAND
13607 +#endif
13608 +
13609 movq $-EFAULT,%rax
13610 jmp ia32_sysret
13611 CFI_ENDPROC
13612 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
13613 CFI_REL_OFFSET rip,RIP-RIP
13614 PARAVIRT_ADJUST_EXCEPTION_FRAME
13615 SWAPGS
13616 - /*
13617 - * No need to follow this irqs on/off section: the syscall
13618 - * disabled irqs and here we enable it straight after entry:
13619 - */
13620 - ENABLE_INTERRUPTS(CLBR_NONE)
13621 movl %eax,%eax
13622 pushq_cfi %rax
13623 cld
13624 /* note the registers are not zero extended to the sf.
13625 this could be a problem. */
13626 SAVE_ARGS 0,1,0
13627 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13628 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13629 + pax_enter_kernel_user
13630 +
13631 +#ifdef CONFIG_PAX_RANDKSTACK
13632 + pax_erase_kstack
13633 +#endif
13634 +
13635 + /*
13636 + * No need to follow this irqs on/off section: the syscall
13637 + * disabled irqs and here we enable it straight after entry:
13638 + */
13639 + ENABLE_INTERRUPTS(CLBR_NONE)
13640 + GET_THREAD_INFO(%r11)
13641 + orl $TS_COMPAT,TI_status(%r11)
13642 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13643 jnz ia32_tracesys
13644 cmpq $(IA32_NR_syscalls-1),%rax
13645 ja ia32_badsys
13646 @@ -442,6 +536,9 @@ ia32_tracesys:
13647 RESTORE_REST
13648 cmpq $(IA32_NR_syscalls-1),%rax
13649 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
13650 +
13651 + pax_erase_kstack
13652 +
13653 jmp ia32_do_call
13654 END(ia32_syscall)
13655
13656 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
13657 index 8e0ceec..af13504 100644
13658 --- a/arch/x86/ia32/sys_ia32.c
13659 +++ b/arch/x86/ia32/sys_ia32.c
13660 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
13661 */
13662 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
13663 {
13664 - typeof(ubuf->st_uid) uid = 0;
13665 - typeof(ubuf->st_gid) gid = 0;
13666 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
13667 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
13668 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
13669 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
13670 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
13671 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
13672 index 372231c..a5aa1a1 100644
13673 --- a/arch/x86/include/asm/alternative-asm.h
13674 +++ b/arch/x86/include/asm/alternative-asm.h
13675 @@ -18,6 +18,45 @@
13676 .endm
13677 #endif
13678
13679 +#ifdef KERNEXEC_PLUGIN
13680 + .macro pax_force_retaddr_bts rip=0
13681 + btsq $63,\rip(%rsp)
13682 + .endm
13683 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
13684 + .macro pax_force_retaddr rip=0, reload=0
13685 + btsq $63,\rip(%rsp)
13686 + .endm
13687 + .macro pax_force_fptr ptr
13688 + btsq $63,\ptr
13689 + .endm
13690 + .macro pax_set_fptr_mask
13691 + .endm
13692 +#endif
13693 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
13694 + .macro pax_force_retaddr rip=0, reload=0
13695 + .if \reload
13696 + pax_set_fptr_mask
13697 + .endif
13698 + orq %r10,\rip(%rsp)
13699 + .endm
13700 + .macro pax_force_fptr ptr
13701 + orq %r10,\ptr
13702 + .endm
13703 + .macro pax_set_fptr_mask
13704 + movabs $0x8000000000000000,%r10
13705 + .endm
13706 +#endif
13707 +#else
13708 + .macro pax_force_retaddr rip=0, reload=0
13709 + .endm
13710 + .macro pax_force_fptr ptr
13711 + .endm
13712 + .macro pax_force_retaddr_bts rip=0
13713 + .endm
13714 + .macro pax_set_fptr_mask
13715 + .endm
13716 +#endif
13717 +
13718 .macro altinstruction_entry orig alt feature orig_len alt_len
13719 .long \orig - .
13720 .long \alt - .
13721 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
13722 index 58ed6d9..f1cbe58 100644
13723 --- a/arch/x86/include/asm/alternative.h
13724 +++ b/arch/x86/include/asm/alternative.h
13725 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13726 ".pushsection .discard,\"aw\",@progbits\n" \
13727 DISCARD_ENTRY(1) \
13728 ".popsection\n" \
13729 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13730 + ".pushsection .altinstr_replacement, \"a\"\n" \
13731 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
13732 ".popsection"
13733
13734 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
13735 DISCARD_ENTRY(1) \
13736 DISCARD_ENTRY(2) \
13737 ".popsection\n" \
13738 - ".pushsection .altinstr_replacement, \"ax\"\n" \
13739 + ".pushsection .altinstr_replacement, \"a\"\n" \
13740 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
13741 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
13742 ".popsection"
13743 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
13744 index f8119b5..7209d5b 100644
13745 --- a/arch/x86/include/asm/apic.h
13746 +++ b/arch/x86/include/asm/apic.h
13747 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
13748
13749 #ifdef CONFIG_X86_LOCAL_APIC
13750
13751 -extern unsigned int apic_verbosity;
13752 +extern int apic_verbosity;
13753 extern int local_apic_timer_c2_ok;
13754
13755 extern int disable_apic;
13756 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
13757 index 20370c6..a2eb9b0 100644
13758 --- a/arch/x86/include/asm/apm.h
13759 +++ b/arch/x86/include/asm/apm.h
13760 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
13761 __asm__ __volatile__(APM_DO_ZERO_SEGS
13762 "pushl %%edi\n\t"
13763 "pushl %%ebp\n\t"
13764 - "lcall *%%cs:apm_bios_entry\n\t"
13765 + "lcall *%%ss:apm_bios_entry\n\t"
13766 "setc %%al\n\t"
13767 "popl %%ebp\n\t"
13768 "popl %%edi\n\t"
13769 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
13770 __asm__ __volatile__(APM_DO_ZERO_SEGS
13771 "pushl %%edi\n\t"
13772 "pushl %%ebp\n\t"
13773 - "lcall *%%cs:apm_bios_entry\n\t"
13774 + "lcall *%%ss:apm_bios_entry\n\t"
13775 "setc %%bl\n\t"
13776 "popl %%ebp\n\t"
13777 "popl %%edi\n\t"
13778 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
13779 index 722aa3b..3a0bb27 100644
13780 --- a/arch/x86/include/asm/atomic.h
13781 +++ b/arch/x86/include/asm/atomic.h
13782 @@ -22,7 +22,18 @@
13783 */
13784 static inline int atomic_read(const atomic_t *v)
13785 {
13786 - return (*(volatile int *)&(v)->counter);
13787 + return (*(volatile const int *)&(v)->counter);
13788 +}
13789 +
13790 +/**
13791 + * atomic_read_unchecked - read atomic variable
13792 + * @v: pointer of type atomic_unchecked_t
13793 + *
13794 + * Atomically reads the value of @v.
13795 + */
13796 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
13797 +{
13798 + return (*(volatile const int *)&(v)->counter);
13799 }
13800
13801 /**
13802 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
13803 }
13804
13805 /**
13806 + * atomic_set_unchecked - set atomic variable
13807 + * @v: pointer of type atomic_unchecked_t
13808 + * @i: required value
13809 + *
13810 + * Atomically sets the value of @v to @i.
13811 + */
13812 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
13813 +{
13814 + v->counter = i;
13815 +}
13816 +
13817 +/**
13818 * atomic_add - add integer to atomic variable
13819 * @i: integer value to add
13820 * @v: pointer of type atomic_t
13821 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
13822 */
13823 static inline void atomic_add(int i, atomic_t *v)
13824 {
13825 - asm volatile(LOCK_PREFIX "addl %1,%0"
13826 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13827 +
13828 +#ifdef CONFIG_PAX_REFCOUNT
13829 + "jno 0f\n"
13830 + LOCK_PREFIX "subl %1,%0\n"
13831 + "int $4\n0:\n"
13832 + _ASM_EXTABLE(0b, 0b)
13833 +#endif
13834 +
13835 + : "+m" (v->counter)
13836 + : "ir" (i));
13837 +}
13838 +
13839 +/**
13840 + * atomic_add_unchecked - add integer to atomic variable
13841 + * @i: integer value to add
13842 + * @v: pointer of type atomic_unchecked_t
13843 + *
13844 + * Atomically adds @i to @v.
13845 + */
13846 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
13847 +{
13848 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
13849 : "+m" (v->counter)
13850 : "ir" (i));
13851 }
13852 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
13853 */
13854 static inline void atomic_sub(int i, atomic_t *v)
13855 {
13856 - asm volatile(LOCK_PREFIX "subl %1,%0"
13857 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13858 +
13859 +#ifdef CONFIG_PAX_REFCOUNT
13860 + "jno 0f\n"
13861 + LOCK_PREFIX "addl %1,%0\n"
13862 + "int $4\n0:\n"
13863 + _ASM_EXTABLE(0b, 0b)
13864 +#endif
13865 +
13866 + : "+m" (v->counter)
13867 + : "ir" (i));
13868 +}
13869 +
13870 +/**
13871 + * atomic_sub_unchecked - subtract integer from atomic variable
13872 + * @i: integer value to subtract
13873 + * @v: pointer of type atomic_unchecked_t
13874 + *
13875 + * Atomically subtracts @i from @v.
13876 + */
13877 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
13878 +{
13879 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
13880 : "+m" (v->counter)
13881 : "ir" (i));
13882 }
13883 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13884 {
13885 unsigned char c;
13886
13887 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
13888 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
13889 +
13890 +#ifdef CONFIG_PAX_REFCOUNT
13891 + "jno 0f\n"
13892 + LOCK_PREFIX "addl %2,%0\n"
13893 + "int $4\n0:\n"
13894 + _ASM_EXTABLE(0b, 0b)
13895 +#endif
13896 +
13897 + "sete %1\n"
13898 : "+m" (v->counter), "=qm" (c)
13899 : "ir" (i) : "memory");
13900 return c;
13901 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
13902 */
13903 static inline void atomic_inc(atomic_t *v)
13904 {
13905 - asm volatile(LOCK_PREFIX "incl %0"
13906 + asm volatile(LOCK_PREFIX "incl %0\n"
13907 +
13908 +#ifdef CONFIG_PAX_REFCOUNT
13909 + "jno 0f\n"
13910 + LOCK_PREFIX "decl %0\n"
13911 + "int $4\n0:\n"
13912 + _ASM_EXTABLE(0b, 0b)
13913 +#endif
13914 +
13915 + : "+m" (v->counter));
13916 +}
13917 +
13918 +/**
13919 + * atomic_inc_unchecked - increment atomic variable
13920 + * @v: pointer of type atomic_unchecked_t
13921 + *
13922 + * Atomically increments @v by 1.
13923 + */
13924 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
13925 +{
13926 + asm volatile(LOCK_PREFIX "incl %0\n"
13927 : "+m" (v->counter));
13928 }
13929
13930 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
13931 */
13932 static inline void atomic_dec(atomic_t *v)
13933 {
13934 - asm volatile(LOCK_PREFIX "decl %0"
13935 + asm volatile(LOCK_PREFIX "decl %0\n"
13936 +
13937 +#ifdef CONFIG_PAX_REFCOUNT
13938 + "jno 0f\n"
13939 + LOCK_PREFIX "incl %0\n"
13940 + "int $4\n0:\n"
13941 + _ASM_EXTABLE(0b, 0b)
13942 +#endif
13943 +
13944 + : "+m" (v->counter));
13945 +}
13946 +
13947 +/**
13948 + * atomic_dec_unchecked - decrement atomic variable
13949 + * @v: pointer of type atomic_unchecked_t
13950 + *
13951 + * Atomically decrements @v by 1.
13952 + */
13953 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13954 +{
13955 + asm volatile(LOCK_PREFIX "decl %0\n"
13956 : "+m" (v->counter));
13957 }
13958
13959 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13960 {
13961 unsigned char c;
13962
13963 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13964 + asm volatile(LOCK_PREFIX "decl %0\n"
13965 +
13966 +#ifdef CONFIG_PAX_REFCOUNT
13967 + "jno 0f\n"
13968 + LOCK_PREFIX "incl %0\n"
13969 + "int $4\n0:\n"
13970 + _ASM_EXTABLE(0b, 0b)
13971 +#endif
13972 +
13973 + "sete %1\n"
13974 : "+m" (v->counter), "=qm" (c)
13975 : : "memory");
13976 return c != 0;
13977 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13978 {
13979 unsigned char c;
13980
13981 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13982 + asm volatile(LOCK_PREFIX "incl %0\n"
13983 +
13984 +#ifdef CONFIG_PAX_REFCOUNT
13985 + "jno 0f\n"
13986 + LOCK_PREFIX "decl %0\n"
13987 + "int $4\n0:\n"
13988 + _ASM_EXTABLE(0b, 0b)
13989 +#endif
13990 +
13991 + "sete %1\n"
13992 + : "+m" (v->counter), "=qm" (c)
13993 + : : "memory");
13994 + return c != 0;
13995 +}
13996 +
13997 +/**
13998 + * atomic_inc_and_test_unchecked - increment and test
13999 + * @v: pointer of type atomic_unchecked_t
14000 + *
14001 + * Atomically increments @v by 1
14002 + * and returns true if the result is zero, or false for all
14003 + * other cases.
14004 + */
14005 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14006 +{
14007 + unsigned char c;
14008 +
14009 + asm volatile(LOCK_PREFIX "incl %0\n"
14010 + "sete %1\n"
14011 : "+m" (v->counter), "=qm" (c)
14012 : : "memory");
14013 return c != 0;
14014 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14015 {
14016 unsigned char c;
14017
14018 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14019 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14020 +
14021 +#ifdef CONFIG_PAX_REFCOUNT
14022 + "jno 0f\n"
14023 + LOCK_PREFIX "subl %2,%0\n"
14024 + "int $4\n0:\n"
14025 + _ASM_EXTABLE(0b, 0b)
14026 +#endif
14027 +
14028 + "sets %1\n"
14029 : "+m" (v->counter), "=qm" (c)
14030 : "ir" (i) : "memory");
14031 return c;
14032 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14033 */
14034 static inline int atomic_add_return(int i, atomic_t *v)
14035 {
14036 + return i + xadd_check_overflow(&v->counter, i);
14037 +}
14038 +
14039 +/**
14040 + * atomic_add_return_unchecked - add integer and return
14041 + * @i: integer value to add
14042 + * @v: pointer of type atomic_unchecked_t
14043 + *
14044 + * Atomically adds @i to @v and returns @i + @v
14045 + */
14046 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14047 +{
14048 return i + xadd(&v->counter, i);
14049 }
14050
14051 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14052 }
14053
14054 #define atomic_inc_return(v) (atomic_add_return(1, v))
14055 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14056 +{
14057 + return atomic_add_return_unchecked(1, v);
14058 +}
14059 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14060
14061 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14062 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14063 return cmpxchg(&v->counter, old, new);
14064 }
14065
14066 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14067 +{
14068 + return cmpxchg(&v->counter, old, new);
14069 +}
14070 +
14071 static inline int atomic_xchg(atomic_t *v, int new)
14072 {
14073 return xchg(&v->counter, new);
14074 }
14075
14076 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14077 +{
14078 + return xchg(&v->counter, new);
14079 +}
14080 +
14081 /**
14082 * __atomic_add_unless - add unless the number is already a given value
14083 * @v: pointer of type atomic_t
14084 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
14085 */
14086 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14087 {
14088 - int c, old;
14089 + int c, old, new;
14090 c = atomic_read(v);
14091 for (;;) {
14092 - if (unlikely(c == (u)))
14093 + if (unlikely(c == u))
14094 break;
14095 - old = atomic_cmpxchg((v), c, c + (a));
14096 +
14097 + asm volatile("addl %2,%0\n"
14098 +
14099 +#ifdef CONFIG_PAX_REFCOUNT
14100 + "jno 0f\n"
14101 + "subl %2,%0\n"
14102 + "int $4\n0:\n"
14103 + _ASM_EXTABLE(0b, 0b)
14104 +#endif
14105 +
14106 + : "=r" (new)
14107 + : "0" (c), "ir" (a));
14108 +
14109 + old = atomic_cmpxchg(v, c, new);
14110 if (likely(old == c))
14111 break;
14112 c = old;
14113 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14114 }
14115
14116 /**
14117 + * atomic_inc_not_zero_hint - increment if not null
14118 + * @v: pointer of type atomic_t
14119 + * @hint: probable value of the atomic before the increment
14120 + *
14121 + * This version of atomic_inc_not_zero() gives a hint of probable
14122 + * value of the atomic. This helps processor to not read the memory
14123 + * before doing the atomic read/modify/write cycle, lowering
14124 + * number of bus transactions on some arches.
14125 + *
14126 + * Returns: 0 if increment was not done, 1 otherwise.
14127 + */
14128 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14129 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14130 +{
14131 + int val, c = hint, new;
14132 +
14133 + /* sanity test, should be removed by compiler if hint is a constant */
14134 + if (!hint)
14135 + return __atomic_add_unless(v, 1, 0);
14136 +
14137 + do {
14138 + asm volatile("incl %0\n"
14139 +
14140 +#ifdef CONFIG_PAX_REFCOUNT
14141 + "jno 0f\n"
14142 + "decl %0\n"
14143 + "int $4\n0:\n"
14144 + _ASM_EXTABLE(0b, 0b)
14145 +#endif
14146 +
14147 + : "=r" (new)
14148 + : "0" (c));
14149 +
14150 + val = atomic_cmpxchg(v, c, new);
14151 + if (val == c)
14152 + return 1;
14153 + c = val;
14154 + } while (c);
14155 +
14156 + return 0;
14157 +}
14158 +
14159 +/**
14160 * atomic_inc_short - increment of a short integer
14161 * @v: pointer to type int
14162 *
14163 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14164 #endif
14165
14166 /* These are x86-specific, used by some header files */
14167 -#define atomic_clear_mask(mask, addr) \
14168 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14169 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14170 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14171 +{
14172 + asm volatile(LOCK_PREFIX "andl %1,%0"
14173 + : "+m" (v->counter)
14174 + : "r" (~(mask))
14175 + : "memory");
14176 +}
14177
14178 -#define atomic_set_mask(mask, addr) \
14179 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14180 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14181 - : "memory")
14182 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14183 +{
14184 + asm volatile(LOCK_PREFIX "andl %1,%0"
14185 + : "+m" (v->counter)
14186 + : "r" (~(mask))
14187 + : "memory");
14188 +}
14189 +
14190 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14191 +{
14192 + asm volatile(LOCK_PREFIX "orl %1,%0"
14193 + : "+m" (v->counter)
14194 + : "r" (mask)
14195 + : "memory");
14196 +}
14197 +
14198 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14199 +{
14200 + asm volatile(LOCK_PREFIX "orl %1,%0"
14201 + : "+m" (v->counter)
14202 + : "r" (mask)
14203 + : "memory");
14204 +}
14205
14206 /* Atomic operations are already serializing on x86 */
14207 #define smp_mb__before_atomic_dec() barrier()
14208 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14209 index b154de7..aadebd8 100644
14210 --- a/arch/x86/include/asm/atomic64_32.h
14211 +++ b/arch/x86/include/asm/atomic64_32.h
14212 @@ -12,6 +12,14 @@ typedef struct {
14213 u64 __aligned(8) counter;
14214 } atomic64_t;
14215
14216 +#ifdef CONFIG_PAX_REFCOUNT
14217 +typedef struct {
14218 + u64 __aligned(8) counter;
14219 +} atomic64_unchecked_t;
14220 +#else
14221 +typedef atomic64_t atomic64_unchecked_t;
14222 +#endif
14223 +
14224 #define ATOMIC64_INIT(val) { (val) }
14225
14226 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14227 @@ -37,21 +45,31 @@ typedef struct {
14228 ATOMIC64_DECL_ONE(sym##_386)
14229
14230 ATOMIC64_DECL_ONE(add_386);
14231 +ATOMIC64_DECL_ONE(add_unchecked_386);
14232 ATOMIC64_DECL_ONE(sub_386);
14233 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14234 ATOMIC64_DECL_ONE(inc_386);
14235 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14236 ATOMIC64_DECL_ONE(dec_386);
14237 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14238 #endif
14239
14240 #define alternative_atomic64(f, out, in...) \
14241 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14242
14243 ATOMIC64_DECL(read);
14244 +ATOMIC64_DECL(read_unchecked);
14245 ATOMIC64_DECL(set);
14246 +ATOMIC64_DECL(set_unchecked);
14247 ATOMIC64_DECL(xchg);
14248 ATOMIC64_DECL(add_return);
14249 +ATOMIC64_DECL(add_return_unchecked);
14250 ATOMIC64_DECL(sub_return);
14251 +ATOMIC64_DECL(sub_return_unchecked);
14252 ATOMIC64_DECL(inc_return);
14253 +ATOMIC64_DECL(inc_return_unchecked);
14254 ATOMIC64_DECL(dec_return);
14255 +ATOMIC64_DECL(dec_return_unchecked);
14256 ATOMIC64_DECL(dec_if_positive);
14257 ATOMIC64_DECL(inc_not_zero);
14258 ATOMIC64_DECL(add_unless);
14259 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14260 }
14261
14262 /**
14263 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14264 + * @p: pointer to type atomic64_unchecked_t
14265 + * @o: expected value
14266 + * @n: new value
14267 + *
14268 + * Atomically sets @v to @n if it was equal to @o and returns
14269 + * the old value.
14270 + */
14271 +
14272 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14273 +{
14274 + return cmpxchg64(&v->counter, o, n);
14275 +}
14276 +
14277 +/**
14278 * atomic64_xchg - xchg atomic64 variable
14279 * @v: pointer to type atomic64_t
14280 * @n: value to assign
14281 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14282 }
14283
14284 /**
14285 + * atomic64_set_unchecked - set atomic64 variable
14286 + * @v: pointer to type atomic64_unchecked_t
14287 + * @n: value to assign
14288 + *
14289 + * Atomically sets the value of @v to @n.
14290 + */
14291 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14292 +{
14293 + unsigned high = (unsigned)(i >> 32);
14294 + unsigned low = (unsigned)i;
14295 + alternative_atomic64(set, /* no output */,
14296 + "S" (v), "b" (low), "c" (high)
14297 + : "eax", "edx", "memory");
14298 +}
14299 +
14300 +/**
14301 * atomic64_read - read atomic64 variable
14302 * @v: pointer to type atomic64_t
14303 *
14304 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14305 }
14306
14307 /**
14308 + * atomic64_read_unchecked - read atomic64 variable
14309 + * @v: pointer to type atomic64_unchecked_t
14310 + *
14311 + * Atomically reads the value of @v and returns it.
14312 + */
14313 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
14314 +{
14315 + long long r;
14316 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14317 + return r;
14318 + }
14319 +
14320 +/**
14321 * atomic64_add_return - add and return
14322 * @i: integer value to add
14323 * @v: pointer to type atomic64_t
14324 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14325 return i;
14326 }
14327
14328 +/**
14329 + * atomic64_add_return_unchecked - add and return
14330 + * @i: integer value to add
14331 + * @v: pointer to type atomic64_unchecked_t
14332 + *
14333 + * Atomically adds @i to @v and returns @i + *@v
14334 + */
14335 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14336 +{
14337 + alternative_atomic64(add_return_unchecked,
14338 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14339 + ASM_NO_INPUT_CLOBBER("memory"));
14340 + return i;
14341 +}
14342 +
14343 /*
14344 * Other variants with different arithmetic operators:
14345 */
14346 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14347 return a;
14348 }
14349
14350 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14351 +{
14352 + long long a;
14353 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14354 + "S" (v) : "memory", "ecx");
14355 + return a;
14356 +}
14357 +
14358 static inline long long atomic64_dec_return(atomic64_t *v)
14359 {
14360 long long a;
14361 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14362 }
14363
14364 /**
14365 + * atomic64_add_unchecked - add integer to atomic64 variable
14366 + * @i: integer value to add
14367 + * @v: pointer to type atomic64_unchecked_t
14368 + *
14369 + * Atomically adds @i to @v.
14370 + */
14371 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14372 +{
14373 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14374 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14375 + ASM_NO_INPUT_CLOBBER("memory"));
14376 + return i;
14377 +}
14378 +
14379 +/**
14380 * atomic64_sub - subtract the atomic64 variable
14381 * @i: integer value to subtract
14382 * @v: pointer to type atomic64_t
14383 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14384 index 0e1cbfc..5623683 100644
14385 --- a/arch/x86/include/asm/atomic64_64.h
14386 +++ b/arch/x86/include/asm/atomic64_64.h
14387 @@ -18,7 +18,19 @@
14388 */
14389 static inline long atomic64_read(const atomic64_t *v)
14390 {
14391 - return (*(volatile long *)&(v)->counter);
14392 + return (*(volatile const long *)&(v)->counter);
14393 +}
14394 +
14395 +/**
14396 + * atomic64_read_unchecked - read atomic64 variable
14397 + * @v: pointer of type atomic64_unchecked_t
14398 + *
14399 + * Atomically reads the value of @v.
14400 + * Doesn't imply a read memory barrier.
14401 + */
14402 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
14403 +{
14404 + return (*(volatile const long *)&(v)->counter);
14405 }
14406
14407 /**
14408 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14409 }
14410
14411 /**
14412 + * atomic64_set_unchecked - set atomic64 variable
14413 + * @v: pointer to type atomic64_unchecked_t
14414 + * @i: required value
14415 + *
14416 + * Atomically sets the value of @v to @i.
14417 + */
14418 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14419 +{
14420 + v->counter = i;
14421 +}
14422 +
14423 +/**
14424 * atomic64_add - add integer to atomic64 variable
14425 * @i: integer value to add
14426 * @v: pointer to type atomic64_t
14427 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14428 */
14429 static inline void atomic64_add(long i, atomic64_t *v)
14430 {
14431 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14432 +
14433 +#ifdef CONFIG_PAX_REFCOUNT
14434 + "jno 0f\n"
14435 + LOCK_PREFIX "subq %1,%0\n"
14436 + "int $4\n0:\n"
14437 + _ASM_EXTABLE(0b, 0b)
14438 +#endif
14439 +
14440 + : "=m" (v->counter)
14441 + : "er" (i), "m" (v->counter));
14442 +}
14443 +
14444 +/**
14445 + * atomic64_add_unchecked - add integer to atomic64 variable
14446 + * @i: integer value to add
14447 + * @v: pointer to type atomic64_unchecked_t
14448 + *
14449 + * Atomically adds @i to @v.
14450 + */
14451 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14452 +{
14453 asm volatile(LOCK_PREFIX "addq %1,%0"
14454 : "=m" (v->counter)
14455 : "er" (i), "m" (v->counter));
14456 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14457 */
14458 static inline void atomic64_sub(long i, atomic64_t *v)
14459 {
14460 - asm volatile(LOCK_PREFIX "subq %1,%0"
14461 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14462 +
14463 +#ifdef CONFIG_PAX_REFCOUNT
14464 + "jno 0f\n"
14465 + LOCK_PREFIX "addq %1,%0\n"
14466 + "int $4\n0:\n"
14467 + _ASM_EXTABLE(0b, 0b)
14468 +#endif
14469 +
14470 + : "=m" (v->counter)
14471 + : "er" (i), "m" (v->counter));
14472 +}
14473 +
14474 +/**
14475 + * atomic64_sub_unchecked - subtract the atomic64 variable
14476 + * @i: integer value to subtract
14477 + * @v: pointer to type atomic64_unchecked_t
14478 + *
14479 + * Atomically subtracts @i from @v.
14480 + */
14481 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14482 +{
14483 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14484 : "=m" (v->counter)
14485 : "er" (i), "m" (v->counter));
14486 }
14487 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14488 {
14489 unsigned char c;
14490
14491 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14492 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14493 +
14494 +#ifdef CONFIG_PAX_REFCOUNT
14495 + "jno 0f\n"
14496 + LOCK_PREFIX "addq %2,%0\n"
14497 + "int $4\n0:\n"
14498 + _ASM_EXTABLE(0b, 0b)
14499 +#endif
14500 +
14501 + "sete %1\n"
14502 : "=m" (v->counter), "=qm" (c)
14503 : "er" (i), "m" (v->counter) : "memory");
14504 return c;
14505 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14506 */
14507 static inline void atomic64_inc(atomic64_t *v)
14508 {
14509 + asm volatile(LOCK_PREFIX "incq %0\n"
14510 +
14511 +#ifdef CONFIG_PAX_REFCOUNT
14512 + "jno 0f\n"
14513 + LOCK_PREFIX "decq %0\n"
14514 + "int $4\n0:\n"
14515 + _ASM_EXTABLE(0b, 0b)
14516 +#endif
14517 +
14518 + : "=m" (v->counter)
14519 + : "m" (v->counter));
14520 +}
14521 +
14522 +/**
14523 + * atomic64_inc_unchecked - increment atomic64 variable
14524 + * @v: pointer to type atomic64_unchecked_t
14525 + *
14526 + * Atomically increments @v by 1.
14527 + */
14528 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
14529 +{
14530 asm volatile(LOCK_PREFIX "incq %0"
14531 : "=m" (v->counter)
14532 : "m" (v->counter));
14533 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
14534 */
14535 static inline void atomic64_dec(atomic64_t *v)
14536 {
14537 - asm volatile(LOCK_PREFIX "decq %0"
14538 + asm volatile(LOCK_PREFIX "decq %0\n"
14539 +
14540 +#ifdef CONFIG_PAX_REFCOUNT
14541 + "jno 0f\n"
14542 + LOCK_PREFIX "incq %0\n"
14543 + "int $4\n0:\n"
14544 + _ASM_EXTABLE(0b, 0b)
14545 +#endif
14546 +
14547 + : "=m" (v->counter)
14548 + : "m" (v->counter));
14549 +}
14550 +
14551 +/**
14552 + * atomic64_dec_unchecked - decrement atomic64 variable
14553 + * @v: pointer to type atomic64_t
14554 + *
14555 + * Atomically decrements @v by 1.
14556 + */
14557 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
14558 +{
14559 + asm volatile(LOCK_PREFIX "decq %0\n"
14560 : "=m" (v->counter)
14561 : "m" (v->counter));
14562 }
14563 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
14564 {
14565 unsigned char c;
14566
14567 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
14568 + asm volatile(LOCK_PREFIX "decq %0\n"
14569 +
14570 +#ifdef CONFIG_PAX_REFCOUNT
14571 + "jno 0f\n"
14572 + LOCK_PREFIX "incq %0\n"
14573 + "int $4\n0:\n"
14574 + _ASM_EXTABLE(0b, 0b)
14575 +#endif
14576 +
14577 + "sete %1\n"
14578 : "=m" (v->counter), "=qm" (c)
14579 : "m" (v->counter) : "memory");
14580 return c != 0;
14581 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
14582 {
14583 unsigned char c;
14584
14585 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
14586 + asm volatile(LOCK_PREFIX "incq %0\n"
14587 +
14588 +#ifdef CONFIG_PAX_REFCOUNT
14589 + "jno 0f\n"
14590 + LOCK_PREFIX "decq %0\n"
14591 + "int $4\n0:\n"
14592 + _ASM_EXTABLE(0b, 0b)
14593 +#endif
14594 +
14595 + "sete %1\n"
14596 : "=m" (v->counter), "=qm" (c)
14597 : "m" (v->counter) : "memory");
14598 return c != 0;
14599 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14600 {
14601 unsigned char c;
14602
14603 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
14604 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
14605 +
14606 +#ifdef CONFIG_PAX_REFCOUNT
14607 + "jno 0f\n"
14608 + LOCK_PREFIX "subq %2,%0\n"
14609 + "int $4\n0:\n"
14610 + _ASM_EXTABLE(0b, 0b)
14611 +#endif
14612 +
14613 + "sets %1\n"
14614 : "=m" (v->counter), "=qm" (c)
14615 : "er" (i), "m" (v->counter) : "memory");
14616 return c;
14617 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
14618 */
14619 static inline long atomic64_add_return(long i, atomic64_t *v)
14620 {
14621 + return i + xadd_check_overflow(&v->counter, i);
14622 +}
14623 +
14624 +/**
14625 + * atomic64_add_return_unchecked - add and return
14626 + * @i: integer value to add
14627 + * @v: pointer to type atomic64_unchecked_t
14628 + *
14629 + * Atomically adds @i to @v and returns @i + @v
14630 + */
14631 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
14632 +{
14633 return i + xadd(&v->counter, i);
14634 }
14635
14636 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
14637 }
14638
14639 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
14640 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14641 +{
14642 + return atomic64_add_return_unchecked(1, v);
14643 +}
14644 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
14645
14646 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14647 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
14648 return cmpxchg(&v->counter, old, new);
14649 }
14650
14651 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
14652 +{
14653 + return cmpxchg(&v->counter, old, new);
14654 +}
14655 +
14656 static inline long atomic64_xchg(atomic64_t *v, long new)
14657 {
14658 return xchg(&v->counter, new);
14659 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
14660 */
14661 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
14662 {
14663 - long c, old;
14664 + long c, old, new;
14665 c = atomic64_read(v);
14666 for (;;) {
14667 - if (unlikely(c == (u)))
14668 + if (unlikely(c == u))
14669 break;
14670 - old = atomic64_cmpxchg((v), c, c + (a));
14671 +
14672 + asm volatile("add %2,%0\n"
14673 +
14674 +#ifdef CONFIG_PAX_REFCOUNT
14675 + "jno 0f\n"
14676 + "sub %2,%0\n"
14677 + "int $4\n0:\n"
14678 + _ASM_EXTABLE(0b, 0b)
14679 +#endif
14680 +
14681 + : "=r" (new)
14682 + : "0" (c), "ir" (a));
14683 +
14684 + old = atomic64_cmpxchg(v, c, new);
14685 if (likely(old == c))
14686 break;
14687 c = old;
14688 }
14689 - return c != (u);
14690 + return c != u;
14691 }
14692
14693 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
14694 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
14695 index 6dfd019..28e188d 100644
14696 --- a/arch/x86/include/asm/bitops.h
14697 +++ b/arch/x86/include/asm/bitops.h
14698 @@ -40,7 +40,7 @@
14699 * a mask operation on a byte.
14700 */
14701 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
14702 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
14703 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
14704 #define CONST_MASK(nr) (1 << ((nr) & 7))
14705
14706 /**
14707 @@ -486,7 +486,7 @@ static inline int fls(int x)
14708 * at position 64.
14709 */
14710 #ifdef CONFIG_X86_64
14711 -static __always_inline int fls64(__u64 x)
14712 +static __always_inline long fls64(__u64 x)
14713 {
14714 int bitpos = -1;
14715 /*
14716 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
14717 index 4fa687a..60f2d39 100644
14718 --- a/arch/x86/include/asm/boot.h
14719 +++ b/arch/x86/include/asm/boot.h
14720 @@ -6,10 +6,15 @@
14721 #include <uapi/asm/boot.h>
14722
14723 /* Physical address where kernel should be loaded. */
14724 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14725 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
14726 + (CONFIG_PHYSICAL_ALIGN - 1)) \
14727 & ~(CONFIG_PHYSICAL_ALIGN - 1))
14728
14729 +#ifndef __ASSEMBLY__
14730 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
14731 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
14732 +#endif
14733 +
14734 /* Minimum kernel alignment, as a power of two */
14735 #ifdef CONFIG_X86_64
14736 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
14737 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
14738 index 48f99f1..d78ebf9 100644
14739 --- a/arch/x86/include/asm/cache.h
14740 +++ b/arch/x86/include/asm/cache.h
14741 @@ -5,12 +5,13 @@
14742
14743 /* L1 cache line size */
14744 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
14745 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
14746 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
14747
14748 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
14749 +#define __read_only __attribute__((__section__(".data..read_only")))
14750
14751 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
14752 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
14753 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
14754
14755 #ifdef CONFIG_X86_VSMP
14756 #ifdef CONFIG_SMP
14757 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
14758 index 9863ee3..4a1f8e1 100644
14759 --- a/arch/x86/include/asm/cacheflush.h
14760 +++ b/arch/x86/include/asm/cacheflush.h
14761 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
14762 unsigned long pg_flags = pg->flags & _PGMT_MASK;
14763
14764 if (pg_flags == _PGMT_DEFAULT)
14765 - return -1;
14766 + return ~0UL;
14767 else if (pg_flags == _PGMT_WC)
14768 return _PAGE_CACHE_WC;
14769 else if (pg_flags == _PGMT_UC_MINUS)
14770 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
14771 index f50de69..2b0a458 100644
14772 --- a/arch/x86/include/asm/checksum_32.h
14773 +++ b/arch/x86/include/asm/checksum_32.h
14774 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
14775 int len, __wsum sum,
14776 int *src_err_ptr, int *dst_err_ptr);
14777
14778 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
14779 + int len, __wsum sum,
14780 + int *src_err_ptr, int *dst_err_ptr);
14781 +
14782 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
14783 + int len, __wsum sum,
14784 + int *src_err_ptr, int *dst_err_ptr);
14785 +
14786 /*
14787 * Note: when you get a NULL pointer exception here this means someone
14788 * passed in an incorrect kernel address to one of these functions.
14789 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
14790
14791 might_sleep();
14792 stac();
14793 - ret = csum_partial_copy_generic((__force void *)src, dst,
14794 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
14795 len, sum, err_ptr, NULL);
14796 clac();
14797
14798 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
14799 might_sleep();
14800 if (access_ok(VERIFY_WRITE, dst, len)) {
14801 stac();
14802 - ret = csum_partial_copy_generic(src, (__force void *)dst,
14803 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
14804 len, sum, NULL, err_ptr);
14805 clac();
14806 return ret;
14807 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
14808 index d47786a..ce1b05d 100644
14809 --- a/arch/x86/include/asm/cmpxchg.h
14810 +++ b/arch/x86/include/asm/cmpxchg.h
14811 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
14812 __compiletime_error("Bad argument size for cmpxchg");
14813 extern void __xadd_wrong_size(void)
14814 __compiletime_error("Bad argument size for xadd");
14815 +extern void __xadd_check_overflow_wrong_size(void)
14816 + __compiletime_error("Bad argument size for xadd_check_overflow");
14817 extern void __add_wrong_size(void)
14818 __compiletime_error("Bad argument size for add");
14819 +extern void __add_check_overflow_wrong_size(void)
14820 + __compiletime_error("Bad argument size for add_check_overflow");
14821
14822 /*
14823 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
14824 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
14825 __ret; \
14826 })
14827
14828 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
14829 + ({ \
14830 + __typeof__ (*(ptr)) __ret = (arg); \
14831 + switch (sizeof(*(ptr))) { \
14832 + case __X86_CASE_L: \
14833 + asm volatile (lock #op "l %0, %1\n" \
14834 + "jno 0f\n" \
14835 + "mov %0,%1\n" \
14836 + "int $4\n0:\n" \
14837 + _ASM_EXTABLE(0b, 0b) \
14838 + : "+r" (__ret), "+m" (*(ptr)) \
14839 + : : "memory", "cc"); \
14840 + break; \
14841 + case __X86_CASE_Q: \
14842 + asm volatile (lock #op "q %q0, %1\n" \
14843 + "jno 0f\n" \
14844 + "mov %0,%1\n" \
14845 + "int $4\n0:\n" \
14846 + _ASM_EXTABLE(0b, 0b) \
14847 + : "+r" (__ret), "+m" (*(ptr)) \
14848 + : : "memory", "cc"); \
14849 + break; \
14850 + default: \
14851 + __ ## op ## _check_overflow_wrong_size(); \
14852 + } \
14853 + __ret; \
14854 + })
14855 +
14856 /*
14857 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
14858 * Since this is generally used to protect other memory information, we
14859 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
14860 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
14861 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
14862
14863 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
14864 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
14865 +
14866 #define __add(ptr, inc, lock) \
14867 ({ \
14868 __typeof__ (*(ptr)) __ret = (inc); \
14869 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
14870 index 59c6c40..5e0b22c 100644
14871 --- a/arch/x86/include/asm/compat.h
14872 +++ b/arch/x86/include/asm/compat.h
14873 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
14874 typedef u32 compat_uint_t;
14875 typedef u32 compat_ulong_t;
14876 typedef u64 __attribute__((aligned(4))) compat_u64;
14877 -typedef u32 compat_uptr_t;
14878 +typedef u32 __user compat_uptr_t;
14879
14880 struct compat_timespec {
14881 compat_time_t tv_sec;
14882 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
14883 index 7290585..717e89e 100644
14884 --- a/arch/x86/include/asm/cpufeature.h
14885 +++ b/arch/x86/include/asm/cpufeature.h
14886 @@ -203,7 +203,7 @@
14887 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
14888 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
14889 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
14890 -
14891 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
14892
14893 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
14894 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
14895 @@ -211,7 +211,7 @@
14896 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
14897 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
14898 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
14899 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
14900 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
14901 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
14902 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
14903 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
14904 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
14905 #undef cpu_has_centaur_mcr
14906 #define cpu_has_centaur_mcr 0
14907
14908 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
14909 #endif /* CONFIG_X86_64 */
14910
14911 #if __GNUC__ >= 4
14912 @@ -403,7 +404,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14913
14914 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
14915 t_warn:
14916 - warn_pre_alternatives();
14917 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
14918 + warn_pre_alternatives();
14919 return false;
14920 #endif
14921 #else /* GCC_VERSION >= 40500 */
14922 @@ -421,7 +423,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
14923 ".section .discard,\"aw\",@progbits\n"
14924 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14925 ".previous\n"
14926 - ".section .altinstr_replacement,\"ax\"\n"
14927 + ".section .altinstr_replacement,\"a\"\n"
14928 "3: movb $1,%0\n"
14929 "4:\n"
14930 ".previous\n"
14931 @@ -457,7 +459,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14932 " .byte 2b - 1b\n" /* src len */
14933 " .byte 4f - 3f\n" /* repl len */
14934 ".previous\n"
14935 - ".section .altinstr_replacement,\"ax\"\n"
14936 + ".section .altinstr_replacement,\"a\"\n"
14937 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
14938 "4:\n"
14939 ".previous\n"
14940 @@ -490,7 +492,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14941 ".section .discard,\"aw\",@progbits\n"
14942 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
14943 ".previous\n"
14944 - ".section .altinstr_replacement,\"ax\"\n"
14945 + ".section .altinstr_replacement,\"a\"\n"
14946 "3: movb $0,%0\n"
14947 "4:\n"
14948 ".previous\n"
14949 @@ -504,7 +506,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
14950 ".section .discard,\"aw\",@progbits\n"
14951 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
14952 ".previous\n"
14953 - ".section .altinstr_replacement,\"ax\"\n"
14954 + ".section .altinstr_replacement,\"a\"\n"
14955 "5: movb $1,%0\n"
14956 "6:\n"
14957 ".previous\n"
14958 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
14959 index b90e5df..b462c91 100644
14960 --- a/arch/x86/include/asm/desc.h
14961 +++ b/arch/x86/include/asm/desc.h
14962 @@ -4,6 +4,7 @@
14963 #include <asm/desc_defs.h>
14964 #include <asm/ldt.h>
14965 #include <asm/mmu.h>
14966 +#include <asm/pgtable.h>
14967
14968 #include <linux/smp.h>
14969 #include <linux/percpu.h>
14970 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14971
14972 desc->type = (info->read_exec_only ^ 1) << 1;
14973 desc->type |= info->contents << 2;
14974 + desc->type |= info->seg_not_present ^ 1;
14975
14976 desc->s = 1;
14977 desc->dpl = 0x3;
14978 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
14979 }
14980
14981 extern struct desc_ptr idt_descr;
14982 -extern gate_desc idt_table[];
14983 -extern struct desc_ptr debug_idt_descr;
14984 -extern gate_desc debug_idt_table[];
14985 -
14986 -struct gdt_page {
14987 - struct desc_struct gdt[GDT_ENTRIES];
14988 -} __attribute__((aligned(PAGE_SIZE)));
14989 -
14990 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14991 +extern gate_desc idt_table[IDT_ENTRIES];
14992 +extern const struct desc_ptr debug_idt_descr;
14993 +extern gate_desc debug_idt_table[IDT_ENTRIES];
14994
14995 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14996 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14997 {
14998 - return per_cpu(gdt_page, cpu).gdt;
14999 + return cpu_gdt_table[cpu];
15000 }
15001
15002 #ifdef CONFIG_X86_64
15003 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15004 unsigned long base, unsigned dpl, unsigned flags,
15005 unsigned short seg)
15006 {
15007 - gate->a = (seg << 16) | (base & 0xffff);
15008 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15009 + gate->gate.offset_low = base;
15010 + gate->gate.seg = seg;
15011 + gate->gate.reserved = 0;
15012 + gate->gate.type = type;
15013 + gate->gate.s = 0;
15014 + gate->gate.dpl = dpl;
15015 + gate->gate.p = 1;
15016 + gate->gate.offset_high = base >> 16;
15017 }
15018
15019 #endif
15020 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15021
15022 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15023 {
15024 + pax_open_kernel();
15025 memcpy(&idt[entry], gate, sizeof(*gate));
15026 + pax_close_kernel();
15027 }
15028
15029 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15030 {
15031 + pax_open_kernel();
15032 memcpy(&ldt[entry], desc, 8);
15033 + pax_close_kernel();
15034 }
15035
15036 static inline void
15037 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15038 default: size = sizeof(*gdt); break;
15039 }
15040
15041 + pax_open_kernel();
15042 memcpy(&gdt[entry], desc, size);
15043 + pax_close_kernel();
15044 }
15045
15046 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15047 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15048
15049 static inline void native_load_tr_desc(void)
15050 {
15051 + pax_open_kernel();
15052 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15053 + pax_close_kernel();
15054 }
15055
15056 static inline void native_load_gdt(const struct desc_ptr *dtr)
15057 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15058 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15059 unsigned int i;
15060
15061 + pax_open_kernel();
15062 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15063 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15064 + pax_close_kernel();
15065 }
15066
15067 #define _LDT_empty(info) \
15068 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15069 preempt_enable();
15070 }
15071
15072 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15073 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15074 {
15075 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15076 }
15077 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15078 }
15079
15080 #ifdef CONFIG_X86_64
15081 -static inline void set_nmi_gate(int gate, void *addr)
15082 +static inline void set_nmi_gate(int gate, const void *addr)
15083 {
15084 gate_desc s;
15085
15086 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15087 #endif
15088
15089 #ifdef CONFIG_TRACING
15090 -extern struct desc_ptr trace_idt_descr;
15091 -extern gate_desc trace_idt_table[];
15092 +extern const struct desc_ptr trace_idt_descr;
15093 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15094 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15095 {
15096 write_idt_entry(trace_idt_table, entry, gate);
15097 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15098 }
15099 #endif
15100
15101 -static inline void _set_gate(int gate, unsigned type, void *addr,
15102 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15103 unsigned dpl, unsigned ist, unsigned seg)
15104 {
15105 gate_desc s;
15106 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15107 * Pentium F0 0F bugfix can have resulted in the mapped
15108 * IDT being write-protected.
15109 */
15110 -static inline void set_intr_gate(unsigned int n, void *addr)
15111 +static inline void set_intr_gate(unsigned int n, const void *addr)
15112 {
15113 BUG_ON((unsigned)n > 0xFF);
15114 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15115 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15116 /*
15117 * This routine sets up an interrupt gate at directory privilege level 3.
15118 */
15119 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15120 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15121 {
15122 BUG_ON((unsigned)n > 0xFF);
15123 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15124 }
15125
15126 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15127 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15128 {
15129 BUG_ON((unsigned)n > 0xFF);
15130 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15131 }
15132
15133 -static inline void set_trap_gate(unsigned int n, void *addr)
15134 +static inline void set_trap_gate(unsigned int n, const void *addr)
15135 {
15136 BUG_ON((unsigned)n > 0xFF);
15137 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15138 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15139 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15140 {
15141 BUG_ON((unsigned)n > 0xFF);
15142 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15143 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15144 }
15145
15146 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15147 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15148 {
15149 BUG_ON((unsigned)n > 0xFF);
15150 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15151 }
15152
15153 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15154 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15155 {
15156 BUG_ON((unsigned)n > 0xFF);
15157 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15158 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15159 else
15160 load_idt((const struct desc_ptr *)&idt_descr);
15161 }
15162 +
15163 +#ifdef CONFIG_X86_32
15164 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15165 +{
15166 + struct desc_struct d;
15167 +
15168 + if (likely(limit))
15169 + limit = (limit - 1UL) >> PAGE_SHIFT;
15170 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15171 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15172 +}
15173 +#endif
15174 +
15175 #endif /* _ASM_X86_DESC_H */
15176 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15177 index 278441f..b95a174 100644
15178 --- a/arch/x86/include/asm/desc_defs.h
15179 +++ b/arch/x86/include/asm/desc_defs.h
15180 @@ -31,6 +31,12 @@ struct desc_struct {
15181 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15182 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15183 };
15184 + struct {
15185 + u16 offset_low;
15186 + u16 seg;
15187 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15188 + unsigned offset_high: 16;
15189 + } gate;
15190 };
15191 } __attribute__((packed));
15192
15193 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15194 index ced283a..ffe04cc 100644
15195 --- a/arch/x86/include/asm/div64.h
15196 +++ b/arch/x86/include/asm/div64.h
15197 @@ -39,7 +39,7 @@
15198 __mod; \
15199 })
15200
15201 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15202 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15203 {
15204 union {
15205 u64 v64;
15206 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15207 index 9c999c1..3860cb8 100644
15208 --- a/arch/x86/include/asm/elf.h
15209 +++ b/arch/x86/include/asm/elf.h
15210 @@ -243,7 +243,25 @@ extern int force_personality32;
15211 the loader. We need to make sure that it is out of the way of the program
15212 that it will "exec", and that there is sufficient room for the brk. */
15213
15214 +#ifdef CONFIG_PAX_SEGMEXEC
15215 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15216 +#else
15217 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15218 +#endif
15219 +
15220 +#ifdef CONFIG_PAX_ASLR
15221 +#ifdef CONFIG_X86_32
15222 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15223 +
15224 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15225 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15226 +#else
15227 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15228 +
15229 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15230 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15231 +#endif
15232 +#endif
15233
15234 /* This yields a mask that user programs can use to figure out what
15235 instruction set this CPU supports. This could be done in user space,
15236 @@ -296,16 +314,12 @@ do { \
15237
15238 #define ARCH_DLINFO \
15239 do { \
15240 - if (vdso_enabled) \
15241 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15242 - (unsigned long)current->mm->context.vdso); \
15243 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15244 } while (0)
15245
15246 #define ARCH_DLINFO_X32 \
15247 do { \
15248 - if (vdso_enabled) \
15249 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15250 - (unsigned long)current->mm->context.vdso); \
15251 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15252 } while (0)
15253
15254 #define AT_SYSINFO 32
15255 @@ -320,7 +334,7 @@ else \
15256
15257 #endif /* !CONFIG_X86_32 */
15258
15259 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15260 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15261
15262 #define VDSO_ENTRY \
15263 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15264 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15265 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15266 #define compat_arch_setup_additional_pages syscall32_setup_pages
15267
15268 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15269 -#define arch_randomize_brk arch_randomize_brk
15270 -
15271 /*
15272 * True on X86_32 or when emulating IA32 on X86_64
15273 */
15274 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15275 index 77a99ac..39ff7f5 100644
15276 --- a/arch/x86/include/asm/emergency-restart.h
15277 +++ b/arch/x86/include/asm/emergency-restart.h
15278 @@ -1,6 +1,6 @@
15279 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15280 #define _ASM_X86_EMERGENCY_RESTART_H
15281
15282 -extern void machine_emergency_restart(void);
15283 +extern void machine_emergency_restart(void) __noreturn;
15284
15285 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15286 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15287 index 4d0bda7..221da4d 100644
15288 --- a/arch/x86/include/asm/fpu-internal.h
15289 +++ b/arch/x86/include/asm/fpu-internal.h
15290 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15291 #define user_insn(insn, output, input...) \
15292 ({ \
15293 int err; \
15294 + pax_open_userland(); \
15295 asm volatile(ASM_STAC "\n" \
15296 - "1:" #insn "\n\t" \
15297 + "1:" \
15298 + __copyuser_seg \
15299 + #insn "\n\t" \
15300 "2: " ASM_CLAC "\n" \
15301 ".section .fixup,\"ax\"\n" \
15302 "3: movl $-1,%[err]\n" \
15303 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15304 _ASM_EXTABLE(1b, 3b) \
15305 : [err] "=r" (err), output \
15306 : "0"(0), input); \
15307 + pax_close_userland(); \
15308 err; \
15309 })
15310
15311 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
15312 "emms\n\t" /* clear stack tags */
15313 "fildl %P[addr]", /* set F?P to defined value */
15314 X86_FEATURE_FXSAVE_LEAK,
15315 - [addr] "m" (tsk->thread.fpu.has_fpu));
15316 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
15317
15318 return fpu_restore_checking(&tsk->thread.fpu);
15319 }
15320 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
15321 index be27ba1..04a8801 100644
15322 --- a/arch/x86/include/asm/futex.h
15323 +++ b/arch/x86/include/asm/futex.h
15324 @@ -12,6 +12,7 @@
15325 #include <asm/smap.h>
15326
15327 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15328 + typecheck(u32 __user *, uaddr); \
15329 asm volatile("\t" ASM_STAC "\n" \
15330 "1:\t" insn "\n" \
15331 "2:\t" ASM_CLAC "\n" \
15332 @@ -20,15 +21,16 @@
15333 "\tjmp\t2b\n" \
15334 "\t.previous\n" \
15335 _ASM_EXTABLE(1b, 3b) \
15336 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
15337 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
15338 : "i" (-EFAULT), "0" (oparg), "1" (0))
15339
15340 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
15341 + typecheck(u32 __user *, uaddr); \
15342 asm volatile("\t" ASM_STAC "\n" \
15343 "1:\tmovl %2, %0\n" \
15344 "\tmovl\t%0, %3\n" \
15345 "\t" insn "\n" \
15346 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
15347 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
15348 "\tjnz\t1b\n" \
15349 "3:\t" ASM_CLAC "\n" \
15350 "\t.section .fixup,\"ax\"\n" \
15351 @@ -38,7 +40,7 @@
15352 _ASM_EXTABLE(1b, 4b) \
15353 _ASM_EXTABLE(2b, 4b) \
15354 : "=&a" (oldval), "=&r" (ret), \
15355 - "+m" (*uaddr), "=&r" (tem) \
15356 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
15357 : "r" (oparg), "i" (-EFAULT), "1" (0))
15358
15359 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15360 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15361
15362 pagefault_disable();
15363
15364 + pax_open_userland();
15365 switch (op) {
15366 case FUTEX_OP_SET:
15367 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
15368 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
15369 break;
15370 case FUTEX_OP_ADD:
15371 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
15372 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
15373 uaddr, oparg);
15374 break;
15375 case FUTEX_OP_OR:
15376 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
15377 default:
15378 ret = -ENOSYS;
15379 }
15380 + pax_close_userland();
15381
15382 pagefault_enable();
15383
15384 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
15385 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
15386 return -EFAULT;
15387
15388 + pax_open_userland();
15389 asm volatile("\t" ASM_STAC "\n"
15390 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
15391 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
15392 "2:\t" ASM_CLAC "\n"
15393 "\t.section .fixup, \"ax\"\n"
15394 "3:\tmov %3, %0\n"
15395 "\tjmp 2b\n"
15396 "\t.previous\n"
15397 _ASM_EXTABLE(1b, 3b)
15398 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
15399 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
15400 : "i" (-EFAULT), "r" (newval), "1" (oldval)
15401 : "memory"
15402 );
15403 + pax_close_userland();
15404
15405 *uval = oldval;
15406 return ret;
15407 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
15408 index e4ac559..c1c0c87 100644
15409 --- a/arch/x86/include/asm/hw_irq.h
15410 +++ b/arch/x86/include/asm/hw_irq.h
15411 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
15412 extern void enable_IO_APIC(void);
15413
15414 /* Statistics */
15415 -extern atomic_t irq_err_count;
15416 -extern atomic_t irq_mis_count;
15417 +extern atomic_unchecked_t irq_err_count;
15418 +extern atomic_unchecked_t irq_mis_count;
15419
15420 /* EISA */
15421 extern void eisa_set_level_irq(unsigned int irq);
15422 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
15423 index a203659..9889f1c 100644
15424 --- a/arch/x86/include/asm/i8259.h
15425 +++ b/arch/x86/include/asm/i8259.h
15426 @@ -62,7 +62,7 @@ struct legacy_pic {
15427 void (*init)(int auto_eoi);
15428 int (*irq_pending)(unsigned int irq);
15429 void (*make_irq)(unsigned int irq);
15430 -};
15431 +} __do_const;
15432
15433 extern struct legacy_pic *legacy_pic;
15434 extern struct legacy_pic null_legacy_pic;
15435 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
15436 index 34f69cb..6d95446 100644
15437 --- a/arch/x86/include/asm/io.h
15438 +++ b/arch/x86/include/asm/io.h
15439 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
15440 "m" (*(volatile type __force *)addr) barrier); }
15441
15442 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
15443 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
15444 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
15445 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
15446 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
15447
15448 build_mmio_read(__readb, "b", unsigned char, "=q", )
15449 -build_mmio_read(__readw, "w", unsigned short, "=r", )
15450 -build_mmio_read(__readl, "l", unsigned int, "=r", )
15451 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
15452 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
15453
15454 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
15455 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
15456 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
15457 return ioremap_nocache(offset, size);
15458 }
15459
15460 -extern void iounmap(volatile void __iomem *addr);
15461 +extern void iounmap(const volatile void __iomem *addr);
15462
15463 extern void set_iounmap_nonlazy(void);
15464
15465 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
15466
15467 #include <linux/vmalloc.h>
15468
15469 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
15470 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
15471 +{
15472 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15473 +}
15474 +
15475 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
15476 +{
15477 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
15478 +}
15479 +
15480 /*
15481 * Convert a virtual cached pointer to an uncached pointer
15482 */
15483 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
15484 index bba3cf8..06bc8da 100644
15485 --- a/arch/x86/include/asm/irqflags.h
15486 +++ b/arch/x86/include/asm/irqflags.h
15487 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
15488 sti; \
15489 sysexit
15490
15491 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
15492 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
15493 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
15494 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
15495 +
15496 #else
15497 #define INTERRUPT_RETURN iret
15498 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
15499 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
15500 index 5a6d287..f815789 100644
15501 --- a/arch/x86/include/asm/kprobes.h
15502 +++ b/arch/x86/include/asm/kprobes.h
15503 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
15504 #define RELATIVEJUMP_SIZE 5
15505 #define RELATIVECALL_OPCODE 0xe8
15506 #define RELATIVE_ADDR_SIZE 4
15507 -#define MAX_STACK_SIZE 64
15508 -#define MIN_STACK_SIZE(ADDR) \
15509 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
15510 - THREAD_SIZE - (unsigned long)(ADDR))) \
15511 - ? (MAX_STACK_SIZE) \
15512 - : (((unsigned long)current_thread_info()) + \
15513 - THREAD_SIZE - (unsigned long)(ADDR)))
15514 +#define MAX_STACK_SIZE 64UL
15515 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
15516
15517 #define flush_insn_slot(p) do { } while (0)
15518
15519 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
15520 index 2d89e39..baee879 100644
15521 --- a/arch/x86/include/asm/local.h
15522 +++ b/arch/x86/include/asm/local.h
15523 @@ -10,33 +10,97 @@ typedef struct {
15524 atomic_long_t a;
15525 } local_t;
15526
15527 +typedef struct {
15528 + atomic_long_unchecked_t a;
15529 +} local_unchecked_t;
15530 +
15531 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15532
15533 #define local_read(l) atomic_long_read(&(l)->a)
15534 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
15535 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
15536 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
15537
15538 static inline void local_inc(local_t *l)
15539 {
15540 - asm volatile(_ASM_INC "%0"
15541 + asm volatile(_ASM_INC "%0\n"
15542 +
15543 +#ifdef CONFIG_PAX_REFCOUNT
15544 + "jno 0f\n"
15545 + _ASM_DEC "%0\n"
15546 + "int $4\n0:\n"
15547 + _ASM_EXTABLE(0b, 0b)
15548 +#endif
15549 +
15550 + : "+m" (l->a.counter));
15551 +}
15552 +
15553 +static inline void local_inc_unchecked(local_unchecked_t *l)
15554 +{
15555 + asm volatile(_ASM_INC "%0\n"
15556 : "+m" (l->a.counter));
15557 }
15558
15559 static inline void local_dec(local_t *l)
15560 {
15561 - asm volatile(_ASM_DEC "%0"
15562 + asm volatile(_ASM_DEC "%0\n"
15563 +
15564 +#ifdef CONFIG_PAX_REFCOUNT
15565 + "jno 0f\n"
15566 + _ASM_INC "%0\n"
15567 + "int $4\n0:\n"
15568 + _ASM_EXTABLE(0b, 0b)
15569 +#endif
15570 +
15571 + : "+m" (l->a.counter));
15572 +}
15573 +
15574 +static inline void local_dec_unchecked(local_unchecked_t *l)
15575 +{
15576 + asm volatile(_ASM_DEC "%0\n"
15577 : "+m" (l->a.counter));
15578 }
15579
15580 static inline void local_add(long i, local_t *l)
15581 {
15582 - asm volatile(_ASM_ADD "%1,%0"
15583 + asm volatile(_ASM_ADD "%1,%0\n"
15584 +
15585 +#ifdef CONFIG_PAX_REFCOUNT
15586 + "jno 0f\n"
15587 + _ASM_SUB "%1,%0\n"
15588 + "int $4\n0:\n"
15589 + _ASM_EXTABLE(0b, 0b)
15590 +#endif
15591 +
15592 + : "+m" (l->a.counter)
15593 + : "ir" (i));
15594 +}
15595 +
15596 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
15597 +{
15598 + asm volatile(_ASM_ADD "%1,%0\n"
15599 : "+m" (l->a.counter)
15600 : "ir" (i));
15601 }
15602
15603 static inline void local_sub(long i, local_t *l)
15604 {
15605 - asm volatile(_ASM_SUB "%1,%0"
15606 + asm volatile(_ASM_SUB "%1,%0\n"
15607 +
15608 +#ifdef CONFIG_PAX_REFCOUNT
15609 + "jno 0f\n"
15610 + _ASM_ADD "%1,%0\n"
15611 + "int $4\n0:\n"
15612 + _ASM_EXTABLE(0b, 0b)
15613 +#endif
15614 +
15615 + : "+m" (l->a.counter)
15616 + : "ir" (i));
15617 +}
15618 +
15619 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
15620 +{
15621 + asm volatile(_ASM_SUB "%1,%0\n"
15622 : "+m" (l->a.counter)
15623 : "ir" (i));
15624 }
15625 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
15626 {
15627 unsigned char c;
15628
15629 - asm volatile(_ASM_SUB "%2,%0; sete %1"
15630 + asm volatile(_ASM_SUB "%2,%0\n"
15631 +
15632 +#ifdef CONFIG_PAX_REFCOUNT
15633 + "jno 0f\n"
15634 + _ASM_ADD "%2,%0\n"
15635 + "int $4\n0:\n"
15636 + _ASM_EXTABLE(0b, 0b)
15637 +#endif
15638 +
15639 + "sete %1\n"
15640 : "+m" (l->a.counter), "=qm" (c)
15641 : "ir" (i) : "memory");
15642 return c;
15643 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
15644 {
15645 unsigned char c;
15646
15647 - asm volatile(_ASM_DEC "%0; sete %1"
15648 + asm volatile(_ASM_DEC "%0\n"
15649 +
15650 +#ifdef CONFIG_PAX_REFCOUNT
15651 + "jno 0f\n"
15652 + _ASM_INC "%0\n"
15653 + "int $4\n0:\n"
15654 + _ASM_EXTABLE(0b, 0b)
15655 +#endif
15656 +
15657 + "sete %1\n"
15658 : "+m" (l->a.counter), "=qm" (c)
15659 : : "memory");
15660 return c != 0;
15661 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
15662 {
15663 unsigned char c;
15664
15665 - asm volatile(_ASM_INC "%0; sete %1"
15666 + asm volatile(_ASM_INC "%0\n"
15667 +
15668 +#ifdef CONFIG_PAX_REFCOUNT
15669 + "jno 0f\n"
15670 + _ASM_DEC "%0\n"
15671 + "int $4\n0:\n"
15672 + _ASM_EXTABLE(0b, 0b)
15673 +#endif
15674 +
15675 + "sete %1\n"
15676 : "+m" (l->a.counter), "=qm" (c)
15677 : : "memory");
15678 return c != 0;
15679 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
15680 {
15681 unsigned char c;
15682
15683 - asm volatile(_ASM_ADD "%2,%0; sets %1"
15684 + asm volatile(_ASM_ADD "%2,%0\n"
15685 +
15686 +#ifdef CONFIG_PAX_REFCOUNT
15687 + "jno 0f\n"
15688 + _ASM_SUB "%2,%0\n"
15689 + "int $4\n0:\n"
15690 + _ASM_EXTABLE(0b, 0b)
15691 +#endif
15692 +
15693 + "sets %1\n"
15694 : "+m" (l->a.counter), "=qm" (c)
15695 : "ir" (i) : "memory");
15696 return c;
15697 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
15698 static inline long local_add_return(long i, local_t *l)
15699 {
15700 long __i = i;
15701 + asm volatile(_ASM_XADD "%0, %1\n"
15702 +
15703 +#ifdef CONFIG_PAX_REFCOUNT
15704 + "jno 0f\n"
15705 + _ASM_MOV "%0,%1\n"
15706 + "int $4\n0:\n"
15707 + _ASM_EXTABLE(0b, 0b)
15708 +#endif
15709 +
15710 + : "+r" (i), "+m" (l->a.counter)
15711 + : : "memory");
15712 + return i + __i;
15713 +}
15714 +
15715 +/**
15716 + * local_add_return_unchecked - add and return
15717 + * @i: integer value to add
15718 + * @l: pointer to type local_unchecked_t
15719 + *
15720 + * Atomically adds @i to @l and returns @i + @l
15721 + */
15722 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
15723 +{
15724 + long __i = i;
15725 asm volatile(_ASM_XADD "%0, %1;"
15726 : "+r" (i), "+m" (l->a.counter)
15727 : : "memory");
15728 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
15729
15730 #define local_cmpxchg(l, o, n) \
15731 (cmpxchg_local(&((l)->a.counter), (o), (n)))
15732 +#define local_cmpxchg_unchecked(l, o, n) \
15733 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
15734 /* Always has a lock prefix */
15735 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
15736
15737 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
15738 new file mode 100644
15739 index 0000000..2bfd3ba
15740 --- /dev/null
15741 +++ b/arch/x86/include/asm/mman.h
15742 @@ -0,0 +1,15 @@
15743 +#ifndef _X86_MMAN_H
15744 +#define _X86_MMAN_H
15745 +
15746 +#include <uapi/asm/mman.h>
15747 +
15748 +#ifdef __KERNEL__
15749 +#ifndef __ASSEMBLY__
15750 +#ifdef CONFIG_X86_32
15751 +#define arch_mmap_check i386_mmap_check
15752 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
15753 +#endif
15754 +#endif
15755 +#endif
15756 +
15757 +#endif /* X86_MMAN_H */
15758 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
15759 index 5f55e69..e20bfb1 100644
15760 --- a/arch/x86/include/asm/mmu.h
15761 +++ b/arch/x86/include/asm/mmu.h
15762 @@ -9,7 +9,7 @@
15763 * we put the segment information here.
15764 */
15765 typedef struct {
15766 - void *ldt;
15767 + struct desc_struct *ldt;
15768 int size;
15769
15770 #ifdef CONFIG_X86_64
15771 @@ -18,7 +18,19 @@ typedef struct {
15772 #endif
15773
15774 struct mutex lock;
15775 - void *vdso;
15776 + unsigned long vdso;
15777 +
15778 +#ifdef CONFIG_X86_32
15779 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
15780 + unsigned long user_cs_base;
15781 + unsigned long user_cs_limit;
15782 +
15783 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15784 + cpumask_t cpu_user_cs_mask;
15785 +#endif
15786 +
15787 +#endif
15788 +#endif
15789 } mm_context_t;
15790
15791 #ifdef CONFIG_SMP
15792 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
15793 index be12c53..2124e35 100644
15794 --- a/arch/x86/include/asm/mmu_context.h
15795 +++ b/arch/x86/include/asm/mmu_context.h
15796 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
15797
15798 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
15799 {
15800 +
15801 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15802 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
15803 + unsigned int i;
15804 + pgd_t *pgd;
15805 +
15806 + pax_open_kernel();
15807 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
15808 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
15809 + set_pgd_batched(pgd+i, native_make_pgd(0));
15810 + pax_close_kernel();
15811 + }
15812 +#endif
15813 +
15814 #ifdef CONFIG_SMP
15815 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
15816 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
15817 @@ -34,16 +48,55 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15818 struct task_struct *tsk)
15819 {
15820 unsigned cpu = smp_processor_id();
15821 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15822 + int tlbstate = TLBSTATE_OK;
15823 +#endif
15824
15825 if (likely(prev != next)) {
15826 #ifdef CONFIG_SMP
15827 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15828 + tlbstate = this_cpu_read(cpu_tlbstate.state);
15829 +#endif
15830 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15831 this_cpu_write(cpu_tlbstate.active_mm, next);
15832 #endif
15833 cpumask_set_cpu(cpu, mm_cpumask(next));
15834
15835 /* Re-load page tables */
15836 +#ifdef CONFIG_PAX_PER_CPU_PGD
15837 + pax_open_kernel();
15838 +
15839 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15840 + if (static_cpu_has(X86_FEATURE_PCID))
15841 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15842 + else
15843 +#endif
15844 +
15845 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15846 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15847 + pax_close_kernel();
15848 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15849 +
15850 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15851 + if (static_cpu_has(X86_FEATURE_PCID)) {
15852 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15853 + u64 descriptor[2];
15854 + descriptor[0] = PCID_USER;
15855 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15856 + } else {
15857 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15858 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15859 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15860 + else
15861 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15862 + }
15863 + } else
15864 +#endif
15865 +
15866 + load_cr3(get_cpu_pgd(cpu, kernel));
15867 +#else
15868 load_cr3(next->pgd);
15869 +#endif
15870
15871 /* Stop flush ipis for the previous mm */
15872 cpumask_clear_cpu(cpu, mm_cpumask(prev));
15873 @@ -51,9 +104,63 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15874 /* Load the LDT, if the LDT is different: */
15875 if (unlikely(prev->context.ldt != next->context.ldt))
15876 load_LDT_nolock(&next->context);
15877 +
15878 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
15879 + if (!(__supported_pte_mask & _PAGE_NX)) {
15880 + smp_mb__before_clear_bit();
15881 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
15882 + smp_mb__after_clear_bit();
15883 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15884 + }
15885 +#endif
15886 +
15887 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15888 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
15889 + prev->context.user_cs_limit != next->context.user_cs_limit))
15890 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15891 +#ifdef CONFIG_SMP
15892 + else if (unlikely(tlbstate != TLBSTATE_OK))
15893 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15894 +#endif
15895 +#endif
15896 +
15897 }
15898 + else {
15899 +
15900 +#ifdef CONFIG_PAX_PER_CPU_PGD
15901 + pax_open_kernel();
15902 +
15903 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15904 + if (static_cpu_has(X86_FEATURE_PCID))
15905 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
15906 + else
15907 +#endif
15908 +
15909 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
15910 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
15911 + pax_close_kernel();
15912 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
15913 +
15914 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15915 + if (static_cpu_has(X86_FEATURE_PCID)) {
15916 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
15917 + u64 descriptor[2];
15918 + descriptor[0] = PCID_USER;
15919 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
15920 + } else {
15921 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
15922 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
15923 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
15924 + else
15925 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
15926 + }
15927 + } else
15928 +#endif
15929 +
15930 + load_cr3(get_cpu_pgd(cpu, kernel));
15931 +#endif
15932 +
15933 #ifdef CONFIG_SMP
15934 - else {
15935 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
15936 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
15937
15938 @@ -70,11 +177,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
15939 * tlb flush IPI delivery. We must reload CR3
15940 * to make sure to use no freed page tables.
15941 */
15942 +
15943 +#ifndef CONFIG_PAX_PER_CPU_PGD
15944 load_cr3(next->pgd);
15945 +#endif
15946 +
15947 load_LDT_nolock(&next->context);
15948 +
15949 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
15950 + if (!(__supported_pte_mask & _PAGE_NX))
15951 + cpu_set(cpu, next->context.cpu_user_cs_mask);
15952 +#endif
15953 +
15954 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
15955 +#ifdef CONFIG_PAX_PAGEEXEC
15956 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
15957 +#endif
15958 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
15959 +#endif
15960 +
15961 }
15962 +#endif
15963 }
15964 -#endif
15965 }
15966
15967 #define activate_mm(prev, next) \
15968 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
15969 index e3b7819..b257c64 100644
15970 --- a/arch/x86/include/asm/module.h
15971 +++ b/arch/x86/include/asm/module.h
15972 @@ -5,6 +5,7 @@
15973
15974 #ifdef CONFIG_X86_64
15975 /* X86_64 does not define MODULE_PROC_FAMILY */
15976 +#define MODULE_PROC_FAMILY ""
15977 #elif defined CONFIG_M486
15978 #define MODULE_PROC_FAMILY "486 "
15979 #elif defined CONFIG_M586
15980 @@ -57,8 +58,20 @@
15981 #error unknown processor family
15982 #endif
15983
15984 -#ifdef CONFIG_X86_32
15985 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
15986 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
15987 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
15988 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
15989 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
15990 +#else
15991 +#define MODULE_PAX_KERNEXEC ""
15992 #endif
15993
15994 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15995 +#define MODULE_PAX_UDEREF "UDEREF "
15996 +#else
15997 +#define MODULE_PAX_UDEREF ""
15998 +#endif
15999 +
16000 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16001 +
16002 #endif /* _ASM_X86_MODULE_H */
16003 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16004 index 86f9301..b365cda 100644
16005 --- a/arch/x86/include/asm/nmi.h
16006 +++ b/arch/x86/include/asm/nmi.h
16007 @@ -40,11 +40,11 @@ struct nmiaction {
16008 nmi_handler_t handler;
16009 unsigned long flags;
16010 const char *name;
16011 -};
16012 +} __do_const;
16013
16014 #define register_nmi_handler(t, fn, fg, n, init...) \
16015 ({ \
16016 - static struct nmiaction init fn##_na = { \
16017 + static const struct nmiaction init fn##_na = { \
16018 .handler = (fn), \
16019 .name = (n), \
16020 .flags = (fg), \
16021 @@ -52,7 +52,7 @@ struct nmiaction {
16022 __register_nmi_handler((t), &fn##_na); \
16023 })
16024
16025 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16026 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16027
16028 void unregister_nmi_handler(unsigned int, const char *);
16029
16030 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16031 index c878924..21f4889 100644
16032 --- a/arch/x86/include/asm/page.h
16033 +++ b/arch/x86/include/asm/page.h
16034 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16035 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16036
16037 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16038 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16039
16040 #define __boot_va(x) __va(x)
16041 #define __boot_pa(x) __pa(x)
16042 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16043 index 0f1ddee..e2fc3d1 100644
16044 --- a/arch/x86/include/asm/page_64.h
16045 +++ b/arch/x86/include/asm/page_64.h
16046 @@ -7,9 +7,9 @@
16047
16048 /* duplicated to the one in bootmem.h */
16049 extern unsigned long max_pfn;
16050 -extern unsigned long phys_base;
16051 +extern const unsigned long phys_base;
16052
16053 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16054 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16055 {
16056 unsigned long y = x - __START_KERNEL_map;
16057
16058 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16059 index cfdc9ee..3f7b5d6 100644
16060 --- a/arch/x86/include/asm/paravirt.h
16061 +++ b/arch/x86/include/asm/paravirt.h
16062 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16063 return (pmd_t) { ret };
16064 }
16065
16066 -static inline pmdval_t pmd_val(pmd_t pmd)
16067 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16068 {
16069 pmdval_t ret;
16070
16071 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16072 val);
16073 }
16074
16075 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16076 +{
16077 + pgdval_t val = native_pgd_val(pgd);
16078 +
16079 + if (sizeof(pgdval_t) > sizeof(long))
16080 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16081 + val, (u64)val >> 32);
16082 + else
16083 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16084 + val);
16085 +}
16086 +
16087 static inline void pgd_clear(pgd_t *pgdp)
16088 {
16089 set_pgd(pgdp, __pgd(0));
16090 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16091 pv_mmu_ops.set_fixmap(idx, phys, flags);
16092 }
16093
16094 +#ifdef CONFIG_PAX_KERNEXEC
16095 +static inline unsigned long pax_open_kernel(void)
16096 +{
16097 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16098 +}
16099 +
16100 +static inline unsigned long pax_close_kernel(void)
16101 +{
16102 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16103 +}
16104 +#else
16105 +static inline unsigned long pax_open_kernel(void) { return 0; }
16106 +static inline unsigned long pax_close_kernel(void) { return 0; }
16107 +#endif
16108 +
16109 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16110
16111 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
16112 @@ -926,7 +953,7 @@ extern void default_banner(void);
16113
16114 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16115 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16116 -#define PARA_INDIRECT(addr) *%cs:addr
16117 +#define PARA_INDIRECT(addr) *%ss:addr
16118 #endif
16119
16120 #define INTERRUPT_RETURN \
16121 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
16122 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16123 CLBR_NONE, \
16124 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16125 +
16126 +#define GET_CR0_INTO_RDI \
16127 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16128 + mov %rax,%rdi
16129 +
16130 +#define SET_RDI_INTO_CR0 \
16131 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16132 +
16133 +#define GET_CR3_INTO_RDI \
16134 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16135 + mov %rax,%rdi
16136 +
16137 +#define SET_RDI_INTO_CR3 \
16138 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16139 +
16140 #endif /* CONFIG_X86_32 */
16141
16142 #endif /* __ASSEMBLY__ */
16143 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16144 index 0db1fca..52310cc 100644
16145 --- a/arch/x86/include/asm/paravirt_types.h
16146 +++ b/arch/x86/include/asm/paravirt_types.h
16147 @@ -84,7 +84,7 @@ struct pv_init_ops {
16148 */
16149 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16150 unsigned long addr, unsigned len);
16151 -};
16152 +} __no_const;
16153
16154
16155 struct pv_lazy_ops {
16156 @@ -98,7 +98,7 @@ struct pv_time_ops {
16157 unsigned long long (*sched_clock)(void);
16158 unsigned long long (*steal_clock)(int cpu);
16159 unsigned long (*get_tsc_khz)(void);
16160 -};
16161 +} __no_const;
16162
16163 struct pv_cpu_ops {
16164 /* hooks for various privileged instructions */
16165 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16166
16167 void (*start_context_switch)(struct task_struct *prev);
16168 void (*end_context_switch)(struct task_struct *next);
16169 -};
16170 +} __no_const;
16171
16172 struct pv_irq_ops {
16173 /*
16174 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16175 unsigned long start_eip,
16176 unsigned long start_esp);
16177 #endif
16178 -};
16179 +} __no_const;
16180
16181 struct pv_mmu_ops {
16182 unsigned long (*read_cr2)(void);
16183 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16184 struct paravirt_callee_save make_pud;
16185
16186 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16187 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16188 #endif /* PAGETABLE_LEVELS == 4 */
16189 #endif /* PAGETABLE_LEVELS >= 3 */
16190
16191 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16192 an mfn. We can tell which is which from the index. */
16193 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16194 phys_addr_t phys, pgprot_t flags);
16195 +
16196 +#ifdef CONFIG_PAX_KERNEXEC
16197 + unsigned long (*pax_open_kernel)(void);
16198 + unsigned long (*pax_close_kernel)(void);
16199 +#endif
16200 +
16201 };
16202
16203 struct arch_spinlock;
16204 @@ -334,7 +341,7 @@ struct pv_lock_ops {
16205 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
16206 int (*spin_trylock)(struct arch_spinlock *lock);
16207 void (*spin_unlock)(struct arch_spinlock *lock);
16208 -};
16209 +} __no_const;
16210
16211 /* This contains all the paravirt structures: we get a convenient
16212 * number for each function using the offset which we use to indicate
16213 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16214 index b4389a4..7024269 100644
16215 --- a/arch/x86/include/asm/pgalloc.h
16216 +++ b/arch/x86/include/asm/pgalloc.h
16217 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16218 pmd_t *pmd, pte_t *pte)
16219 {
16220 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16221 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16222 +}
16223 +
16224 +static inline void pmd_populate_user(struct mm_struct *mm,
16225 + pmd_t *pmd, pte_t *pte)
16226 +{
16227 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16228 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16229 }
16230
16231 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16232
16233 #ifdef CONFIG_X86_PAE
16234 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16235 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16236 +{
16237 + pud_populate(mm, pudp, pmd);
16238 +}
16239 #else /* !CONFIG_X86_PAE */
16240 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16241 {
16242 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16243 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16244 }
16245 +
16246 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16247 +{
16248 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16249 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16250 +}
16251 #endif /* CONFIG_X86_PAE */
16252
16253 #if PAGETABLE_LEVELS > 3
16254 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16255 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16256 }
16257
16258 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16259 +{
16260 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16261 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16262 +}
16263 +
16264 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16265 {
16266 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16267 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16268 index 3bf2dd0..23d2a9f 100644
16269 --- a/arch/x86/include/asm/pgtable-2level.h
16270 +++ b/arch/x86/include/asm/pgtable-2level.h
16271 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16272
16273 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16274 {
16275 + pax_open_kernel();
16276 *pmdp = pmd;
16277 + pax_close_kernel();
16278 }
16279
16280 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16281 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16282 index 81bb91b..9392125 100644
16283 --- a/arch/x86/include/asm/pgtable-3level.h
16284 +++ b/arch/x86/include/asm/pgtable-3level.h
16285 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16286
16287 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16288 {
16289 + pax_open_kernel();
16290 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16291 + pax_close_kernel();
16292 }
16293
16294 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16295 {
16296 + pax_open_kernel();
16297 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
16298 + pax_close_kernel();
16299 }
16300
16301 /*
16302 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
16303 index 1c00631..845f898 100644
16304 --- a/arch/x86/include/asm/pgtable.h
16305 +++ b/arch/x86/include/asm/pgtable.h
16306 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16307
16308 #ifndef __PAGETABLE_PUD_FOLDED
16309 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
16310 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
16311 #define pgd_clear(pgd) native_pgd_clear(pgd)
16312 #endif
16313
16314 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
16315
16316 #define arch_end_context_switch(prev) do {} while(0)
16317
16318 +#define pax_open_kernel() native_pax_open_kernel()
16319 +#define pax_close_kernel() native_pax_close_kernel()
16320 #endif /* CONFIG_PARAVIRT */
16321
16322 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
16323 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
16324 +
16325 +#ifdef CONFIG_PAX_KERNEXEC
16326 +static inline unsigned long native_pax_open_kernel(void)
16327 +{
16328 + unsigned long cr0;
16329 +
16330 + preempt_disable();
16331 + barrier();
16332 + cr0 = read_cr0() ^ X86_CR0_WP;
16333 + BUG_ON(cr0 & X86_CR0_WP);
16334 + write_cr0(cr0);
16335 + return cr0 ^ X86_CR0_WP;
16336 +}
16337 +
16338 +static inline unsigned long native_pax_close_kernel(void)
16339 +{
16340 + unsigned long cr0;
16341 +
16342 + cr0 = read_cr0() ^ X86_CR0_WP;
16343 + BUG_ON(!(cr0 & X86_CR0_WP));
16344 + write_cr0(cr0);
16345 + barrier();
16346 + preempt_enable_no_resched();
16347 + return cr0 ^ X86_CR0_WP;
16348 +}
16349 +#else
16350 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
16351 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
16352 +#endif
16353 +
16354 /*
16355 * The following only work if pte_present() is true.
16356 * Undefined behaviour if not..
16357 */
16358 +static inline int pte_user(pte_t pte)
16359 +{
16360 + return pte_val(pte) & _PAGE_USER;
16361 +}
16362 +
16363 static inline int pte_dirty(pte_t pte)
16364 {
16365 return pte_flags(pte) & _PAGE_DIRTY;
16366 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
16367 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
16368 }
16369
16370 +static inline unsigned long pgd_pfn(pgd_t pgd)
16371 +{
16372 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
16373 +}
16374 +
16375 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
16376
16377 static inline int pmd_large(pmd_t pte)
16378 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
16379 return pte_clear_flags(pte, _PAGE_RW);
16380 }
16381
16382 +static inline pte_t pte_mkread(pte_t pte)
16383 +{
16384 + return __pte(pte_val(pte) | _PAGE_USER);
16385 +}
16386 +
16387 static inline pte_t pte_mkexec(pte_t pte)
16388 {
16389 - return pte_clear_flags(pte, _PAGE_NX);
16390 +#ifdef CONFIG_X86_PAE
16391 + if (__supported_pte_mask & _PAGE_NX)
16392 + return pte_clear_flags(pte, _PAGE_NX);
16393 + else
16394 +#endif
16395 + return pte_set_flags(pte, _PAGE_USER);
16396 +}
16397 +
16398 +static inline pte_t pte_exprotect(pte_t pte)
16399 +{
16400 +#ifdef CONFIG_X86_PAE
16401 + if (__supported_pte_mask & _PAGE_NX)
16402 + return pte_set_flags(pte, _PAGE_NX);
16403 + else
16404 +#endif
16405 + return pte_clear_flags(pte, _PAGE_USER);
16406 }
16407
16408 static inline pte_t pte_mkdirty(pte_t pte)
16409 @@ -444,6 +509,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
16410 #endif
16411
16412 #ifndef __ASSEMBLY__
16413 +
16414 +#ifdef CONFIG_PAX_PER_CPU_PGD
16415 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
16416 +enum cpu_pgd_type {kernel = 0, user = 1};
16417 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
16418 +{
16419 + return cpu_pgd[cpu][type];
16420 +}
16421 +#endif
16422 +
16423 #include <linux/mm_types.h>
16424 #include <linux/log2.h>
16425
16426 @@ -576,7 +651,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
16427 * Currently stuck as a macro due to indirect forward reference to
16428 * linux/mmzone.h's __section_mem_map_addr() definition:
16429 */
16430 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
16431 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
16432
16433 /* Find an entry in the second-level page table.. */
16434 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
16435 @@ -616,7 +691,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
16436 * Currently stuck as a macro due to indirect forward reference to
16437 * linux/mmzone.h's __section_mem_map_addr() definition:
16438 */
16439 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
16440 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
16441
16442 /* to find an entry in a page-table-directory. */
16443 static inline unsigned long pud_index(unsigned long address)
16444 @@ -631,7 +706,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
16445
16446 static inline int pgd_bad(pgd_t pgd)
16447 {
16448 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
16449 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
16450 }
16451
16452 static inline int pgd_none(pgd_t pgd)
16453 @@ -654,7 +729,12 @@ static inline int pgd_none(pgd_t pgd)
16454 * pgd_offset() returns a (pgd_t *)
16455 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
16456 */
16457 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
16458 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
16459 +
16460 +#ifdef CONFIG_PAX_PER_CPU_PGD
16461 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
16462 +#endif
16463 +
16464 /*
16465 * a shortcut which implies the use of the kernel's pgd, instead
16466 * of a process's
16467 @@ -665,6 +745,23 @@ static inline int pgd_none(pgd_t pgd)
16468 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
16469 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
16470
16471 +#ifdef CONFIG_X86_32
16472 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
16473 +#else
16474 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
16475 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
16476 +
16477 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16478 +#ifdef __ASSEMBLY__
16479 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
16480 +#else
16481 +extern unsigned long pax_user_shadow_base;
16482 +extern pgdval_t clone_pgd_mask;
16483 +#endif
16484 +#endif
16485 +
16486 +#endif
16487 +
16488 #ifndef __ASSEMBLY__
16489
16490 extern int direct_gbpages;
16491 @@ -831,11 +928,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
16492 * dst and src can be on the same page, but the range must not overlap,
16493 * and must not cross a page boundary.
16494 */
16495 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
16496 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
16497 {
16498 - memcpy(dst, src, count * sizeof(pgd_t));
16499 + pax_open_kernel();
16500 + while (count--)
16501 + *dst++ = *src++;
16502 + pax_close_kernel();
16503 }
16504
16505 +#ifdef CONFIG_PAX_PER_CPU_PGD
16506 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
16507 +#endif
16508 +
16509 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16510 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
16511 +#else
16512 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
16513 +#endif
16514 +
16515 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
16516 static inline int page_level_shift(enum pg_level level)
16517 {
16518 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
16519 index 9ee3221..b979c6b 100644
16520 --- a/arch/x86/include/asm/pgtable_32.h
16521 +++ b/arch/x86/include/asm/pgtable_32.h
16522 @@ -25,9 +25,6 @@
16523 struct mm_struct;
16524 struct vm_area_struct;
16525
16526 -extern pgd_t swapper_pg_dir[1024];
16527 -extern pgd_t initial_page_table[1024];
16528 -
16529 static inline void pgtable_cache_init(void) { }
16530 static inline void check_pgt_cache(void) { }
16531 void paging_init(void);
16532 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16533 # include <asm/pgtable-2level.h>
16534 #endif
16535
16536 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
16537 +extern pgd_t initial_page_table[PTRS_PER_PGD];
16538 +#ifdef CONFIG_X86_PAE
16539 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
16540 +#endif
16541 +
16542 #if defined(CONFIG_HIGHPTE)
16543 #define pte_offset_map(dir, address) \
16544 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
16545 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
16546 /* Clear a kernel PTE and flush it from the TLB */
16547 #define kpte_clear_flush(ptep, vaddr) \
16548 do { \
16549 + pax_open_kernel(); \
16550 pte_clear(&init_mm, (vaddr), (ptep)); \
16551 + pax_close_kernel(); \
16552 __flush_tlb_one((vaddr)); \
16553 } while (0)
16554
16555 #endif /* !__ASSEMBLY__ */
16556
16557 +#define HAVE_ARCH_UNMAPPED_AREA
16558 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
16559 +
16560 /*
16561 * kern_addr_valid() is (1) for FLATMEM and (0) for
16562 * SPARSEMEM and DISCONTIGMEM
16563 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
16564 index ed5903b..c7fe163 100644
16565 --- a/arch/x86/include/asm/pgtable_32_types.h
16566 +++ b/arch/x86/include/asm/pgtable_32_types.h
16567 @@ -8,7 +8,7 @@
16568 */
16569 #ifdef CONFIG_X86_PAE
16570 # include <asm/pgtable-3level_types.h>
16571 -# define PMD_SIZE (1UL << PMD_SHIFT)
16572 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
16573 # define PMD_MASK (~(PMD_SIZE - 1))
16574 #else
16575 # include <asm/pgtable-2level_types.h>
16576 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
16577 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
16578 #endif
16579
16580 +#ifdef CONFIG_PAX_KERNEXEC
16581 +#ifndef __ASSEMBLY__
16582 +extern unsigned char MODULES_EXEC_VADDR[];
16583 +extern unsigned char MODULES_EXEC_END[];
16584 +#endif
16585 +#include <asm/boot.h>
16586 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
16587 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
16588 +#else
16589 +#define ktla_ktva(addr) (addr)
16590 +#define ktva_ktla(addr) (addr)
16591 +#endif
16592 +
16593 #define MODULES_VADDR VMALLOC_START
16594 #define MODULES_END VMALLOC_END
16595 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
16596 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
16597 index e22c1db..23a625a 100644
16598 --- a/arch/x86/include/asm/pgtable_64.h
16599 +++ b/arch/x86/include/asm/pgtable_64.h
16600 @@ -16,10 +16,14 @@
16601
16602 extern pud_t level3_kernel_pgt[512];
16603 extern pud_t level3_ident_pgt[512];
16604 +extern pud_t level3_vmalloc_start_pgt[512];
16605 +extern pud_t level3_vmalloc_end_pgt[512];
16606 +extern pud_t level3_vmemmap_pgt[512];
16607 +extern pud_t level2_vmemmap_pgt[512];
16608 extern pmd_t level2_kernel_pgt[512];
16609 extern pmd_t level2_fixmap_pgt[512];
16610 -extern pmd_t level2_ident_pgt[512];
16611 -extern pgd_t init_level4_pgt[];
16612 +extern pmd_t level2_ident_pgt[512*2];
16613 +extern pgd_t init_level4_pgt[512];
16614
16615 #define swapper_pg_dir init_level4_pgt
16616
16617 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16618
16619 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16620 {
16621 + pax_open_kernel();
16622 *pmdp = pmd;
16623 + pax_close_kernel();
16624 }
16625
16626 static inline void native_pmd_clear(pmd_t *pmd)
16627 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
16628
16629 static inline void native_set_pud(pud_t *pudp, pud_t pud)
16630 {
16631 + pax_open_kernel();
16632 *pudp = pud;
16633 + pax_close_kernel();
16634 }
16635
16636 static inline void native_pud_clear(pud_t *pud)
16637 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
16638
16639 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
16640 {
16641 + pax_open_kernel();
16642 + *pgdp = pgd;
16643 + pax_close_kernel();
16644 +}
16645 +
16646 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16647 +{
16648 *pgdp = pgd;
16649 }
16650
16651 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
16652 index 2d88344..4679fc3 100644
16653 --- a/arch/x86/include/asm/pgtable_64_types.h
16654 +++ b/arch/x86/include/asm/pgtable_64_types.h
16655 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
16656 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
16657 #define MODULES_END _AC(0xffffffffff000000, UL)
16658 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
16659 +#define MODULES_EXEC_VADDR MODULES_VADDR
16660 +#define MODULES_EXEC_END MODULES_END
16661 +
16662 +#define ktla_ktva(addr) (addr)
16663 +#define ktva_ktla(addr) (addr)
16664
16665 #define EARLY_DYNAMIC_PAGE_TABLES 64
16666
16667 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
16668 index f4843e0..a2526f8 100644
16669 --- a/arch/x86/include/asm/pgtable_types.h
16670 +++ b/arch/x86/include/asm/pgtable_types.h
16671 @@ -16,13 +16,12 @@
16672 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16673 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
16674 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
16675 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
16676 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
16677 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
16678 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
16679 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
16680 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
16681 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
16682 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
16683 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
16684 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
16685 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
16686
16687 /* If _PAGE_BIT_PRESENT is clear, we use these: */
16688 @@ -40,7 +39,6 @@
16689 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
16690 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
16691 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
16692 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
16693 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
16694 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
16695 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
16696 @@ -84,8 +82,10 @@
16697
16698 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
16699 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
16700 -#else
16701 +#elif defined(CONFIG_KMEMCHECK)
16702 #define _PAGE_NX (_AT(pteval_t, 0))
16703 +#else
16704 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
16705 #endif
16706
16707 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
16708 @@ -143,6 +143,9 @@
16709 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
16710 _PAGE_ACCESSED)
16711
16712 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
16713 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
16714 +
16715 #define __PAGE_KERNEL_EXEC \
16716 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
16717 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
16718 @@ -153,7 +156,7 @@
16719 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
16720 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
16721 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
16722 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
16723 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
16724 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
16725 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
16726 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
16727 @@ -215,8 +218,8 @@
16728 * bits are combined, this will alow user to access the high address mapped
16729 * VDSO in the presence of CONFIG_COMPAT_VDSO
16730 */
16731 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
16732 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
16733 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16734 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
16735 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
16736 #endif
16737
16738 @@ -254,7 +257,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
16739 {
16740 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
16741 }
16742 +#endif
16743
16744 +#if PAGETABLE_LEVELS == 3
16745 +#include <asm-generic/pgtable-nopud.h>
16746 +#endif
16747 +
16748 +#if PAGETABLE_LEVELS == 2
16749 +#include <asm-generic/pgtable-nopmd.h>
16750 +#endif
16751 +
16752 +#ifndef __ASSEMBLY__
16753 #if PAGETABLE_LEVELS > 3
16754 typedef struct { pudval_t pud; } pud_t;
16755
16756 @@ -268,8 +281,6 @@ static inline pudval_t native_pud_val(pud_t pud)
16757 return pud.pud;
16758 }
16759 #else
16760 -#include <asm-generic/pgtable-nopud.h>
16761 -
16762 static inline pudval_t native_pud_val(pud_t pud)
16763 {
16764 return native_pgd_val(pud.pgd);
16765 @@ -289,8 +300,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
16766 return pmd.pmd;
16767 }
16768 #else
16769 -#include <asm-generic/pgtable-nopmd.h>
16770 -
16771 static inline pmdval_t native_pmd_val(pmd_t pmd)
16772 {
16773 return native_pgd_val(pmd.pud.pgd);
16774 @@ -330,7 +339,6 @@ typedef struct page *pgtable_t;
16775
16776 extern pteval_t __supported_pte_mask;
16777 extern void set_nx(void);
16778 -extern int nx_enabled;
16779
16780 #define pgprot_writecombine pgprot_writecombine
16781 extern pgprot_t pgprot_writecombine(pgprot_t prot);
16782 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
16783 index 24cf5ae..4d9fa2d 100644
16784 --- a/arch/x86/include/asm/processor.h
16785 +++ b/arch/x86/include/asm/processor.h
16786 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
16787 : "memory");
16788 }
16789
16790 +/* invpcid (%rdx),%rax */
16791 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
16792 +
16793 +#define INVPCID_SINGLE_ADDRESS 0UL
16794 +#define INVPCID_SINGLE_CONTEXT 1UL
16795 +#define INVPCID_ALL_GLOBAL 2UL
16796 +#define INVPCID_ALL_MONGLOBAL 3UL
16797 +
16798 +#define PCID_KERNEL 0UL
16799 +#define PCID_USER 1UL
16800 +#define PCID_NOFLUSH (1UL << 63)
16801 +
16802 static inline void load_cr3(pgd_t *pgdir)
16803 {
16804 - write_cr3(__pa(pgdir));
16805 + write_cr3(__pa(pgdir) | PCID_KERNEL);
16806 }
16807
16808 #ifdef CONFIG_X86_32
16809 @@ -283,7 +295,7 @@ struct tss_struct {
16810
16811 } ____cacheline_aligned;
16812
16813 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
16814 +extern struct tss_struct init_tss[NR_CPUS];
16815
16816 /*
16817 * Save the original ist values for checking stack pointers during debugging
16818 @@ -453,6 +465,7 @@ struct thread_struct {
16819 unsigned short ds;
16820 unsigned short fsindex;
16821 unsigned short gsindex;
16822 + unsigned short ss;
16823 #endif
16824 #ifdef CONFIG_X86_32
16825 unsigned long ip;
16826 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
16827 extern unsigned long mmu_cr4_features;
16828 extern u32 *trampoline_cr4_features;
16829
16830 -static inline void set_in_cr4(unsigned long mask)
16831 -{
16832 - unsigned long cr4;
16833 -
16834 - mmu_cr4_features |= mask;
16835 - if (trampoline_cr4_features)
16836 - *trampoline_cr4_features = mmu_cr4_features;
16837 - cr4 = read_cr4();
16838 - cr4 |= mask;
16839 - write_cr4(cr4);
16840 -}
16841 -
16842 -static inline void clear_in_cr4(unsigned long mask)
16843 -{
16844 - unsigned long cr4;
16845 -
16846 - mmu_cr4_features &= ~mask;
16847 - if (trampoline_cr4_features)
16848 - *trampoline_cr4_features = mmu_cr4_features;
16849 - cr4 = read_cr4();
16850 - cr4 &= ~mask;
16851 - write_cr4(cr4);
16852 -}
16853 +extern void set_in_cr4(unsigned long mask);
16854 +extern void clear_in_cr4(unsigned long mask);
16855
16856 typedef struct {
16857 unsigned long seg;
16858 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
16859 */
16860 #define TASK_SIZE PAGE_OFFSET
16861 #define TASK_SIZE_MAX TASK_SIZE
16862 +
16863 +#ifdef CONFIG_PAX_SEGMEXEC
16864 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
16865 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
16866 +#else
16867 #define STACK_TOP TASK_SIZE
16868 -#define STACK_TOP_MAX STACK_TOP
16869 +#endif
16870 +
16871 +#define STACK_TOP_MAX TASK_SIZE
16872
16873 #define INIT_THREAD { \
16874 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16875 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16876 .vm86_info = NULL, \
16877 .sysenter_cs = __KERNEL_CS, \
16878 .io_bitmap_ptr = NULL, \
16879 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
16880 */
16881 #define INIT_TSS { \
16882 .x86_tss = { \
16883 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
16884 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
16885 .ss0 = __KERNEL_DS, \
16886 .ss1 = __KERNEL_CS, \
16887 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
16888 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
16889 extern unsigned long thread_saved_pc(struct task_struct *tsk);
16890
16891 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
16892 -#define KSTK_TOP(info) \
16893 -({ \
16894 - unsigned long *__ptr = (unsigned long *)(info); \
16895 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
16896 -})
16897 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
16898
16899 /*
16900 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
16901 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16902 #define task_pt_regs(task) \
16903 ({ \
16904 struct pt_regs *__regs__; \
16905 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
16906 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
16907 __regs__ - 1; \
16908 })
16909
16910 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16911 /*
16912 * User space process size. 47bits minus one guard page.
16913 */
16914 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
16915 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
16916
16917 /* This decides where the kernel will search for a free chunk of vm
16918 * space during mmap's.
16919 */
16920 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
16921 - 0xc0000000 : 0xFFFFe000)
16922 + 0xc0000000 : 0xFFFFf000)
16923
16924 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
16925 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
16926 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
16927 #define STACK_TOP_MAX TASK_SIZE_MAX
16928
16929 #define INIT_THREAD { \
16930 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16931 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16932 }
16933
16934 #define INIT_TSS { \
16935 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
16936 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
16937 }
16938
16939 /*
16940 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
16941 */
16942 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
16943
16944 +#ifdef CONFIG_PAX_SEGMEXEC
16945 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
16946 +#endif
16947 +
16948 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
16949
16950 /* Get/set a process' ability to use the timestamp counter instruction */
16951 @@ -943,7 +942,8 @@ extern int set_tsc_mode(unsigned int val);
16952 extern u16 amd_get_nb_id(int cpu);
16953
16954 struct aperfmperf {
16955 - u64 aperf, mperf;
16956 + u64 aperf __intentional_overflow(0);
16957 + u64 mperf __intentional_overflow(0);
16958 };
16959
16960 static inline void get_aperfmperf(struct aperfmperf *am)
16961 @@ -971,7 +971,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
16962 return ratio;
16963 }
16964
16965 -extern unsigned long arch_align_stack(unsigned long sp);
16966 +#define arch_align_stack(x) ((x) & ~0xfUL)
16967 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
16968
16969 void default_idle(void);
16970 @@ -981,6 +981,6 @@ bool xen_set_default_idle(void);
16971 #define xen_set_default_idle 0
16972 #endif
16973
16974 -void stop_this_cpu(void *dummy);
16975 +void stop_this_cpu(void *dummy) __noreturn;
16976 void df_debug(struct pt_regs *regs, long error_code);
16977 #endif /* _ASM_X86_PROCESSOR_H */
16978 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
16979 index 942a086..6c26446 100644
16980 --- a/arch/x86/include/asm/ptrace.h
16981 +++ b/arch/x86/include/asm/ptrace.h
16982 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
16983 }
16984
16985 /*
16986 - * user_mode_vm(regs) determines whether a register set came from user mode.
16987 + * user_mode(regs) determines whether a register set came from user mode.
16988 * This is true if V8086 mode was enabled OR if the register set was from
16989 * protected mode with RPL-3 CS value. This tricky test checks that with
16990 * one comparison. Many places in the kernel can bypass this full check
16991 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
16992 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
16993 + * be used.
16994 */
16995 -static inline int user_mode(struct pt_regs *regs)
16996 +static inline int user_mode_novm(struct pt_regs *regs)
16997 {
16998 #ifdef CONFIG_X86_32
16999 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17000 #else
17001 - return !!(regs->cs & 3);
17002 + return !!(regs->cs & SEGMENT_RPL_MASK);
17003 #endif
17004 }
17005
17006 -static inline int user_mode_vm(struct pt_regs *regs)
17007 +static inline int user_mode(struct pt_regs *regs)
17008 {
17009 #ifdef CONFIG_X86_32
17010 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17011 USER_RPL;
17012 #else
17013 - return user_mode(regs);
17014 + return user_mode_novm(regs);
17015 #endif
17016 }
17017
17018 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17019 #ifdef CONFIG_X86_64
17020 static inline bool user_64bit_mode(struct pt_regs *regs)
17021 {
17022 + unsigned long cs = regs->cs & 0xffff;
17023 #ifndef CONFIG_PARAVIRT
17024 /*
17025 * On non-paravirt systems, this is the only long mode CPL 3
17026 * selector. We do not allow long mode selectors in the LDT.
17027 */
17028 - return regs->cs == __USER_CS;
17029 + return cs == __USER_CS;
17030 #else
17031 /* Headers are too twisted for this to go in paravirt.h. */
17032 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17033 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17034 #endif
17035 }
17036
17037 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17038 * Traps from the kernel do not save sp and ss.
17039 * Use the helper function to retrieve sp.
17040 */
17041 - if (offset == offsetof(struct pt_regs, sp) &&
17042 - regs->cs == __KERNEL_CS)
17043 - return kernel_stack_pointer(regs);
17044 + if (offset == offsetof(struct pt_regs, sp)) {
17045 + unsigned long cs = regs->cs & 0xffff;
17046 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17047 + return kernel_stack_pointer(regs);
17048 + }
17049 #endif
17050 return *(unsigned long *)((unsigned long)regs + offset);
17051 }
17052 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17053 index 9c6b890..5305f53 100644
17054 --- a/arch/x86/include/asm/realmode.h
17055 +++ b/arch/x86/include/asm/realmode.h
17056 @@ -22,16 +22,14 @@ struct real_mode_header {
17057 #endif
17058 /* APM/BIOS reboot */
17059 u32 machine_real_restart_asm;
17060 -#ifdef CONFIG_X86_64
17061 u32 machine_real_restart_seg;
17062 -#endif
17063 };
17064
17065 /* This must match data at trampoline_32/64.S */
17066 struct trampoline_header {
17067 #ifdef CONFIG_X86_32
17068 u32 start;
17069 - u16 gdt_pad;
17070 + u16 boot_cs;
17071 u16 gdt_limit;
17072 u32 gdt_base;
17073 #else
17074 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17075 index a82c4f1..ac45053 100644
17076 --- a/arch/x86/include/asm/reboot.h
17077 +++ b/arch/x86/include/asm/reboot.h
17078 @@ -6,13 +6,13 @@
17079 struct pt_regs;
17080
17081 struct machine_ops {
17082 - void (*restart)(char *cmd);
17083 - void (*halt)(void);
17084 - void (*power_off)(void);
17085 + void (* __noreturn restart)(char *cmd);
17086 + void (* __noreturn halt)(void);
17087 + void (* __noreturn power_off)(void);
17088 void (*shutdown)(void);
17089 void (*crash_shutdown)(struct pt_regs *);
17090 - void (*emergency_restart)(void);
17091 -};
17092 + void (* __noreturn emergency_restart)(void);
17093 +} __no_const;
17094
17095 extern struct machine_ops machine_ops;
17096
17097 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17098 index cad82c9..2e5c5c1 100644
17099 --- a/arch/x86/include/asm/rwsem.h
17100 +++ b/arch/x86/include/asm/rwsem.h
17101 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17102 {
17103 asm volatile("# beginning down_read\n\t"
17104 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17105 +
17106 +#ifdef CONFIG_PAX_REFCOUNT
17107 + "jno 0f\n"
17108 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17109 + "int $4\n0:\n"
17110 + _ASM_EXTABLE(0b, 0b)
17111 +#endif
17112 +
17113 /* adds 0x00000001 */
17114 " jns 1f\n"
17115 " call call_rwsem_down_read_failed\n"
17116 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17117 "1:\n\t"
17118 " mov %1,%2\n\t"
17119 " add %3,%2\n\t"
17120 +
17121 +#ifdef CONFIG_PAX_REFCOUNT
17122 + "jno 0f\n"
17123 + "sub %3,%2\n"
17124 + "int $4\n0:\n"
17125 + _ASM_EXTABLE(0b, 0b)
17126 +#endif
17127 +
17128 " jle 2f\n\t"
17129 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17130 " jnz 1b\n\t"
17131 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17132 long tmp;
17133 asm volatile("# beginning down_write\n\t"
17134 LOCK_PREFIX " xadd %1,(%2)\n\t"
17135 +
17136 +#ifdef CONFIG_PAX_REFCOUNT
17137 + "jno 0f\n"
17138 + "mov %1,(%2)\n"
17139 + "int $4\n0:\n"
17140 + _ASM_EXTABLE(0b, 0b)
17141 +#endif
17142 +
17143 /* adds 0xffff0001, returns the old value */
17144 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17145 /* was the active mask 0 before? */
17146 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17147 long tmp;
17148 asm volatile("# beginning __up_read\n\t"
17149 LOCK_PREFIX " xadd %1,(%2)\n\t"
17150 +
17151 +#ifdef CONFIG_PAX_REFCOUNT
17152 + "jno 0f\n"
17153 + "mov %1,(%2)\n"
17154 + "int $4\n0:\n"
17155 + _ASM_EXTABLE(0b, 0b)
17156 +#endif
17157 +
17158 /* subtracts 1, returns the old value */
17159 " jns 1f\n\t"
17160 " call call_rwsem_wake\n" /* expects old value in %edx */
17161 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17162 long tmp;
17163 asm volatile("# beginning __up_write\n\t"
17164 LOCK_PREFIX " xadd %1,(%2)\n\t"
17165 +
17166 +#ifdef CONFIG_PAX_REFCOUNT
17167 + "jno 0f\n"
17168 + "mov %1,(%2)\n"
17169 + "int $4\n0:\n"
17170 + _ASM_EXTABLE(0b, 0b)
17171 +#endif
17172 +
17173 /* subtracts 0xffff0001, returns the old value */
17174 " jns 1f\n\t"
17175 " call call_rwsem_wake\n" /* expects old value in %edx */
17176 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17177 {
17178 asm volatile("# beginning __downgrade_write\n\t"
17179 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17180 +
17181 +#ifdef CONFIG_PAX_REFCOUNT
17182 + "jno 0f\n"
17183 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17184 + "int $4\n0:\n"
17185 + _ASM_EXTABLE(0b, 0b)
17186 +#endif
17187 +
17188 /*
17189 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17190 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17191 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17192 */
17193 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17194 {
17195 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17196 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17197 +
17198 +#ifdef CONFIG_PAX_REFCOUNT
17199 + "jno 0f\n"
17200 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17201 + "int $4\n0:\n"
17202 + _ASM_EXTABLE(0b, 0b)
17203 +#endif
17204 +
17205 : "+m" (sem->count)
17206 : "er" (delta));
17207 }
17208 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17209 */
17210 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17211 {
17212 - return delta + xadd(&sem->count, delta);
17213 + return delta + xadd_check_overflow(&sem->count, delta);
17214 }
17215
17216 #endif /* __KERNEL__ */
17217 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17218 index c48a950..bc40804 100644
17219 --- a/arch/x86/include/asm/segment.h
17220 +++ b/arch/x86/include/asm/segment.h
17221 @@ -64,10 +64,15 @@
17222 * 26 - ESPFIX small SS
17223 * 27 - per-cpu [ offset to per-cpu data area ]
17224 * 28 - stack_canary-20 [ for stack protector ]
17225 - * 29 - unused
17226 - * 30 - unused
17227 + * 29 - PCI BIOS CS
17228 + * 30 - PCI BIOS DS
17229 * 31 - TSS for double fault handler
17230 */
17231 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17232 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17233 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17234 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17235 +
17236 #define GDT_ENTRY_TLS_MIN 6
17237 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17238
17239 @@ -79,6 +84,8 @@
17240
17241 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17242
17243 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17244 +
17245 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17246
17247 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17248 @@ -104,6 +111,12 @@
17249 #define __KERNEL_STACK_CANARY 0
17250 #endif
17251
17252 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17253 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17254 +
17255 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17256 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17257 +
17258 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17259
17260 /*
17261 @@ -141,7 +154,7 @@
17262 */
17263
17264 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17265 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17266 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17267
17268
17269 #else
17270 @@ -165,6 +178,8 @@
17271 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17272 #define __USER32_DS __USER_DS
17273
17274 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17275 +
17276 #define GDT_ENTRY_TSS 8 /* needs two entries */
17277 #define GDT_ENTRY_LDT 10 /* needs two entries */
17278 #define GDT_ENTRY_TLS_MIN 12
17279 @@ -173,6 +188,8 @@
17280 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17281 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17282
17283 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17284 +
17285 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17286 #define FS_TLS 0
17287 #define GS_TLS 1
17288 @@ -180,12 +197,14 @@
17289 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17290 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17291
17292 -#define GDT_ENTRIES 16
17293 +#define GDT_ENTRIES 17
17294
17295 #endif
17296
17297 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17298 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17299 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17300 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17301 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17302 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17303 #ifndef CONFIG_PARAVIRT
17304 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
17305 {
17306 unsigned long __limit;
17307 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
17308 - return __limit + 1;
17309 + return __limit;
17310 }
17311
17312 #endif /* !__ASSEMBLY__ */
17313 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
17314 index 8d3120f..352b440 100644
17315 --- a/arch/x86/include/asm/smap.h
17316 +++ b/arch/x86/include/asm/smap.h
17317 @@ -25,11 +25,40 @@
17318
17319 #include <asm/alternative-asm.h>
17320
17321 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17322 +#define ASM_PAX_OPEN_USERLAND \
17323 + 661: jmp 663f; \
17324 + .pushsection .altinstr_replacement, "a" ; \
17325 + 662: pushq %rax; nop; \
17326 + .popsection ; \
17327 + .pushsection .altinstructions, "a" ; \
17328 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17329 + .popsection ; \
17330 + call __pax_open_userland; \
17331 + popq %rax; \
17332 + 663:
17333 +
17334 +#define ASM_PAX_CLOSE_USERLAND \
17335 + 661: jmp 663f; \
17336 + .pushsection .altinstr_replacement, "a" ; \
17337 + 662: pushq %rax; nop; \
17338 + .popsection; \
17339 + .pushsection .altinstructions, "a" ; \
17340 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
17341 + .popsection; \
17342 + call __pax_close_userland; \
17343 + popq %rax; \
17344 + 663:
17345 +#else
17346 +#define ASM_PAX_OPEN_USERLAND
17347 +#define ASM_PAX_CLOSE_USERLAND
17348 +#endif
17349 +
17350 #ifdef CONFIG_X86_SMAP
17351
17352 #define ASM_CLAC \
17353 661: ASM_NOP3 ; \
17354 - .pushsection .altinstr_replacement, "ax" ; \
17355 + .pushsection .altinstr_replacement, "a" ; \
17356 662: __ASM_CLAC ; \
17357 .popsection ; \
17358 .pushsection .altinstructions, "a" ; \
17359 @@ -38,7 +67,7 @@
17360
17361 #define ASM_STAC \
17362 661: ASM_NOP3 ; \
17363 - .pushsection .altinstr_replacement, "ax" ; \
17364 + .pushsection .altinstr_replacement, "a" ; \
17365 662: __ASM_STAC ; \
17366 .popsection ; \
17367 .pushsection .altinstructions, "a" ; \
17368 @@ -56,6 +85,37 @@
17369
17370 #include <asm/alternative.h>
17371
17372 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
17373 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
17374 +
17375 +extern void __pax_open_userland(void);
17376 +static __always_inline unsigned long pax_open_userland(void)
17377 +{
17378 +
17379 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17380 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
17381 + :
17382 + : [open] "i" (__pax_open_userland)
17383 + : "memory", "rax");
17384 +#endif
17385 +
17386 + return 0;
17387 +}
17388 +
17389 +extern void __pax_close_userland(void);
17390 +static __always_inline unsigned long pax_close_userland(void)
17391 +{
17392 +
17393 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17394 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
17395 + :
17396 + : [close] "i" (__pax_close_userland)
17397 + : "memory", "rax");
17398 +#endif
17399 +
17400 + return 0;
17401 +}
17402 +
17403 #ifdef CONFIG_X86_SMAP
17404
17405 static __always_inline void clac(void)
17406 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
17407 index 4137890..03fa172 100644
17408 --- a/arch/x86/include/asm/smp.h
17409 +++ b/arch/x86/include/asm/smp.h
17410 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
17411 /* cpus sharing the last level cache: */
17412 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
17413 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
17414 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
17415 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
17416
17417 static inline struct cpumask *cpu_sibling_mask(int cpu)
17418 {
17419 @@ -79,7 +79,7 @@ struct smp_ops {
17420
17421 void (*send_call_func_ipi)(const struct cpumask *mask);
17422 void (*send_call_func_single_ipi)(int cpu);
17423 -};
17424 +} __no_const;
17425
17426 /* Globals due to paravirt */
17427 extern void set_cpu_sibling_map(int cpu);
17428 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
17429 extern int safe_smp_processor_id(void);
17430
17431 #elif defined(CONFIG_X86_64_SMP)
17432 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17433 -
17434 -#define stack_smp_processor_id() \
17435 -({ \
17436 - struct thread_info *ti; \
17437 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
17438 - ti->cpu; \
17439 -})
17440 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
17441 +#define stack_smp_processor_id() raw_smp_processor_id()
17442 #define safe_smp_processor_id() smp_processor_id()
17443
17444 #endif
17445 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
17446 index e3ddd7d..3611fce 100644
17447 --- a/arch/x86/include/asm/spinlock.h
17448 +++ b/arch/x86/include/asm/spinlock.h
17449 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
17450 static inline void arch_read_lock(arch_rwlock_t *rw)
17451 {
17452 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
17453 +
17454 +#ifdef CONFIG_PAX_REFCOUNT
17455 + "jno 0f\n"
17456 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
17457 + "int $4\n0:\n"
17458 + _ASM_EXTABLE(0b, 0b)
17459 +#endif
17460 +
17461 "jns 1f\n"
17462 "call __read_lock_failed\n\t"
17463 "1:\n"
17464 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
17465 static inline void arch_write_lock(arch_rwlock_t *rw)
17466 {
17467 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
17468 +
17469 +#ifdef CONFIG_PAX_REFCOUNT
17470 + "jno 0f\n"
17471 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
17472 + "int $4\n0:\n"
17473 + _ASM_EXTABLE(0b, 0b)
17474 +#endif
17475 +
17476 "jz 1f\n"
17477 "call __write_lock_failed\n\t"
17478 "1:\n"
17479 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
17480
17481 static inline void arch_read_unlock(arch_rwlock_t *rw)
17482 {
17483 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
17484 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
17485 +
17486 +#ifdef CONFIG_PAX_REFCOUNT
17487 + "jno 0f\n"
17488 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
17489 + "int $4\n0:\n"
17490 + _ASM_EXTABLE(0b, 0b)
17491 +#endif
17492 +
17493 :"+m" (rw->lock) : : "memory");
17494 }
17495
17496 static inline void arch_write_unlock(arch_rwlock_t *rw)
17497 {
17498 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
17499 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
17500 +
17501 +#ifdef CONFIG_PAX_REFCOUNT
17502 + "jno 0f\n"
17503 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
17504 + "int $4\n0:\n"
17505 + _ASM_EXTABLE(0b, 0b)
17506 +#endif
17507 +
17508 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
17509 }
17510
17511 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
17512 index 6a99859..03cb807 100644
17513 --- a/arch/x86/include/asm/stackprotector.h
17514 +++ b/arch/x86/include/asm/stackprotector.h
17515 @@ -47,7 +47,7 @@
17516 * head_32 for boot CPU and setup_per_cpu_areas() for others.
17517 */
17518 #define GDT_STACK_CANARY_INIT \
17519 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
17520 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
17521
17522 /*
17523 * Initialize the stackprotector canary value.
17524 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
17525
17526 static inline void load_stack_canary_segment(void)
17527 {
17528 -#ifdef CONFIG_X86_32
17529 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
17530 asm volatile ("mov %0, %%gs" : : "r" (0));
17531 #endif
17532 }
17533 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
17534 index 70bbe39..4ae2bd4 100644
17535 --- a/arch/x86/include/asm/stacktrace.h
17536 +++ b/arch/x86/include/asm/stacktrace.h
17537 @@ -11,28 +11,20 @@
17538
17539 extern int kstack_depth_to_print;
17540
17541 -struct thread_info;
17542 +struct task_struct;
17543 struct stacktrace_ops;
17544
17545 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
17546 - unsigned long *stack,
17547 - unsigned long bp,
17548 - const struct stacktrace_ops *ops,
17549 - void *data,
17550 - unsigned long *end,
17551 - int *graph);
17552 +typedef unsigned long walk_stack_t(struct task_struct *task,
17553 + void *stack_start,
17554 + unsigned long *stack,
17555 + unsigned long bp,
17556 + const struct stacktrace_ops *ops,
17557 + void *data,
17558 + unsigned long *end,
17559 + int *graph);
17560
17561 -extern unsigned long
17562 -print_context_stack(struct thread_info *tinfo,
17563 - unsigned long *stack, unsigned long bp,
17564 - const struct stacktrace_ops *ops, void *data,
17565 - unsigned long *end, int *graph);
17566 -
17567 -extern unsigned long
17568 -print_context_stack_bp(struct thread_info *tinfo,
17569 - unsigned long *stack, unsigned long bp,
17570 - const struct stacktrace_ops *ops, void *data,
17571 - unsigned long *end, int *graph);
17572 +extern walk_stack_t print_context_stack;
17573 +extern walk_stack_t print_context_stack_bp;
17574
17575 /* Generic stack tracer with callbacks */
17576
17577 @@ -40,7 +32,7 @@ struct stacktrace_ops {
17578 void (*address)(void *data, unsigned long address, int reliable);
17579 /* On negative return stop dumping */
17580 int (*stack)(void *data, char *name);
17581 - walk_stack_t walk_stack;
17582 + walk_stack_t *walk_stack;
17583 };
17584
17585 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
17586 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
17587 index 4ec45b3..a4f0a8a 100644
17588 --- a/arch/x86/include/asm/switch_to.h
17589 +++ b/arch/x86/include/asm/switch_to.h
17590 @@ -108,7 +108,7 @@ do { \
17591 "call __switch_to\n\t" \
17592 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
17593 __switch_canary \
17594 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
17595 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
17596 "movq %%rax,%%rdi\n\t" \
17597 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
17598 "jnz ret_from_fork\n\t" \
17599 @@ -119,7 +119,7 @@ do { \
17600 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
17601 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
17602 [_tif_fork] "i" (_TIF_FORK), \
17603 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
17604 + [thread_info] "m" (current_tinfo), \
17605 [current_task] "m" (current_task) \
17606 __switch_canary_iparam \
17607 : "memory", "cc" __EXTRA_CLOBBER)
17608 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
17609 index 2781119..618b59b 100644
17610 --- a/arch/x86/include/asm/thread_info.h
17611 +++ b/arch/x86/include/asm/thread_info.h
17612 @@ -10,6 +10,7 @@
17613 #include <linux/compiler.h>
17614 #include <asm/page.h>
17615 #include <asm/types.h>
17616 +#include <asm/percpu.h>
17617
17618 /*
17619 * low level task data that entry.S needs immediate access to
17620 @@ -23,7 +24,6 @@ struct exec_domain;
17621 #include <linux/atomic.h>
17622
17623 struct thread_info {
17624 - struct task_struct *task; /* main task structure */
17625 struct exec_domain *exec_domain; /* execution domain */
17626 __u32 flags; /* low level flags */
17627 __u32 status; /* thread synchronous flags */
17628 @@ -33,19 +33,13 @@ struct thread_info {
17629 mm_segment_t addr_limit;
17630 struct restart_block restart_block;
17631 void __user *sysenter_return;
17632 -#ifdef CONFIG_X86_32
17633 - unsigned long previous_esp; /* ESP of the previous stack in
17634 - case of nested (IRQ) stacks
17635 - */
17636 - __u8 supervisor_stack[0];
17637 -#endif
17638 + unsigned long lowest_stack;
17639 unsigned int sig_on_uaccess_error:1;
17640 unsigned int uaccess_err:1; /* uaccess failed */
17641 };
17642
17643 -#define INIT_THREAD_INFO(tsk) \
17644 +#define INIT_THREAD_INFO \
17645 { \
17646 - .task = &tsk, \
17647 .exec_domain = &default_exec_domain, \
17648 .flags = 0, \
17649 .cpu = 0, \
17650 @@ -56,7 +50,7 @@ struct thread_info {
17651 }, \
17652 }
17653
17654 -#define init_thread_info (init_thread_union.thread_info)
17655 +#define init_thread_info (init_thread_union.stack)
17656 #define init_stack (init_thread_union.stack)
17657
17658 #else /* !__ASSEMBLY__ */
17659 @@ -96,6 +90,7 @@ struct thread_info {
17660 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
17661 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
17662 #define TIF_X32 30 /* 32-bit native x86-64 binary */
17663 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
17664
17665 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
17666 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
17667 @@ -119,17 +114,18 @@ struct thread_info {
17668 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
17669 #define _TIF_ADDR32 (1 << TIF_ADDR32)
17670 #define _TIF_X32 (1 << TIF_X32)
17671 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
17672
17673 /* work to do in syscall_trace_enter() */
17674 #define _TIF_WORK_SYSCALL_ENTRY \
17675 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
17676 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
17677 - _TIF_NOHZ)
17678 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17679
17680 /* work to do in syscall_trace_leave() */
17681 #define _TIF_WORK_SYSCALL_EXIT \
17682 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
17683 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
17684 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
17685
17686 /* work to do on interrupt/exception return */
17687 #define _TIF_WORK_MASK \
17688 @@ -140,7 +136,7 @@ struct thread_info {
17689 /* work to do on any return to user space */
17690 #define _TIF_ALLWORK_MASK \
17691 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
17692 - _TIF_NOHZ)
17693 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
17694
17695 /* Only used for 64 bit */
17696 #define _TIF_DO_NOTIFY_MASK \
17697 @@ -156,45 +152,40 @@ struct thread_info {
17698
17699 #define PREEMPT_ACTIVE 0x10000000
17700
17701 -#ifdef CONFIG_X86_32
17702 -
17703 -#define STACK_WARN (THREAD_SIZE/8)
17704 -/*
17705 - * macros/functions for gaining access to the thread information structure
17706 - *
17707 - * preempt_count needs to be 1 initially, until the scheduler is functional.
17708 - */
17709 -#ifndef __ASSEMBLY__
17710 -
17711 -
17712 -/* how to get the current stack pointer from C */
17713 -register unsigned long current_stack_pointer asm("esp") __used;
17714 -
17715 -/* how to get the thread information struct from C */
17716 -static inline struct thread_info *current_thread_info(void)
17717 -{
17718 - return (struct thread_info *)
17719 - (current_stack_pointer & ~(THREAD_SIZE - 1));
17720 -}
17721 -
17722 -#else /* !__ASSEMBLY__ */
17723 -
17724 +#ifdef __ASSEMBLY__
17725 /* how to get the thread information struct from ASM */
17726 #define GET_THREAD_INFO(reg) \
17727 - movl $-THREAD_SIZE, reg; \
17728 - andl %esp, reg
17729 + mov PER_CPU_VAR(current_tinfo), reg
17730
17731 /* use this one if reg already contains %esp */
17732 -#define GET_THREAD_INFO_WITH_ESP(reg) \
17733 - andl $-THREAD_SIZE, reg
17734 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
17735 +#else
17736 +/* how to get the thread information struct from C */
17737 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
17738 +
17739 +static __always_inline struct thread_info *current_thread_info(void)
17740 +{
17741 + return this_cpu_read_stable(current_tinfo);
17742 +}
17743 +#endif
17744 +
17745 +#ifdef CONFIG_X86_32
17746 +
17747 +#define STACK_WARN (THREAD_SIZE/8)
17748 +/*
17749 + * macros/functions for gaining access to the thread information structure
17750 + *
17751 + * preempt_count needs to be 1 initially, until the scheduler is functional.
17752 + */
17753 +#ifndef __ASSEMBLY__
17754 +
17755 +/* how to get the current stack pointer from C */
17756 +register unsigned long current_stack_pointer asm("esp") __used;
17757
17758 #endif
17759
17760 #else /* X86_32 */
17761
17762 -#include <asm/percpu.h>
17763 -#define KERNEL_STACK_OFFSET (5*8)
17764 -
17765 /*
17766 * macros/functions for gaining access to the thread information structure
17767 * preempt_count needs to be 1 initially, until the scheduler is functional.
17768 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
17769 #ifndef __ASSEMBLY__
17770 DECLARE_PER_CPU(unsigned long, kernel_stack);
17771
17772 -static inline struct thread_info *current_thread_info(void)
17773 -{
17774 - struct thread_info *ti;
17775 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
17776 - KERNEL_STACK_OFFSET - THREAD_SIZE);
17777 - return ti;
17778 -}
17779 -
17780 -#else /* !__ASSEMBLY__ */
17781 -
17782 -/* how to get the thread information struct from ASM */
17783 -#define GET_THREAD_INFO(reg) \
17784 - movq PER_CPU_VAR(kernel_stack),reg ; \
17785 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
17786 -
17787 -/*
17788 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
17789 - * a certain register (to be used in assembler memory operands).
17790 - */
17791 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
17792 -
17793 +/* how to get the current stack pointer from C */
17794 +register unsigned long current_stack_pointer asm("rsp") __used;
17795 #endif
17796
17797 #endif /* !X86_32 */
17798 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
17799 extern void arch_task_cache_init(void);
17800 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
17801 extern void arch_release_task_struct(struct task_struct *tsk);
17802 +
17803 +#define __HAVE_THREAD_FUNCTIONS
17804 +#define task_thread_info(task) (&(task)->tinfo)
17805 +#define task_stack_page(task) ((task)->stack)
17806 +#define setup_thread_stack(p, org) do {} while (0)
17807 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
17808 +
17809 #endif
17810 #endif /* _ASM_X86_THREAD_INFO_H */
17811 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
17812 index cf51200..63ff068 100644
17813 --- a/arch/x86/include/asm/tlbflush.h
17814 +++ b/arch/x86/include/asm/tlbflush.h
17815 @@ -17,18 +17,44 @@
17816
17817 static inline void __native_flush_tlb(void)
17818 {
17819 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17820 + u64 descriptor[2];
17821 +
17822 + descriptor[0] = PCID_KERNEL;
17823 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
17824 + return;
17825 + }
17826 +
17827 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17828 + if (static_cpu_has(X86_FEATURE_PCID)) {
17829 + unsigned int cpu = raw_get_cpu();
17830 +
17831 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
17832 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
17833 + raw_put_cpu_no_resched();
17834 + return;
17835 + }
17836 +#endif
17837 +
17838 native_write_cr3(native_read_cr3());
17839 }
17840
17841 static inline void __native_flush_tlb_global_irq_disabled(void)
17842 {
17843 - unsigned long cr4;
17844 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17845 + u64 descriptor[2];
17846
17847 - cr4 = native_read_cr4();
17848 - /* clear PGE */
17849 - native_write_cr4(cr4 & ~X86_CR4_PGE);
17850 - /* write old PGE again and flush TLBs */
17851 - native_write_cr4(cr4);
17852 + descriptor[0] = PCID_KERNEL;
17853 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
17854 + } else {
17855 + unsigned long cr4;
17856 +
17857 + cr4 = native_read_cr4();
17858 + /* clear PGE */
17859 + native_write_cr4(cr4 & ~X86_CR4_PGE);
17860 + /* write old PGE again and flush TLBs */
17861 + native_write_cr4(cr4);
17862 + }
17863 }
17864
17865 static inline void __native_flush_tlb_global(void)
17866 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
17867
17868 static inline void __native_flush_tlb_single(unsigned long addr)
17869 {
17870 +
17871 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
17872 + u64 descriptor[2];
17873 +
17874 + descriptor[0] = PCID_KERNEL;
17875 + descriptor[1] = addr;
17876 +
17877 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17878 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
17879 + if (addr < TASK_SIZE_MAX)
17880 + descriptor[1] += pax_user_shadow_base;
17881 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17882 + }
17883 +
17884 + descriptor[0] = PCID_USER;
17885 + descriptor[1] = addr;
17886 +#endif
17887 +
17888 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
17889 + return;
17890 + }
17891 +
17892 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17893 + if (static_cpu_has(X86_FEATURE_PCID)) {
17894 + unsigned int cpu = raw_get_cpu();
17895 +
17896 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
17897 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17898 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
17899 + raw_put_cpu_no_resched();
17900 +
17901 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
17902 + addr += pax_user_shadow_base;
17903 + }
17904 +#endif
17905 +
17906 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
17907 }
17908
17909 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
17910 index 5ee2687..74590b9 100644
17911 --- a/arch/x86/include/asm/uaccess.h
17912 +++ b/arch/x86/include/asm/uaccess.h
17913 @@ -7,6 +7,7 @@
17914 #include <linux/compiler.h>
17915 #include <linux/thread_info.h>
17916 #include <linux/string.h>
17917 +#include <linux/sched.h>
17918 #include <asm/asm.h>
17919 #include <asm/page.h>
17920 #include <asm/smap.h>
17921 @@ -29,7 +30,12 @@
17922
17923 #define get_ds() (KERNEL_DS)
17924 #define get_fs() (current_thread_info()->addr_limit)
17925 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17926 +void __set_fs(mm_segment_t x);
17927 +void set_fs(mm_segment_t x);
17928 +#else
17929 #define set_fs(x) (current_thread_info()->addr_limit = (x))
17930 +#endif
17931
17932 #define segment_eq(a, b) ((a).seg == (b).seg)
17933
17934 @@ -77,8 +83,33 @@
17935 * checks that the pointer is in the user space range - after calling
17936 * this function, memory access functions may still return -EFAULT.
17937 */
17938 -#define access_ok(type, addr, size) \
17939 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17940 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
17941 +#define access_ok(type, addr, size) \
17942 +({ \
17943 + long __size = size; \
17944 + unsigned long __addr = (unsigned long)addr; \
17945 + unsigned long __addr_ao = __addr & PAGE_MASK; \
17946 + unsigned long __end_ao = __addr + __size - 1; \
17947 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
17948 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
17949 + while(__addr_ao <= __end_ao) { \
17950 + char __c_ao; \
17951 + __addr_ao += PAGE_SIZE; \
17952 + if (__size > PAGE_SIZE) \
17953 + cond_resched(); \
17954 + if (__get_user(__c_ao, (char __user *)__addr)) \
17955 + break; \
17956 + if (type != VERIFY_WRITE) { \
17957 + __addr = __addr_ao; \
17958 + continue; \
17959 + } \
17960 + if (__put_user(__c_ao, (char __user *)__addr)) \
17961 + break; \
17962 + __addr = __addr_ao; \
17963 + } \
17964 + } \
17965 + __ret_ao; \
17966 +})
17967
17968 /*
17969 * The exception table consists of pairs of addresses relative to the
17970 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17971 register __inttype(*(ptr)) __val_gu asm("%edx"); \
17972 __chk_user_ptr(ptr); \
17973 might_fault(); \
17974 + pax_open_userland(); \
17975 asm volatile("call __get_user_%P3" \
17976 : "=a" (__ret_gu), "=r" (__val_gu) \
17977 : "0" (ptr), "i" (sizeof(*(ptr)))); \
17978 (x) = (__typeof__(*(ptr))) __val_gu; \
17979 + pax_close_userland(); \
17980 __ret_gu; \
17981 })
17982
17983 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17984 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
17985 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
17986
17987 -
17988 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
17989 +#define __copyuser_seg "gs;"
17990 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
17991 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
17992 +#else
17993 +#define __copyuser_seg
17994 +#define __COPYUSER_SET_ES
17995 +#define __COPYUSER_RESTORE_ES
17996 +#endif
17997
17998 #ifdef CONFIG_X86_32
17999 #define __put_user_asm_u64(x, addr, err, errret) \
18000 asm volatile(ASM_STAC "\n" \
18001 - "1: movl %%eax,0(%2)\n" \
18002 - "2: movl %%edx,4(%2)\n" \
18003 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18004 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18005 "3: " ASM_CLAC "\n" \
18006 ".section .fixup,\"ax\"\n" \
18007 "4: movl %3,%0\n" \
18008 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18009
18010 #define __put_user_asm_ex_u64(x, addr) \
18011 asm volatile(ASM_STAC "\n" \
18012 - "1: movl %%eax,0(%1)\n" \
18013 - "2: movl %%edx,4(%1)\n" \
18014 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18015 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18016 "3: " ASM_CLAC "\n" \
18017 _ASM_EXTABLE_EX(1b, 2b) \
18018 _ASM_EXTABLE_EX(2b, 3b) \
18019 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
18020 __typeof__(*(ptr)) __pu_val; \
18021 __chk_user_ptr(ptr); \
18022 might_fault(); \
18023 - __pu_val = x; \
18024 + __pu_val = (x); \
18025 + pax_open_userland(); \
18026 switch (sizeof(*(ptr))) { \
18027 case 1: \
18028 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18029 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
18030 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18031 break; \
18032 } \
18033 + pax_close_userland(); \
18034 __ret_pu; \
18035 })
18036
18037 @@ -344,8 +387,10 @@ do { \
18038 } while (0)
18039
18040 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18041 +do { \
18042 + pax_open_userland(); \
18043 asm volatile(ASM_STAC "\n" \
18044 - "1: mov"itype" %2,%"rtype"1\n" \
18045 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18046 "2: " ASM_CLAC "\n" \
18047 ".section .fixup,\"ax\"\n" \
18048 "3: mov %3,%0\n" \
18049 @@ -353,8 +398,10 @@ do { \
18050 " jmp 2b\n" \
18051 ".previous\n" \
18052 _ASM_EXTABLE(1b, 3b) \
18053 - : "=r" (err), ltype(x) \
18054 - : "m" (__m(addr)), "i" (errret), "0" (err))
18055 + : "=r" (err), ltype (x) \
18056 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18057 + pax_close_userland(); \
18058 +} while (0)
18059
18060 #define __get_user_size_ex(x, ptr, size) \
18061 do { \
18062 @@ -378,7 +425,7 @@ do { \
18063 } while (0)
18064
18065 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18066 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18067 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18068 "2:\n" \
18069 _ASM_EXTABLE_EX(1b, 2b) \
18070 : ltype(x) : "m" (__m(addr)))
18071 @@ -395,13 +442,24 @@ do { \
18072 int __gu_err; \
18073 unsigned long __gu_val; \
18074 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18075 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18076 + (x) = (__typeof__(*(ptr)))__gu_val; \
18077 __gu_err; \
18078 })
18079
18080 /* FIXME: this hack is definitely wrong -AK */
18081 struct __large_struct { unsigned long buf[100]; };
18082 -#define __m(x) (*(struct __large_struct __user *)(x))
18083 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18084 +#define ____m(x) \
18085 +({ \
18086 + unsigned long ____x = (unsigned long)(x); \
18087 + if (____x < pax_user_shadow_base) \
18088 + ____x += pax_user_shadow_base; \
18089 + (typeof(x))____x; \
18090 +})
18091 +#else
18092 +#define ____m(x) (x)
18093 +#endif
18094 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18095
18096 /*
18097 * Tell gcc we read from memory instead of writing: this is because
18098 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
18099 * aliasing issues.
18100 */
18101 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18102 +do { \
18103 + pax_open_userland(); \
18104 asm volatile(ASM_STAC "\n" \
18105 - "1: mov"itype" %"rtype"1,%2\n" \
18106 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18107 "2: " ASM_CLAC "\n" \
18108 ".section .fixup,\"ax\"\n" \
18109 "3: mov %3,%0\n" \
18110 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
18111 ".previous\n" \
18112 _ASM_EXTABLE(1b, 3b) \
18113 : "=r"(err) \
18114 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18115 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18116 + pax_close_userland(); \
18117 +} while (0)
18118
18119 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18120 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18121 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18122 "2:\n" \
18123 _ASM_EXTABLE_EX(1b, 2b) \
18124 : : ltype(x), "m" (__m(addr)))
18125 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
18126 */
18127 #define uaccess_try do { \
18128 current_thread_info()->uaccess_err = 0; \
18129 + pax_open_userland(); \
18130 stac(); \
18131 barrier();
18132
18133 #define uaccess_catch(err) \
18134 clac(); \
18135 + pax_close_userland(); \
18136 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18137 } while (0)
18138
18139 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
18140 * On error, the variable @x is set to zero.
18141 */
18142
18143 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18144 +#define __get_user(x, ptr) get_user((x), (ptr))
18145 +#else
18146 #define __get_user(x, ptr) \
18147 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18148 +#endif
18149
18150 /**
18151 * __put_user: - Write a simple value into user space, with less checking.
18152 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
18153 * Returns zero on success, or -EFAULT on error.
18154 */
18155
18156 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18157 +#define __put_user(x, ptr) put_user((x), (ptr))
18158 +#else
18159 #define __put_user(x, ptr) \
18160 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18161 +#endif
18162
18163 #define __get_user_unaligned __get_user
18164 #define __put_user_unaligned __put_user
18165 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
18166 #define get_user_ex(x, ptr) do { \
18167 unsigned long __gue_val; \
18168 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18169 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18170 + (x) = (__typeof__(*(ptr)))__gue_val; \
18171 } while (0)
18172
18173 #define put_user_try uaccess_try
18174 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
18175 extern __must_check long strlen_user(const char __user *str);
18176 extern __must_check long strnlen_user(const char __user *str, long n);
18177
18178 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
18179 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
18180 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18181 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
18182
18183 /*
18184 * movsl can be slow when source and dest are not both 8-byte aligned
18185 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18186 index 7f760a9..04b1c65 100644
18187 --- a/arch/x86/include/asm/uaccess_32.h
18188 +++ b/arch/x86/include/asm/uaccess_32.h
18189 @@ -11,15 +11,15 @@
18190 #include <asm/page.h>
18191
18192 unsigned long __must_check __copy_to_user_ll
18193 - (void __user *to, const void *from, unsigned long n);
18194 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
18195 unsigned long __must_check __copy_from_user_ll
18196 - (void *to, const void __user *from, unsigned long n);
18197 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18198 unsigned long __must_check __copy_from_user_ll_nozero
18199 - (void *to, const void __user *from, unsigned long n);
18200 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18201 unsigned long __must_check __copy_from_user_ll_nocache
18202 - (void *to, const void __user *from, unsigned long n);
18203 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18204 unsigned long __must_check __copy_from_user_ll_nocache_nozero
18205 - (void *to, const void __user *from, unsigned long n);
18206 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
18207
18208 /**
18209 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
18210 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18211 static __always_inline unsigned long __must_check
18212 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18213 {
18214 + if ((long)n < 0)
18215 + return n;
18216 +
18217 + check_object_size(from, n, true);
18218 +
18219 if (__builtin_constant_p(n)) {
18220 unsigned long ret;
18221
18222 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18223 __copy_to_user(void __user *to, const void *from, unsigned long n)
18224 {
18225 might_fault();
18226 +
18227 return __copy_to_user_inatomic(to, from, n);
18228 }
18229
18230 static __always_inline unsigned long
18231 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18232 {
18233 + if ((long)n < 0)
18234 + return n;
18235 +
18236 /* Avoid zeroing the tail if the copy fails..
18237 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18238 * but as the zeroing behaviour is only significant when n is not
18239 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18240 __copy_from_user(void *to, const void __user *from, unsigned long n)
18241 {
18242 might_fault();
18243 +
18244 + if ((long)n < 0)
18245 + return n;
18246 +
18247 + check_object_size(to, n, false);
18248 +
18249 if (__builtin_constant_p(n)) {
18250 unsigned long ret;
18251
18252 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18253 const void __user *from, unsigned long n)
18254 {
18255 might_fault();
18256 +
18257 + if ((long)n < 0)
18258 + return n;
18259 +
18260 if (__builtin_constant_p(n)) {
18261 unsigned long ret;
18262
18263 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18264 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18265 unsigned long n)
18266 {
18267 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18268 + if ((long)n < 0)
18269 + return n;
18270 +
18271 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18272 }
18273
18274 -unsigned long __must_check copy_to_user(void __user *to,
18275 - const void *from, unsigned long n);
18276 -unsigned long __must_check _copy_from_user(void *to,
18277 - const void __user *from,
18278 - unsigned long n);
18279 -
18280 +extern void copy_to_user_overflow(void)
18281 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18282 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18283 +#else
18284 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18285 +#endif
18286 +;
18287
18288 extern void copy_from_user_overflow(void)
18289 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18290 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18291 #endif
18292 ;
18293
18294 -static inline unsigned long __must_check copy_from_user(void *to,
18295 - const void __user *from,
18296 - unsigned long n)
18297 +/**
18298 + * copy_to_user: - Copy a block of data into user space.
18299 + * @to: Destination address, in user space.
18300 + * @from: Source address, in kernel space.
18301 + * @n: Number of bytes to copy.
18302 + *
18303 + * Context: User context only. This function may sleep.
18304 + *
18305 + * Copy data from kernel space to user space.
18306 + *
18307 + * Returns number of bytes that could not be copied.
18308 + * On success, this will be zero.
18309 + */
18310 +static inline unsigned long __must_check
18311 +copy_to_user(void __user *to, const void *from, unsigned long n)
18312 {
18313 - int sz = __compiletime_object_size(to);
18314 + size_t sz = __compiletime_object_size(from);
18315
18316 - if (likely(sz == -1 || sz >= n))
18317 - n = _copy_from_user(to, from, n);
18318 - else
18319 + if (unlikely(sz != (size_t)-1 && sz < n))
18320 + copy_to_user_overflow();
18321 + else if (access_ok(VERIFY_WRITE, to, n))
18322 + n = __copy_to_user(to, from, n);
18323 + return n;
18324 +}
18325 +
18326 +/**
18327 + * copy_from_user: - Copy a block of data from user space.
18328 + * @to: Destination address, in kernel space.
18329 + * @from: Source address, in user space.
18330 + * @n: Number of bytes to copy.
18331 + *
18332 + * Context: User context only. This function may sleep.
18333 + *
18334 + * Copy data from user space to kernel space.
18335 + *
18336 + * Returns number of bytes that could not be copied.
18337 + * On success, this will be zero.
18338 + *
18339 + * If some data could not be copied, this function will pad the copied
18340 + * data to the requested size using zero bytes.
18341 + */
18342 +static inline unsigned long __must_check
18343 +copy_from_user(void *to, const void __user *from, unsigned long n)
18344 +{
18345 + size_t sz = __compiletime_object_size(to);
18346 +
18347 + check_object_size(to, n, false);
18348 +
18349 + if (unlikely(sz != (size_t)-1 && sz < n))
18350 copy_from_user_overflow();
18351 -
18352 + else if (access_ok(VERIFY_READ, from, n))
18353 + n = __copy_from_user(to, from, n);
18354 + else if ((long)n > 0)
18355 + memset(to, 0, n);
18356 return n;
18357 }
18358
18359 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
18360 index 4f7923d..d3526c1 100644
18361 --- a/arch/x86/include/asm/uaccess_64.h
18362 +++ b/arch/x86/include/asm/uaccess_64.h
18363 @@ -10,6 +10,9 @@
18364 #include <asm/alternative.h>
18365 #include <asm/cpufeature.h>
18366 #include <asm/page.h>
18367 +#include <asm/pgtable.h>
18368 +
18369 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
18370
18371 /*
18372 * Copy To/From Userspace
18373 @@ -17,14 +20,14 @@
18374
18375 /* Handles exceptions in both to and from, but doesn't do access_ok */
18376 __must_check unsigned long
18377 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
18378 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
18379 __must_check unsigned long
18380 -copy_user_generic_string(void *to, const void *from, unsigned len);
18381 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
18382 __must_check unsigned long
18383 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
18384 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
18385
18386 -static __always_inline __must_check unsigned long
18387 -copy_user_generic(void *to, const void *from, unsigned len)
18388 +static __always_inline __must_check __size_overflow(3) unsigned long
18389 +copy_user_generic(void *to, const void *from, unsigned long len)
18390 {
18391 unsigned ret;
18392
18393 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
18394 return ret;
18395 }
18396
18397 +static __always_inline __must_check unsigned long
18398 +__copy_to_user(void __user *to, const void *from, unsigned long len);
18399 +static __always_inline __must_check unsigned long
18400 +__copy_from_user(void *to, const void __user *from, unsigned long len);
18401 __must_check unsigned long
18402 -_copy_to_user(void __user *to, const void *from, unsigned len);
18403 -__must_check unsigned long
18404 -_copy_from_user(void *to, const void __user *from, unsigned len);
18405 -__must_check unsigned long
18406 -copy_in_user(void __user *to, const void __user *from, unsigned len);
18407 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
18408 +
18409 +extern void copy_to_user_overflow(void)
18410 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18411 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18412 +#else
18413 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18414 +#endif
18415 +;
18416 +
18417 +extern void copy_from_user_overflow(void)
18418 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18419 + __compiletime_error("copy_from_user() buffer size is not provably correct")
18420 +#else
18421 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
18422 +#endif
18423 +;
18424
18425 static inline unsigned long __must_check copy_from_user(void *to,
18426 const void __user *from,
18427 unsigned long n)
18428 {
18429 - int sz = __compiletime_object_size(to);
18430 -
18431 might_fault();
18432 - if (likely(sz == -1 || sz >= n))
18433 - n = _copy_from_user(to, from, n);
18434 -#ifdef CONFIG_DEBUG_VM
18435 - else
18436 - WARN(1, "Buffer overflow detected!\n");
18437 -#endif
18438 +
18439 + check_object_size(to, n, false);
18440 +
18441 + if (access_ok(VERIFY_READ, from, n))
18442 + n = __copy_from_user(to, from, n);
18443 + else if (n < INT_MAX)
18444 + memset(to, 0, n);
18445 return n;
18446 }
18447
18448 static __always_inline __must_check
18449 -int copy_to_user(void __user *dst, const void *src, unsigned size)
18450 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
18451 {
18452 might_fault();
18453
18454 - return _copy_to_user(dst, src, size);
18455 + if (access_ok(VERIFY_WRITE, dst, size))
18456 + size = __copy_to_user(dst, src, size);
18457 + return size;
18458 }
18459
18460 static __always_inline __must_check
18461 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
18462 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
18463 {
18464 - int ret = 0;
18465 + size_t sz = __compiletime_object_size(dst);
18466 + unsigned ret = 0;
18467
18468 might_fault();
18469 +
18470 + if (size > INT_MAX)
18471 + return size;
18472 +
18473 + check_object_size(dst, size, false);
18474 +
18475 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18476 + if (!__access_ok(VERIFY_READ, src, size))
18477 + return size;
18478 +#endif
18479 +
18480 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18481 + copy_from_user_overflow();
18482 + return size;
18483 + }
18484 +
18485 if (!__builtin_constant_p(size))
18486 - return copy_user_generic(dst, (__force void *)src, size);
18487 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18488 switch (size) {
18489 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
18490 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
18491 ret, "b", "b", "=q", 1);
18492 return ret;
18493 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
18494 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
18495 ret, "w", "w", "=r", 2);
18496 return ret;
18497 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
18498 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
18499 ret, "l", "k", "=r", 4);
18500 return ret;
18501 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
18502 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18503 ret, "q", "", "=r", 8);
18504 return ret;
18505 case 10:
18506 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18507 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18508 ret, "q", "", "=r", 10);
18509 if (unlikely(ret))
18510 return ret;
18511 __get_user_asm(*(u16 *)(8 + (char *)dst),
18512 - (u16 __user *)(8 + (char __user *)src),
18513 + (const u16 __user *)(8 + (const char __user *)src),
18514 ret, "w", "w", "=r", 2);
18515 return ret;
18516 case 16:
18517 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
18518 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
18519 ret, "q", "", "=r", 16);
18520 if (unlikely(ret))
18521 return ret;
18522 __get_user_asm(*(u64 *)(8 + (char *)dst),
18523 - (u64 __user *)(8 + (char __user *)src),
18524 + (const u64 __user *)(8 + (const char __user *)src),
18525 ret, "q", "", "=r", 8);
18526 return ret;
18527 default:
18528 - return copy_user_generic(dst, (__force void *)src, size);
18529 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18530 }
18531 }
18532
18533 static __always_inline __must_check
18534 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
18535 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
18536 {
18537 - int ret = 0;
18538 + size_t sz = __compiletime_object_size(src);
18539 + unsigned ret = 0;
18540
18541 might_fault();
18542 +
18543 + if (size > INT_MAX)
18544 + return size;
18545 +
18546 + check_object_size(src, size, true);
18547 +
18548 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18549 + if (!__access_ok(VERIFY_WRITE, dst, size))
18550 + return size;
18551 +#endif
18552 +
18553 + if (unlikely(sz != (size_t)-1 && sz < size)) {
18554 + copy_to_user_overflow();
18555 + return size;
18556 + }
18557 +
18558 if (!__builtin_constant_p(size))
18559 - return copy_user_generic((__force void *)dst, src, size);
18560 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18561 switch (size) {
18562 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
18563 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
18564 ret, "b", "b", "iq", 1);
18565 return ret;
18566 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
18567 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
18568 ret, "w", "w", "ir", 2);
18569 return ret;
18570 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
18571 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
18572 ret, "l", "k", "ir", 4);
18573 return ret;
18574 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
18575 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18576 ret, "q", "", "er", 8);
18577 return ret;
18578 case 10:
18579 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18580 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18581 ret, "q", "", "er", 10);
18582 if (unlikely(ret))
18583 return ret;
18584 asm("":::"memory");
18585 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
18586 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
18587 ret, "w", "w", "ir", 2);
18588 return ret;
18589 case 16:
18590 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
18591 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
18592 ret, "q", "", "er", 16);
18593 if (unlikely(ret))
18594 return ret;
18595 asm("":::"memory");
18596 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
18597 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
18598 ret, "q", "", "er", 8);
18599 return ret;
18600 default:
18601 - return copy_user_generic((__force void *)dst, src, size);
18602 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18603 }
18604 }
18605
18606 static __always_inline __must_check
18607 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18608 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
18609 {
18610 - int ret = 0;
18611 + unsigned ret = 0;
18612
18613 might_fault();
18614 +
18615 + if (size > INT_MAX)
18616 + return size;
18617 +
18618 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18619 + if (!__access_ok(VERIFY_READ, src, size))
18620 + return size;
18621 + if (!__access_ok(VERIFY_WRITE, dst, size))
18622 + return size;
18623 +#endif
18624 +
18625 if (!__builtin_constant_p(size))
18626 - return copy_user_generic((__force void *)dst,
18627 - (__force void *)src, size);
18628 + return copy_user_generic((__force_kernel void *)____m(dst),
18629 + (__force_kernel const void *)____m(src), size);
18630 switch (size) {
18631 case 1: {
18632 u8 tmp;
18633 - __get_user_asm(tmp, (u8 __user *)src,
18634 + __get_user_asm(tmp, (const u8 __user *)src,
18635 ret, "b", "b", "=q", 1);
18636 if (likely(!ret))
18637 __put_user_asm(tmp, (u8 __user *)dst,
18638 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18639 }
18640 case 2: {
18641 u16 tmp;
18642 - __get_user_asm(tmp, (u16 __user *)src,
18643 + __get_user_asm(tmp, (const u16 __user *)src,
18644 ret, "w", "w", "=r", 2);
18645 if (likely(!ret))
18646 __put_user_asm(tmp, (u16 __user *)dst,
18647 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18648
18649 case 4: {
18650 u32 tmp;
18651 - __get_user_asm(tmp, (u32 __user *)src,
18652 + __get_user_asm(tmp, (const u32 __user *)src,
18653 ret, "l", "k", "=r", 4);
18654 if (likely(!ret))
18655 __put_user_asm(tmp, (u32 __user *)dst,
18656 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18657 }
18658 case 8: {
18659 u64 tmp;
18660 - __get_user_asm(tmp, (u64 __user *)src,
18661 + __get_user_asm(tmp, (const u64 __user *)src,
18662 ret, "q", "", "=r", 8);
18663 if (likely(!ret))
18664 __put_user_asm(tmp, (u64 __user *)dst,
18665 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
18666 return ret;
18667 }
18668 default:
18669 - return copy_user_generic((__force void *)dst,
18670 - (__force void *)src, size);
18671 + return copy_user_generic((__force_kernel void *)____m(dst),
18672 + (__force_kernel const void *)____m(src), size);
18673 }
18674 }
18675
18676 -static __must_check __always_inline int
18677 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
18678 +static __must_check __always_inline unsigned long
18679 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
18680 {
18681 - return copy_user_generic(dst, (__force const void *)src, size);
18682 + if (size > INT_MAX)
18683 + return size;
18684 +
18685 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18686 + if (!__access_ok(VERIFY_READ, src, size))
18687 + return size;
18688 +#endif
18689 +
18690 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
18691 }
18692
18693 -static __must_check __always_inline int
18694 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
18695 +static __must_check __always_inline unsigned long
18696 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
18697 {
18698 - return copy_user_generic((__force void *)dst, src, size);
18699 + if (size > INT_MAX)
18700 + return size;
18701 +
18702 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18703 + if (!__access_ok(VERIFY_WRITE, dst, size))
18704 + return size;
18705 +#endif
18706 +
18707 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
18708 }
18709
18710 -extern long __copy_user_nocache(void *dst, const void __user *src,
18711 - unsigned size, int zerorest);
18712 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
18713 + unsigned long size, int zerorest) __size_overflow(3);
18714
18715 -static inline int
18716 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
18717 +static inline unsigned long
18718 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
18719 {
18720 might_fault();
18721 +
18722 + if (size > INT_MAX)
18723 + return size;
18724 +
18725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18726 + if (!__access_ok(VERIFY_READ, src, size))
18727 + return size;
18728 +#endif
18729 +
18730 return __copy_user_nocache(dst, src, size, 1);
18731 }
18732
18733 -static inline int
18734 +static inline unsigned long
18735 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
18736 - unsigned size)
18737 + unsigned long size)
18738 {
18739 + if (size > INT_MAX)
18740 + return size;
18741 +
18742 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18743 + if (!__access_ok(VERIFY_READ, src, size))
18744 + return size;
18745 +#endif
18746 +
18747 return __copy_user_nocache(dst, src, size, 0);
18748 }
18749
18750 unsigned long
18751 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
18752 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
18753
18754 #endif /* _ASM_X86_UACCESS_64_H */
18755 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
18756 index 5b238981..77fdd78 100644
18757 --- a/arch/x86/include/asm/word-at-a-time.h
18758 +++ b/arch/x86/include/asm/word-at-a-time.h
18759 @@ -11,7 +11,7 @@
18760 * and shift, for example.
18761 */
18762 struct word_at_a_time {
18763 - const unsigned long one_bits, high_bits;
18764 + unsigned long one_bits, high_bits;
18765 };
18766
18767 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
18768 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
18769 index 828a156..650e625 100644
18770 --- a/arch/x86/include/asm/x86_init.h
18771 +++ b/arch/x86/include/asm/x86_init.h
18772 @@ -129,7 +129,7 @@ struct x86_init_ops {
18773 struct x86_init_timers timers;
18774 struct x86_init_iommu iommu;
18775 struct x86_init_pci pci;
18776 -};
18777 +} __no_const;
18778
18779 /**
18780 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
18781 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
18782 void (*setup_percpu_clockev)(void);
18783 void (*early_percpu_clock_init)(void);
18784 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
18785 -};
18786 +} __no_const;
18787
18788 struct timespec;
18789
18790 @@ -168,7 +168,7 @@ struct x86_platform_ops {
18791 void (*save_sched_clock_state)(void);
18792 void (*restore_sched_clock_state)(void);
18793 void (*apic_post_init)(void);
18794 -};
18795 +} __no_const;
18796
18797 struct pci_dev;
18798 struct msi_msg;
18799 @@ -182,7 +182,7 @@ struct x86_msi_ops {
18800 void (*teardown_msi_irqs)(struct pci_dev *dev);
18801 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
18802 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
18803 -};
18804 +} __no_const;
18805
18806 struct IO_APIC_route_entry;
18807 struct io_apic_irq_attr;
18808 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
18809 unsigned int destination, int vector,
18810 struct io_apic_irq_attr *attr);
18811 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
18812 -};
18813 +} __no_const;
18814
18815 extern struct x86_init_ops x86_init;
18816 extern struct x86_cpuinit_ops x86_cpuinit;
18817 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
18818 index 0415cda..3b22adc 100644
18819 --- a/arch/x86/include/asm/xsave.h
18820 +++ b/arch/x86/include/asm/xsave.h
18821 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18822 if (unlikely(err))
18823 return -EFAULT;
18824
18825 + pax_open_userland();
18826 __asm__ __volatile__(ASM_STAC "\n"
18827 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
18828 + "1:"
18829 + __copyuser_seg
18830 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
18831 "2: " ASM_CLAC "\n"
18832 ".section .fixup,\"ax\"\n"
18833 "3: movl $-1,%[err]\n"
18834 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
18835 : [err] "=r" (err)
18836 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
18837 : "memory");
18838 + pax_close_userland();
18839 return err;
18840 }
18841
18842 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18843 {
18844 int err;
18845 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
18846 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
18847 u32 lmask = mask;
18848 u32 hmask = mask >> 32;
18849
18850 + pax_open_userland();
18851 __asm__ __volatile__(ASM_STAC "\n"
18852 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18853 + "1:"
18854 + __copyuser_seg
18855 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
18856 "2: " ASM_CLAC "\n"
18857 ".section .fixup,\"ax\"\n"
18858 "3: movl $-1,%[err]\n"
18859 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
18860 : [err] "=r" (err)
18861 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
18862 : "memory"); /* memory required? */
18863 + pax_close_userland();
18864 return err;
18865 }
18866
18867 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
18868 index bbae024..e1528f9 100644
18869 --- a/arch/x86/include/uapi/asm/e820.h
18870 +++ b/arch/x86/include/uapi/asm/e820.h
18871 @@ -63,7 +63,7 @@ struct e820map {
18872 #define ISA_START_ADDRESS 0xa0000
18873 #define ISA_END_ADDRESS 0x100000
18874
18875 -#define BIOS_BEGIN 0x000a0000
18876 +#define BIOS_BEGIN 0x000c0000
18877 #define BIOS_END 0x00100000
18878
18879 #define BIOS_ROM_BASE 0xffe00000
18880 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
18881 index 88d99ea..9fc7e17 100644
18882 --- a/arch/x86/kernel/Makefile
18883 +++ b/arch/x86/kernel/Makefile
18884 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
18885 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
18886 obj-$(CONFIG_IRQ_WORK) += irq_work.o
18887 obj-y += probe_roms.o
18888 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
18889 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
18890 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
18891 obj-y += syscall_$(BITS).o
18892 obj-$(CONFIG_X86_64) += vsyscall_64.o
18893 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
18894 index 2627a81..cd8325e 100644
18895 --- a/arch/x86/kernel/acpi/boot.c
18896 +++ b/arch/x86/kernel/acpi/boot.c
18897 @@ -1368,7 +1368,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
18898 * If your system is blacklisted here, but you find that acpi=force
18899 * works for you, please contact linux-acpi@vger.kernel.org
18900 */
18901 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
18902 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
18903 /*
18904 * Boxes that need ACPI disabled
18905 */
18906 @@ -1443,7 +1443,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
18907 };
18908
18909 /* second table for DMI checks that should run after early-quirks */
18910 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
18911 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
18912 /*
18913 * HP laptops which use a DSDT reporting as HP/SB400/10000,
18914 * which includes some code which overrides all temperature
18915 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
18916 index 3312010..a65ca7b 100644
18917 --- a/arch/x86/kernel/acpi/sleep.c
18918 +++ b/arch/x86/kernel/acpi/sleep.c
18919 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
18920 #else /* CONFIG_64BIT */
18921 #ifdef CONFIG_SMP
18922 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
18923 +
18924 + pax_open_kernel();
18925 early_gdt_descr.address =
18926 (unsigned long)get_cpu_gdt_table(smp_processor_id());
18927 + pax_close_kernel();
18928 +
18929 initial_gs = per_cpu_offset(smp_processor_id());
18930 #endif
18931 initial_code = (unsigned long)wakeup_long64;
18932 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
18933 index d1daa66..59fecba 100644
18934 --- a/arch/x86/kernel/acpi/wakeup_32.S
18935 +++ b/arch/x86/kernel/acpi/wakeup_32.S
18936 @@ -29,13 +29,11 @@ wakeup_pmode_return:
18937 # and restore the stack ... but you need gdt for this to work
18938 movl saved_context_esp, %esp
18939
18940 - movl %cs:saved_magic, %eax
18941 - cmpl $0x12345678, %eax
18942 + cmpl $0x12345678, saved_magic
18943 jne bogus_magic
18944
18945 # jump to place where we left off
18946 - movl saved_eip, %eax
18947 - jmp *%eax
18948 + jmp *(saved_eip)
18949
18950 bogus_magic:
18951 jmp bogus_magic
18952 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
18953 index c15cf9a..0e63558 100644
18954 --- a/arch/x86/kernel/alternative.c
18955 +++ b/arch/x86/kernel/alternative.c
18956 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
18957 */
18958 for (a = start; a < end; a++) {
18959 instr = (u8 *)&a->instr_offset + a->instr_offset;
18960 +
18961 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18962 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18963 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
18964 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18965 +#endif
18966 +
18967 replacement = (u8 *)&a->repl_offset + a->repl_offset;
18968 BUG_ON(a->replacementlen > a->instrlen);
18969 BUG_ON(a->instrlen > sizeof(insnbuf));
18970 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
18971 for (poff = start; poff < end; poff++) {
18972 u8 *ptr = (u8 *)poff + *poff;
18973
18974 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18975 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18976 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18977 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18978 +#endif
18979 +
18980 if (!*poff || ptr < text || ptr >= text_end)
18981 continue;
18982 /* turn DS segment override prefix into lock prefix */
18983 - if (*ptr == 0x3e)
18984 + if (*ktla_ktva(ptr) == 0x3e)
18985 text_poke(ptr, ((unsigned char []){0xf0}), 1);
18986 }
18987 mutex_unlock(&text_mutex);
18988 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
18989 for (poff = start; poff < end; poff++) {
18990 u8 *ptr = (u8 *)poff + *poff;
18991
18992 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
18993 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18994 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
18995 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
18996 +#endif
18997 +
18998 if (!*poff || ptr < text || ptr >= text_end)
18999 continue;
19000 /* turn lock prefix into DS segment override prefix */
19001 - if (*ptr == 0xf0)
19002 + if (*ktla_ktva(ptr) == 0xf0)
19003 text_poke(ptr, ((unsigned char []){0x3E}), 1);
19004 }
19005 mutex_unlock(&text_mutex);
19006 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19007
19008 BUG_ON(p->len > MAX_PATCH_LEN);
19009 /* prep the buffer with the original instructions */
19010 - memcpy(insnbuf, p->instr, p->len);
19011 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19012 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19013 (unsigned long)p->instr, p->len);
19014
19015 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
19016 if (!uniproc_patched || num_possible_cpus() == 1)
19017 free_init_pages("SMP alternatives",
19018 (unsigned long)__smp_locks,
19019 - (unsigned long)__smp_locks_end);
19020 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19021 #endif
19022
19023 apply_paravirt(__parainstructions, __parainstructions_end);
19024 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
19025 * instructions. And on the local CPU you need to be protected again NMI or MCE
19026 * handlers seeing an inconsistent instruction while you patch.
19027 */
19028 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19029 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19030 size_t len)
19031 {
19032 unsigned long flags;
19033 local_irq_save(flags);
19034 - memcpy(addr, opcode, len);
19035 +
19036 + pax_open_kernel();
19037 + memcpy(ktla_ktva(addr), opcode, len);
19038 sync_core();
19039 + pax_close_kernel();
19040 +
19041 local_irq_restore(flags);
19042 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19043 that causes hangs on some VIA CPUs. */
19044 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19045 */
19046 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19047 {
19048 - unsigned long flags;
19049 - char *vaddr;
19050 + unsigned char *vaddr = ktla_ktva(addr);
19051 struct page *pages[2];
19052 - int i;
19053 + size_t i;
19054
19055 if (!core_kernel_text((unsigned long)addr)) {
19056 - pages[0] = vmalloc_to_page(addr);
19057 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19058 + pages[0] = vmalloc_to_page(vaddr);
19059 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19060 } else {
19061 - pages[0] = virt_to_page(addr);
19062 + pages[0] = virt_to_page(vaddr);
19063 WARN_ON(!PageReserved(pages[0]));
19064 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19065 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19066 }
19067 BUG_ON(!pages[0]);
19068 - local_irq_save(flags);
19069 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19070 - if (pages[1])
19071 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19072 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19073 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19074 - clear_fixmap(FIX_TEXT_POKE0);
19075 - if (pages[1])
19076 - clear_fixmap(FIX_TEXT_POKE1);
19077 - local_flush_tlb();
19078 - sync_core();
19079 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19080 - that causes hangs on some VIA CPUs. */
19081 + text_poke_early(addr, opcode, len);
19082 for (i = 0; i < len; i++)
19083 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19084 - local_irq_restore(flags);
19085 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19086 return addr;
19087 }
19088
19089 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19090 index eca89c5..d566b78 100644
19091 --- a/arch/x86/kernel/apic/apic.c
19092 +++ b/arch/x86/kernel/apic/apic.c
19093 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19094 /*
19095 * Debug level, exported for io_apic.c
19096 */
19097 -unsigned int apic_verbosity;
19098 +int apic_verbosity;
19099
19100 int pic_mode;
19101
19102 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19103 apic_write(APIC_ESR, 0);
19104 v1 = apic_read(APIC_ESR);
19105 ack_APIC_irq();
19106 - atomic_inc(&irq_err_count);
19107 + atomic_inc_unchecked(&irq_err_count);
19108
19109 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19110 smp_processor_id(), v0 , v1);
19111 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19112 index 00c77cf..2dc6a2d 100644
19113 --- a/arch/x86/kernel/apic/apic_flat_64.c
19114 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19115 @@ -157,7 +157,7 @@ static int flat_probe(void)
19116 return 1;
19117 }
19118
19119 -static struct apic apic_flat = {
19120 +static struct apic apic_flat __read_only = {
19121 .name = "flat",
19122 .probe = flat_probe,
19123 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19124 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19125 return 0;
19126 }
19127
19128 -static struct apic apic_physflat = {
19129 +static struct apic apic_physflat __read_only = {
19130
19131 .name = "physical flat",
19132 .probe = physflat_probe,
19133 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19134 index e145f28..2752888 100644
19135 --- a/arch/x86/kernel/apic/apic_noop.c
19136 +++ b/arch/x86/kernel/apic/apic_noop.c
19137 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19138 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19139 }
19140
19141 -struct apic apic_noop = {
19142 +struct apic apic_noop __read_only = {
19143 .name = "noop",
19144 .probe = noop_probe,
19145 .acpi_madt_oem_check = NULL,
19146 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19147 index d50e364..543bee3 100644
19148 --- a/arch/x86/kernel/apic/bigsmp_32.c
19149 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19150 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19151 return dmi_bigsmp;
19152 }
19153
19154 -static struct apic apic_bigsmp = {
19155 +static struct apic apic_bigsmp __read_only = {
19156
19157 .name = "bigsmp",
19158 .probe = probe_bigsmp,
19159 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19160 index c552247..587a316 100644
19161 --- a/arch/x86/kernel/apic/es7000_32.c
19162 +++ b/arch/x86/kernel/apic/es7000_32.c
19163 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19164 return ret && es7000_apic_is_cluster();
19165 }
19166
19167 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19168 -static struct apic __refdata apic_es7000_cluster = {
19169 +static struct apic apic_es7000_cluster __read_only = {
19170
19171 .name = "es7000",
19172 .probe = probe_es7000,
19173 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19174 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19175 };
19176
19177 -static struct apic __refdata apic_es7000 = {
19178 +static struct apic apic_es7000 __read_only = {
19179
19180 .name = "es7000",
19181 .probe = probe_es7000,
19182 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19183 index 9ed796c..e930fe4 100644
19184 --- a/arch/x86/kernel/apic/io_apic.c
19185 +++ b/arch/x86/kernel/apic/io_apic.c
19186 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19187 }
19188 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19189
19190 -void lock_vector_lock(void)
19191 +void lock_vector_lock(void) __acquires(vector_lock)
19192 {
19193 /* Used to the online set of cpus does not change
19194 * during assign_irq_vector.
19195 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19196 raw_spin_lock(&vector_lock);
19197 }
19198
19199 -void unlock_vector_lock(void)
19200 +void unlock_vector_lock(void) __releases(vector_lock)
19201 {
19202 raw_spin_unlock(&vector_lock);
19203 }
19204 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
19205 ack_APIC_irq();
19206 }
19207
19208 -atomic_t irq_mis_count;
19209 +atomic_unchecked_t irq_mis_count;
19210
19211 #ifdef CONFIG_GENERIC_PENDING_IRQ
19212 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19213 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
19214 * at the cpu.
19215 */
19216 if (!(v & (1 << (i & 0x1f)))) {
19217 - atomic_inc(&irq_mis_count);
19218 + atomic_inc_unchecked(&irq_mis_count);
19219
19220 eoi_ioapic_irq(irq, cfg);
19221 }
19222 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19223 index 1e42e8f..daacf44 100644
19224 --- a/arch/x86/kernel/apic/numaq_32.c
19225 +++ b/arch/x86/kernel/apic/numaq_32.c
19226 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19227 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19228 }
19229
19230 -/* Use __refdata to keep false positive warning calm. */
19231 -static struct apic __refdata apic_numaq = {
19232 +static struct apic apic_numaq __read_only = {
19233
19234 .name = "NUMAQ",
19235 .probe = probe_numaq,
19236 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19237 index eb35ef9..f184a21 100644
19238 --- a/arch/x86/kernel/apic/probe_32.c
19239 +++ b/arch/x86/kernel/apic/probe_32.c
19240 @@ -72,7 +72,7 @@ static int probe_default(void)
19241 return 1;
19242 }
19243
19244 -static struct apic apic_default = {
19245 +static struct apic apic_default __read_only = {
19246
19247 .name = "default",
19248 .probe = probe_default,
19249 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19250 index 77c95c0..434f8a4 100644
19251 --- a/arch/x86/kernel/apic/summit_32.c
19252 +++ b/arch/x86/kernel/apic/summit_32.c
19253 @@ -486,7 +486,7 @@ void setup_summit(void)
19254 }
19255 #endif
19256
19257 -static struct apic apic_summit = {
19258 +static struct apic apic_summit __read_only = {
19259
19260 .name = "summit",
19261 .probe = probe_summit,
19262 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19263 index 140e29d..d88bc95 100644
19264 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19265 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19266 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19267 return notifier_from_errno(err);
19268 }
19269
19270 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19271 +static struct notifier_block x2apic_cpu_notifier = {
19272 .notifier_call = update_clusterinfo,
19273 };
19274
19275 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19276 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19277 }
19278
19279 -static struct apic apic_x2apic_cluster = {
19280 +static struct apic apic_x2apic_cluster __read_only = {
19281
19282 .name = "cluster x2apic",
19283 .probe = x2apic_cluster_probe,
19284 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19285 index 562a76d..a003c0f 100644
19286 --- a/arch/x86/kernel/apic/x2apic_phys.c
19287 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19288 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19289 return apic == &apic_x2apic_phys;
19290 }
19291
19292 -static struct apic apic_x2apic_phys = {
19293 +static struct apic apic_x2apic_phys __read_only = {
19294
19295 .name = "physical x2apic",
19296 .probe = x2apic_phys_probe,
19297 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
19298 index 1191ac1..2335fa4 100644
19299 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
19300 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
19301 @@ -357,7 +357,7 @@ static int uv_probe(void)
19302 return apic == &apic_x2apic_uv_x;
19303 }
19304
19305 -static struct apic __refdata apic_x2apic_uv_x = {
19306 +static struct apic apic_x2apic_uv_x __read_only = {
19307
19308 .name = "UV large system",
19309 .probe = uv_probe,
19310 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
19311 index 53a4e27..038760a 100644
19312 --- a/arch/x86/kernel/apm_32.c
19313 +++ b/arch/x86/kernel/apm_32.c
19314 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
19315 * This is for buggy BIOS's that refer to (real mode) segment 0x40
19316 * even though they are called in protected mode.
19317 */
19318 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
19319 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
19320 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
19321
19322 static const char driver_version[] = "1.16ac"; /* no spaces */
19323 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
19324 BUG_ON(cpu != 0);
19325 gdt = get_cpu_gdt_table(cpu);
19326 save_desc_40 = gdt[0x40 / 8];
19327 +
19328 + pax_open_kernel();
19329 gdt[0x40 / 8] = bad_bios_desc;
19330 + pax_close_kernel();
19331
19332 apm_irq_save(flags);
19333 APM_DO_SAVE_SEGS;
19334 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
19335 &call->esi);
19336 APM_DO_RESTORE_SEGS;
19337 apm_irq_restore(flags);
19338 +
19339 + pax_open_kernel();
19340 gdt[0x40 / 8] = save_desc_40;
19341 + pax_close_kernel();
19342 +
19343 put_cpu();
19344
19345 return call->eax & 0xff;
19346 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
19347 BUG_ON(cpu != 0);
19348 gdt = get_cpu_gdt_table(cpu);
19349 save_desc_40 = gdt[0x40 / 8];
19350 +
19351 + pax_open_kernel();
19352 gdt[0x40 / 8] = bad_bios_desc;
19353 + pax_close_kernel();
19354
19355 apm_irq_save(flags);
19356 APM_DO_SAVE_SEGS;
19357 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
19358 &call->eax);
19359 APM_DO_RESTORE_SEGS;
19360 apm_irq_restore(flags);
19361 +
19362 + pax_open_kernel();
19363 gdt[0x40 / 8] = save_desc_40;
19364 + pax_close_kernel();
19365 +
19366 put_cpu();
19367 return error;
19368 }
19369 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
19370 * code to that CPU.
19371 */
19372 gdt = get_cpu_gdt_table(0);
19373 +
19374 + pax_open_kernel();
19375 set_desc_base(&gdt[APM_CS >> 3],
19376 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
19377 set_desc_base(&gdt[APM_CS_16 >> 3],
19378 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
19379 set_desc_base(&gdt[APM_DS >> 3],
19380 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
19381 + pax_close_kernel();
19382
19383 proc_create("apm", 0, NULL, &apm_file_ops);
19384
19385 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
19386 index 2861082..6d4718e 100644
19387 --- a/arch/x86/kernel/asm-offsets.c
19388 +++ b/arch/x86/kernel/asm-offsets.c
19389 @@ -33,6 +33,8 @@ void common(void) {
19390 OFFSET(TI_status, thread_info, status);
19391 OFFSET(TI_addr_limit, thread_info, addr_limit);
19392 OFFSET(TI_preempt_count, thread_info, preempt_count);
19393 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
19394 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
19395
19396 BLANK();
19397 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
19398 @@ -53,8 +55,26 @@ void common(void) {
19399 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
19400 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
19401 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
19402 +
19403 +#ifdef CONFIG_PAX_KERNEXEC
19404 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
19405 #endif
19406
19407 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19408 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
19409 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
19410 +#ifdef CONFIG_X86_64
19411 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
19412 +#endif
19413 +#endif
19414 +
19415 +#endif
19416 +
19417 + BLANK();
19418 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
19419 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
19420 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
19421 +
19422 #ifdef CONFIG_XEN
19423 BLANK();
19424 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
19425 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
19426 index e7c798b..2b2019b 100644
19427 --- a/arch/x86/kernel/asm-offsets_64.c
19428 +++ b/arch/x86/kernel/asm-offsets_64.c
19429 @@ -77,6 +77,7 @@ int main(void)
19430 BLANK();
19431 #undef ENTRY
19432
19433 + DEFINE(TSS_size, sizeof(struct tss_struct));
19434 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
19435 BLANK();
19436
19437 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
19438 index 47b56a7..efc2bc6 100644
19439 --- a/arch/x86/kernel/cpu/Makefile
19440 +++ b/arch/x86/kernel/cpu/Makefile
19441 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
19442 CFLAGS_REMOVE_perf_event.o = -pg
19443 endif
19444
19445 -# Make sure load_percpu_segment has no stackprotector
19446 -nostackp := $(call cc-option, -fno-stack-protector)
19447 -CFLAGS_common.o := $(nostackp)
19448 -
19449 obj-y := intel_cacheinfo.o scattered.o topology.o
19450 obj-y += proc.o capflags.o powerflags.o common.o
19451 obj-y += rdrand.o
19452 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
19453 index 08a0890..e557865 100644
19454 --- a/arch/x86/kernel/cpu/amd.c
19455 +++ b/arch/x86/kernel/cpu/amd.c
19456 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
19457 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
19458 {
19459 /* AMD errata T13 (order #21922) */
19460 - if ((c->x86 == 6)) {
19461 + if (c->x86 == 6) {
19462 /* Duron Rev A0 */
19463 if (c->x86_model == 3 && c->x86_mask == 0)
19464 size = 64;
19465 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
19466 index 25eb274..3a92d93 100644
19467 --- a/arch/x86/kernel/cpu/common.c
19468 +++ b/arch/x86/kernel/cpu/common.c
19469 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
19470
19471 static const struct cpu_dev *this_cpu = &default_cpu;
19472
19473 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
19474 -#ifdef CONFIG_X86_64
19475 - /*
19476 - * We need valid kernel segments for data and code in long mode too
19477 - * IRET will check the segment types kkeil 2000/10/28
19478 - * Also sysret mandates a special GDT layout
19479 - *
19480 - * TLS descriptors are currently at a different place compared to i386.
19481 - * Hopefully nobody expects them at a fixed place (Wine?)
19482 - */
19483 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
19484 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
19485 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
19486 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
19487 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
19488 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
19489 -#else
19490 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
19491 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19492 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
19493 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
19494 - /*
19495 - * Segments used for calling PnP BIOS have byte granularity.
19496 - * They code segments and data segments have fixed 64k limits,
19497 - * the transfer segment sizes are set at run time.
19498 - */
19499 - /* 32-bit code */
19500 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19501 - /* 16-bit code */
19502 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19503 - /* 16-bit data */
19504 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
19505 - /* 16-bit data */
19506 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
19507 - /* 16-bit data */
19508 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
19509 - /*
19510 - * The APM segments have byte granularity and their bases
19511 - * are set at run time. All have 64k limits.
19512 - */
19513 - /* 32-bit code */
19514 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
19515 - /* 16-bit code */
19516 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
19517 - /* data */
19518 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
19519 -
19520 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19521 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
19522 - GDT_STACK_CANARY_INIT
19523 -#endif
19524 -} };
19525 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
19526 -
19527 static int __init x86_xsave_setup(char *s)
19528 {
19529 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
19530 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
19531 set_in_cr4(X86_CR4_SMAP);
19532 }
19533
19534 +#ifdef CONFIG_X86_64
19535 +static __init int setup_disable_pcid(char *arg)
19536 +{
19537 + setup_clear_cpu_cap(X86_FEATURE_PCID);
19538 +
19539 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19540 + if (clone_pgd_mask != ~(pgdval_t)0UL)
19541 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19542 +#endif
19543 +
19544 + return 1;
19545 +}
19546 +__setup("nopcid", setup_disable_pcid);
19547 +
19548 +static void setup_pcid(struct cpuinfo_x86 *c)
19549 +{
19550 + if (!cpu_has(c, X86_FEATURE_PCID)) {
19551 +
19552 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19553 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
19554 + pax_open_kernel();
19555 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
19556 + pax_close_kernel();
19557 + printk("PAX: slow and weak UDEREF enabled\n");
19558 + } else
19559 + printk("PAX: UDEREF disabled\n");
19560 +#endif
19561 +
19562 + return;
19563 + }
19564 +
19565 + printk("PAX: PCID detected\n");
19566 + set_in_cr4(X86_CR4_PCIDE);
19567 +
19568 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19569 + pax_open_kernel();
19570 + clone_pgd_mask = ~(pgdval_t)0UL;
19571 + pax_close_kernel();
19572 + if (pax_user_shadow_base)
19573 + printk("PAX: weak UDEREF enabled\n");
19574 + else {
19575 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
19576 + printk("PAX: strong UDEREF enabled\n");
19577 + }
19578 +#endif
19579 +
19580 + if (cpu_has(c, X86_FEATURE_INVPCID))
19581 + printk("PAX: INVPCID detected\n");
19582 +}
19583 +#endif
19584 +
19585 /*
19586 * Some CPU features depend on higher CPUID levels, which may not always
19587 * be available due to CPUID level capping or broken virtualization
19588 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
19589 {
19590 struct desc_ptr gdt_descr;
19591
19592 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
19593 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
19594 gdt_descr.size = GDT_SIZE - 1;
19595 load_gdt(&gdt_descr);
19596 /* Reload the per-cpu base */
19597 @@ -875,6 +872,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19598 setup_smep(c);
19599 setup_smap(c);
19600
19601 +#ifdef CONFIG_X86_64
19602 + setup_pcid(c);
19603 +#endif
19604 +
19605 /*
19606 * The vendor-specific functions might have changed features.
19607 * Now we do "generic changes."
19608 @@ -883,6 +884,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
19609 /* Filter out anything that depends on CPUID levels we don't have */
19610 filter_cpuid_features(c, true);
19611
19612 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
19613 + setup_clear_cpu_cap(X86_FEATURE_SEP);
19614 +#endif
19615 +
19616 /* If the model name is still unset, do table lookup. */
19617 if (!c->x86_model_id[0]) {
19618 const char *p;
19619 @@ -1070,10 +1075,12 @@ static __init int setup_disablecpuid(char *arg)
19620 }
19621 __setup("clearcpuid=", setup_disablecpuid);
19622
19623 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
19624 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
19625 +
19626 #ifdef CONFIG_X86_64
19627 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19628 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
19629 - (unsigned long) debug_idt_table };
19630 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
19631 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
19632
19633 DEFINE_PER_CPU_FIRST(union irq_stack_union,
19634 irq_stack_union) __aligned(PAGE_SIZE);
19635 @@ -1087,7 +1094,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
19636 EXPORT_PER_CPU_SYMBOL(current_task);
19637
19638 DEFINE_PER_CPU(unsigned long, kernel_stack) =
19639 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
19640 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
19641 EXPORT_PER_CPU_SYMBOL(kernel_stack);
19642
19643 DEFINE_PER_CPU(char *, irq_stack_ptr) =
19644 @@ -1232,7 +1239,7 @@ void cpu_init(void)
19645 load_ucode_ap();
19646
19647 cpu = stack_smp_processor_id();
19648 - t = &per_cpu(init_tss, cpu);
19649 + t = init_tss + cpu;
19650 oist = &per_cpu(orig_ist, cpu);
19651
19652 #ifdef CONFIG_NUMA
19653 @@ -1267,7 +1274,6 @@ void cpu_init(void)
19654 wrmsrl(MSR_KERNEL_GS_BASE, 0);
19655 barrier();
19656
19657 - x86_configure_nx();
19658 enable_x2apic();
19659
19660 /*
19661 @@ -1319,7 +1325,7 @@ void cpu_init(void)
19662 {
19663 int cpu = smp_processor_id();
19664 struct task_struct *curr = current;
19665 - struct tss_struct *t = &per_cpu(init_tss, cpu);
19666 + struct tss_struct *t = init_tss + cpu;
19667 struct thread_struct *thread = &curr->thread;
19668
19669 show_ucode_info_early();
19670 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
19671 index 1414c90..1159406 100644
19672 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
19673 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
19674 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
19675 };
19676
19677 #ifdef CONFIG_AMD_NB
19678 +static struct attribute *default_attrs_amd_nb[] = {
19679 + &type.attr,
19680 + &level.attr,
19681 + &coherency_line_size.attr,
19682 + &physical_line_partition.attr,
19683 + &ways_of_associativity.attr,
19684 + &number_of_sets.attr,
19685 + &size.attr,
19686 + &shared_cpu_map.attr,
19687 + &shared_cpu_list.attr,
19688 + NULL,
19689 + NULL,
19690 + NULL,
19691 + NULL
19692 +};
19693 +
19694 static struct attribute **amd_l3_attrs(void)
19695 {
19696 static struct attribute **attrs;
19697 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
19698
19699 n = ARRAY_SIZE(default_attrs);
19700
19701 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
19702 - n += 2;
19703 -
19704 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
19705 - n += 1;
19706 -
19707 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
19708 - if (attrs == NULL)
19709 - return attrs = default_attrs;
19710 -
19711 - for (n = 0; default_attrs[n]; n++)
19712 - attrs[n] = default_attrs[n];
19713 + attrs = default_attrs_amd_nb;
19714
19715 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
19716 attrs[n++] = &cache_disable_0.attr;
19717 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
19718 .default_attrs = default_attrs,
19719 };
19720
19721 +#ifdef CONFIG_AMD_NB
19722 +static struct kobj_type ktype_cache_amd_nb = {
19723 + .sysfs_ops = &sysfs_ops,
19724 + .default_attrs = default_attrs_amd_nb,
19725 +};
19726 +#endif
19727 +
19728 static struct kobj_type ktype_percpu_entry = {
19729 .sysfs_ops = &sysfs_ops,
19730 };
19731 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
19732 return retval;
19733 }
19734
19735 +#ifdef CONFIG_AMD_NB
19736 + amd_l3_attrs();
19737 +#endif
19738 +
19739 for (i = 0; i < num_cache_leaves; i++) {
19740 + struct kobj_type *ktype;
19741 +
19742 this_object = INDEX_KOBJECT_PTR(cpu, i);
19743 this_object->cpu = cpu;
19744 this_object->index = i;
19745
19746 this_leaf = CPUID4_INFO_IDX(cpu, i);
19747
19748 - ktype_cache.default_attrs = default_attrs;
19749 + ktype = &ktype_cache;
19750 #ifdef CONFIG_AMD_NB
19751 if (this_leaf->base.nb)
19752 - ktype_cache.default_attrs = amd_l3_attrs();
19753 + ktype = &ktype_cache_amd_nb;
19754 #endif
19755 retval = kobject_init_and_add(&(this_object->kobj),
19756 - &ktype_cache,
19757 + ktype,
19758 per_cpu(ici_cache_kobject, cpu),
19759 "index%1lu", i);
19760 if (unlikely(retval)) {
19761 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
19762 index 87a65c9..92fcce6 100644
19763 --- a/arch/x86/kernel/cpu/mcheck/mce.c
19764 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
19765 @@ -45,6 +45,7 @@
19766 #include <asm/processor.h>
19767 #include <asm/mce.h>
19768 #include <asm/msr.h>
19769 +#include <asm/local.h>
19770
19771 #include "mce-internal.h"
19772
19773 @@ -249,7 +250,7 @@ static void print_mce(struct mce *m)
19774 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
19775 m->cs, m->ip);
19776
19777 - if (m->cs == __KERNEL_CS)
19778 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
19779 print_symbol("{%s}", m->ip);
19780 pr_cont("\n");
19781 }
19782 @@ -282,10 +283,10 @@ static void print_mce(struct mce *m)
19783
19784 #define PANIC_TIMEOUT 5 /* 5 seconds */
19785
19786 -static atomic_t mce_paniced;
19787 +static atomic_unchecked_t mce_paniced;
19788
19789 static int fake_panic;
19790 -static atomic_t mce_fake_paniced;
19791 +static atomic_unchecked_t mce_fake_paniced;
19792
19793 /* Panic in progress. Enable interrupts and wait for final IPI */
19794 static void wait_for_panic(void)
19795 @@ -309,7 +310,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19796 /*
19797 * Make sure only one CPU runs in machine check panic
19798 */
19799 - if (atomic_inc_return(&mce_paniced) > 1)
19800 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
19801 wait_for_panic();
19802 barrier();
19803
19804 @@ -317,7 +318,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19805 console_verbose();
19806 } else {
19807 /* Don't log too much for fake panic */
19808 - if (atomic_inc_return(&mce_fake_paniced) > 1)
19809 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
19810 return;
19811 }
19812 /* First print corrected ones that are still unlogged */
19813 @@ -356,7 +357,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
19814 if (!fake_panic) {
19815 if (panic_timeout == 0)
19816 panic_timeout = mca_cfg.panic_timeout;
19817 - panic(msg);
19818 + panic("%s", msg);
19819 } else
19820 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
19821 }
19822 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
19823 * might have been modified by someone else.
19824 */
19825 rmb();
19826 - if (atomic_read(&mce_paniced))
19827 + if (atomic_read_unchecked(&mce_paniced))
19828 wait_for_panic();
19829 if (!mca_cfg.monarch_timeout)
19830 goto out;
19831 @@ -1657,7 +1658,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
19832 }
19833
19834 /* Call the installed machine check handler for this CPU setup. */
19835 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
19836 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
19837 unexpected_machine_check;
19838
19839 /*
19840 @@ -1680,7 +1681,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19841 return;
19842 }
19843
19844 + pax_open_kernel();
19845 machine_check_vector = do_machine_check;
19846 + pax_close_kernel();
19847
19848 __mcheck_cpu_init_generic();
19849 __mcheck_cpu_init_vendor(c);
19850 @@ -1694,7 +1697,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
19851 */
19852
19853 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
19854 -static int mce_chrdev_open_count; /* #times opened */
19855 +static local_t mce_chrdev_open_count; /* #times opened */
19856 static int mce_chrdev_open_exclu; /* already open exclusive? */
19857
19858 static int mce_chrdev_open(struct inode *inode, struct file *file)
19859 @@ -1702,7 +1705,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19860 spin_lock(&mce_chrdev_state_lock);
19861
19862 if (mce_chrdev_open_exclu ||
19863 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
19864 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
19865 spin_unlock(&mce_chrdev_state_lock);
19866
19867 return -EBUSY;
19868 @@ -1710,7 +1713,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
19869
19870 if (file->f_flags & O_EXCL)
19871 mce_chrdev_open_exclu = 1;
19872 - mce_chrdev_open_count++;
19873 + local_inc(&mce_chrdev_open_count);
19874
19875 spin_unlock(&mce_chrdev_state_lock);
19876
19877 @@ -1721,7 +1724,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
19878 {
19879 spin_lock(&mce_chrdev_state_lock);
19880
19881 - mce_chrdev_open_count--;
19882 + local_dec(&mce_chrdev_open_count);
19883 mce_chrdev_open_exclu = 0;
19884
19885 spin_unlock(&mce_chrdev_state_lock);
19886 @@ -2376,7 +2379,7 @@ static __init void mce_init_banks(void)
19887
19888 for (i = 0; i < mca_cfg.banks; i++) {
19889 struct mce_bank *b = &mce_banks[i];
19890 - struct device_attribute *a = &b->attr;
19891 + device_attribute_no_const *a = &b->attr;
19892
19893 sysfs_attr_init(&a->attr);
19894 a->attr.name = b->attrname;
19895 @@ -2444,7 +2447,7 @@ struct dentry *mce_get_debugfs_dir(void)
19896 static void mce_reset(void)
19897 {
19898 cpu_missing = 0;
19899 - atomic_set(&mce_fake_paniced, 0);
19900 + atomic_set_unchecked(&mce_fake_paniced, 0);
19901 atomic_set(&mce_executing, 0);
19902 atomic_set(&mce_callin, 0);
19903 atomic_set(&global_nwo, 0);
19904 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
19905 index 1c044b1..37a2a43 100644
19906 --- a/arch/x86/kernel/cpu/mcheck/p5.c
19907 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
19908 @@ -11,6 +11,7 @@
19909 #include <asm/processor.h>
19910 #include <asm/mce.h>
19911 #include <asm/msr.h>
19912 +#include <asm/pgtable.h>
19913
19914 /* By default disabled */
19915 int mce_p5_enabled __read_mostly;
19916 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
19917 if (!cpu_has(c, X86_FEATURE_MCE))
19918 return;
19919
19920 + pax_open_kernel();
19921 machine_check_vector = pentium_machine_check;
19922 + pax_close_kernel();
19923 /* Make sure the vector pointer is visible before we enable MCEs: */
19924 wmb();
19925
19926 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
19927 index e9a701a..35317d6 100644
19928 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
19929 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
19930 @@ -10,6 +10,7 @@
19931 #include <asm/processor.h>
19932 #include <asm/mce.h>
19933 #include <asm/msr.h>
19934 +#include <asm/pgtable.h>
19935
19936 /* Machine check handler for WinChip C6: */
19937 static void winchip_machine_check(struct pt_regs *regs, long error_code)
19938 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
19939 {
19940 u32 lo, hi;
19941
19942 + pax_open_kernel();
19943 machine_check_vector = winchip_machine_check;
19944 + pax_close_kernel();
19945 /* Make sure the vector pointer is visible before we enable MCEs: */
19946 wmb();
19947
19948 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
19949 index f961de9..8a9d332 100644
19950 --- a/arch/x86/kernel/cpu/mtrr/main.c
19951 +++ b/arch/x86/kernel/cpu/mtrr/main.c
19952 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
19953 u64 size_or_mask, size_and_mask;
19954 static bool mtrr_aps_delayed_init;
19955
19956 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
19957 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
19958
19959 const struct mtrr_ops *mtrr_if;
19960
19961 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
19962 index df5e41f..816c719 100644
19963 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
19964 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
19965 @@ -25,7 +25,7 @@ struct mtrr_ops {
19966 int (*validate_add_page)(unsigned long base, unsigned long size,
19967 unsigned int type);
19968 int (*have_wrcomb)(void);
19969 -};
19970 +} __do_const;
19971
19972 extern int generic_get_free_region(unsigned long base, unsigned long size,
19973 int replace_reg);
19974 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19975 index a7c7305..b9705ab 100644
19976 --- a/arch/x86/kernel/cpu/perf_event.c
19977 +++ b/arch/x86/kernel/cpu/perf_event.c
19978 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
19979 pr_info("no hardware sampling interrupt available.\n");
19980 }
19981
19982 -static struct attribute_group x86_pmu_format_group = {
19983 +static attribute_group_no_const x86_pmu_format_group = {
19984 .name = "format",
19985 .attrs = NULL,
19986 };
19987 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
19988 NULL,
19989 };
19990
19991 -static struct attribute_group x86_pmu_events_group = {
19992 +static attribute_group_no_const x86_pmu_events_group = {
19993 .name = "events",
19994 .attrs = events_attr,
19995 };
19996 @@ -1957,7 +1957,7 @@ static unsigned long get_segment_base(unsigned int segment)
19997 if (idx > GDT_ENTRIES)
19998 return 0;
19999
20000 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20001 + desc = get_cpu_gdt_table(smp_processor_id());
20002 }
20003
20004 return get_desc_base(desc + idx);
20005 @@ -2047,7 +2047,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20006 break;
20007
20008 perf_callchain_store(entry, frame.return_address);
20009 - fp = frame.next_frame;
20010 + fp = (const void __force_user *)frame.next_frame;
20011 }
20012 }
20013
20014 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20015 index 639d128..e92d7e5 100644
20016 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20017 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20018 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20019 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20020 {
20021 struct attribute **attrs;
20022 - struct attribute_group *attr_group;
20023 + attribute_group_no_const *attr_group;
20024 int i = 0, j;
20025
20026 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20027 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20028 index a45d8d4..8abd32c 100644
20029 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20030 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20031 @@ -2099,10 +2099,10 @@ __init int intel_pmu_init(void)
20032 * v2 and above have a perf capabilities MSR
20033 */
20034 if (version > 1) {
20035 - u64 capabilities;
20036 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20037
20038 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20039 - x86_pmu.intel_cap.capabilities = capabilities;
20040 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20041 + x86_pmu.intel_cap.capabilities = capabilities;
20042 }
20043
20044 intel_ds_init();
20045 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20046 index 1fb6c72..f5fa2a3 100644
20047 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20048 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20049 @@ -3095,7 +3095,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20050 static int __init uncore_type_init(struct intel_uncore_type *type)
20051 {
20052 struct intel_uncore_pmu *pmus;
20053 - struct attribute_group *attr_group;
20054 + attribute_group_no_const *attr_group;
20055 struct attribute **attrs;
20056 int i, j;
20057
20058 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20059 index 47b3d00c..2cf1751 100644
20060 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20061 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20062 @@ -488,7 +488,7 @@ struct intel_uncore_box {
20063 struct uncore_event_desc {
20064 struct kobj_attribute attr;
20065 const char *config;
20066 -};
20067 +} __do_const;
20068
20069 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20070 { \
20071 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20072 index 7d9481c..99c7e4b 100644
20073 --- a/arch/x86/kernel/cpuid.c
20074 +++ b/arch/x86/kernel/cpuid.c
20075 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20076 return notifier_from_errno(err);
20077 }
20078
20079 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20080 +static struct notifier_block cpuid_class_cpu_notifier =
20081 {
20082 .notifier_call = cpuid_class_cpu_callback,
20083 };
20084 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20085 index 74467fe..18793d5 100644
20086 --- a/arch/x86/kernel/crash.c
20087 +++ b/arch/x86/kernel/crash.c
20088 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20089 {
20090 #ifdef CONFIG_X86_32
20091 struct pt_regs fixed_regs;
20092 -#endif
20093
20094 -#ifdef CONFIG_X86_32
20095 - if (!user_mode_vm(regs)) {
20096 + if (!user_mode(regs)) {
20097 crash_fixup_ss_esp(&fixed_regs, regs);
20098 regs = &fixed_regs;
20099 }
20100 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20101 index afa64ad..dce67dd 100644
20102 --- a/arch/x86/kernel/crash_dump_64.c
20103 +++ b/arch/x86/kernel/crash_dump_64.c
20104 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20105 return -ENOMEM;
20106
20107 if (userbuf) {
20108 - if (copy_to_user(buf, vaddr + offset, csize)) {
20109 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20110 iounmap(vaddr);
20111 return -EFAULT;
20112 }
20113 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20114 index 5d3fe8d..02e1429 100644
20115 --- a/arch/x86/kernel/doublefault.c
20116 +++ b/arch/x86/kernel/doublefault.c
20117 @@ -13,7 +13,7 @@
20118
20119 #define DOUBLEFAULT_STACKSIZE (1024)
20120 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20121 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20122 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20123
20124 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20125
20126 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20127 unsigned long gdt, tss;
20128
20129 native_store_gdt(&gdt_desc);
20130 - gdt = gdt_desc.address;
20131 + gdt = (unsigned long)gdt_desc.address;
20132
20133 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20134
20135 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20136 /* 0x2 bit is always set */
20137 .flags = X86_EFLAGS_SF | 0x2,
20138 .sp = STACK_START,
20139 - .es = __USER_DS,
20140 + .es = __KERNEL_DS,
20141 .cs = __KERNEL_CS,
20142 .ss = __KERNEL_DS,
20143 - .ds = __USER_DS,
20144 + .ds = __KERNEL_DS,
20145 .fs = __KERNEL_PERCPU,
20146
20147 .__cr3 = __pa_nodebug(swapper_pg_dir),
20148 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20149 index deb6421..76bbc12 100644
20150 --- a/arch/x86/kernel/dumpstack.c
20151 +++ b/arch/x86/kernel/dumpstack.c
20152 @@ -2,6 +2,9 @@
20153 * Copyright (C) 1991, 1992 Linus Torvalds
20154 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20155 */
20156 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20157 +#define __INCLUDED_BY_HIDESYM 1
20158 +#endif
20159 #include <linux/kallsyms.h>
20160 #include <linux/kprobes.h>
20161 #include <linux/uaccess.h>
20162 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20163 static void
20164 print_ftrace_graph_addr(unsigned long addr, void *data,
20165 const struct stacktrace_ops *ops,
20166 - struct thread_info *tinfo, int *graph)
20167 + struct task_struct *task, int *graph)
20168 {
20169 - struct task_struct *task;
20170 unsigned long ret_addr;
20171 int index;
20172
20173 if (addr != (unsigned long)return_to_handler)
20174 return;
20175
20176 - task = tinfo->task;
20177 index = task->curr_ret_stack;
20178
20179 if (!task->ret_stack || index < *graph)
20180 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20181 static inline void
20182 print_ftrace_graph_addr(unsigned long addr, void *data,
20183 const struct stacktrace_ops *ops,
20184 - struct thread_info *tinfo, int *graph)
20185 + struct task_struct *task, int *graph)
20186 { }
20187 #endif
20188
20189 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20190 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20191 */
20192
20193 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20194 - void *p, unsigned int size, void *end)
20195 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20196 {
20197 - void *t = tinfo;
20198 if (end) {
20199 if (p < end && p >= (end-THREAD_SIZE))
20200 return 1;
20201 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20202 }
20203
20204 unsigned long
20205 -print_context_stack(struct thread_info *tinfo,
20206 +print_context_stack(struct task_struct *task, void *stack_start,
20207 unsigned long *stack, unsigned long bp,
20208 const struct stacktrace_ops *ops, void *data,
20209 unsigned long *end, int *graph)
20210 {
20211 struct stack_frame *frame = (struct stack_frame *)bp;
20212
20213 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20214 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20215 unsigned long addr;
20216
20217 addr = *stack;
20218 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20219 } else {
20220 ops->address(data, addr, 0);
20221 }
20222 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20223 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20224 }
20225 stack++;
20226 }
20227 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20228 EXPORT_SYMBOL_GPL(print_context_stack);
20229
20230 unsigned long
20231 -print_context_stack_bp(struct thread_info *tinfo,
20232 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20233 unsigned long *stack, unsigned long bp,
20234 const struct stacktrace_ops *ops, void *data,
20235 unsigned long *end, int *graph)
20236 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20237 struct stack_frame *frame = (struct stack_frame *)bp;
20238 unsigned long *ret_addr = &frame->return_address;
20239
20240 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20241 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20242 unsigned long addr = *ret_addr;
20243
20244 if (!__kernel_text_address(addr))
20245 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20246 ops->address(data, addr, 1);
20247 frame = frame->next_frame;
20248 ret_addr = &frame->return_address;
20249 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20250 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20251 }
20252
20253 return (unsigned long)frame;
20254 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20255 static void print_trace_address(void *data, unsigned long addr, int reliable)
20256 {
20257 touch_nmi_watchdog();
20258 - printk(data);
20259 + printk("%s", (char *)data);
20260 printk_address(addr, reliable);
20261 }
20262
20263 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20264 }
20265 EXPORT_SYMBOL_GPL(oops_begin);
20266
20267 +extern void gr_handle_kernel_exploit(void);
20268 +
20269 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20270 {
20271 if (regs && kexec_should_crash(current))
20272 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20273 panic("Fatal exception in interrupt");
20274 if (panic_on_oops)
20275 panic("Fatal exception");
20276 - do_exit(signr);
20277 +
20278 + gr_handle_kernel_exploit();
20279 +
20280 + do_group_exit(signr);
20281 }
20282
20283 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20284 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20285 print_modules();
20286 show_regs(regs);
20287 #ifdef CONFIG_X86_32
20288 - if (user_mode_vm(regs)) {
20289 + if (user_mode(regs)) {
20290 sp = regs->sp;
20291 ss = regs->ss & 0xffff;
20292 } else {
20293 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
20294 unsigned long flags = oops_begin();
20295 int sig = SIGSEGV;
20296
20297 - if (!user_mode_vm(regs))
20298 + if (!user_mode(regs))
20299 report_bug(regs->ip, regs);
20300
20301 if (__die(str, regs, err))
20302 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
20303 index f2a1770..540657f 100644
20304 --- a/arch/x86/kernel/dumpstack_32.c
20305 +++ b/arch/x86/kernel/dumpstack_32.c
20306 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20307 bp = stack_frame(task, regs);
20308
20309 for (;;) {
20310 - struct thread_info *context;
20311 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20312
20313 - context = (struct thread_info *)
20314 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
20315 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
20316 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20317
20318 - stack = (unsigned long *)context->previous_esp;
20319 - if (!stack)
20320 + if (stack_start == task_stack_page(task))
20321 break;
20322 + stack = *(unsigned long **)stack_start;
20323 if (ops->stack(data, "IRQ") < 0)
20324 break;
20325 touch_nmi_watchdog();
20326 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
20327 int i;
20328
20329 show_regs_print_info(KERN_EMERG);
20330 - __show_regs(regs, !user_mode_vm(regs));
20331 + __show_regs(regs, !user_mode(regs));
20332
20333 /*
20334 * When in-kernel, we also print out the stack and code at the
20335 * time of the fault..
20336 */
20337 - if (!user_mode_vm(regs)) {
20338 + if (!user_mode(regs)) {
20339 unsigned int code_prologue = code_bytes * 43 / 64;
20340 unsigned int code_len = code_bytes;
20341 unsigned char c;
20342 u8 *ip;
20343 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
20344
20345 pr_emerg("Stack:\n");
20346 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
20347
20348 pr_emerg("Code:");
20349
20350 - ip = (u8 *)regs->ip - code_prologue;
20351 + ip = (u8 *)regs->ip - code_prologue + cs_base;
20352 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
20353 /* try starting at IP */
20354 - ip = (u8 *)regs->ip;
20355 + ip = (u8 *)regs->ip + cs_base;
20356 code_len = code_len - code_prologue + 1;
20357 }
20358 for (i = 0; i < code_len; i++, ip++) {
20359 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
20360 pr_cont(" Bad EIP value.");
20361 break;
20362 }
20363 - if (ip == (u8 *)regs->ip)
20364 + if (ip == (u8 *)regs->ip + cs_base)
20365 pr_cont(" <%02x>", c);
20366 else
20367 pr_cont(" %02x", c);
20368 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
20369 {
20370 unsigned short ud2;
20371
20372 + ip = ktla_ktva(ip);
20373 if (ip < PAGE_OFFSET)
20374 return 0;
20375 if (probe_kernel_address((unsigned short *)ip, ud2))
20376 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
20377
20378 return ud2 == 0x0b0f;
20379 }
20380 +
20381 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20382 +void pax_check_alloca(unsigned long size)
20383 +{
20384 + unsigned long sp = (unsigned long)&sp, stack_left;
20385 +
20386 + /* all kernel stacks are of the same size */
20387 + stack_left = sp & (THREAD_SIZE - 1);
20388 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20389 +}
20390 +EXPORT_SYMBOL(pax_check_alloca);
20391 +#endif
20392 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
20393 index addb207..99635fa 100644
20394 --- a/arch/x86/kernel/dumpstack_64.c
20395 +++ b/arch/x86/kernel/dumpstack_64.c
20396 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20397 unsigned long *irq_stack_end =
20398 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
20399 unsigned used = 0;
20400 - struct thread_info *tinfo;
20401 int graph = 0;
20402 unsigned long dummy;
20403 + void *stack_start;
20404
20405 if (!task)
20406 task = current;
20407 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20408 * current stack address. If the stacks consist of nested
20409 * exceptions
20410 */
20411 - tinfo = task_thread_info(task);
20412 for (;;) {
20413 char *id;
20414 unsigned long *estack_end;
20415 +
20416 estack_end = in_exception_stack(cpu, (unsigned long)stack,
20417 &used, &id);
20418
20419 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20420 if (ops->stack(data, id) < 0)
20421 break;
20422
20423 - bp = ops->walk_stack(tinfo, stack, bp, ops,
20424 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
20425 data, estack_end, &graph);
20426 ops->stack(data, "<EOE>");
20427 /*
20428 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20429 * second-to-last pointer (index -2 to end) in the
20430 * exception stack:
20431 */
20432 + if ((u16)estack_end[-1] != __KERNEL_DS)
20433 + goto out;
20434 stack = (unsigned long *) estack_end[-2];
20435 continue;
20436 }
20437 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20438 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
20439 if (ops->stack(data, "IRQ") < 0)
20440 break;
20441 - bp = ops->walk_stack(tinfo, stack, bp,
20442 + bp = ops->walk_stack(task, irq_stack, stack, bp,
20443 ops, data, irq_stack_end, &graph);
20444 /*
20445 * We link to the next stack (which would be
20446 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
20447 /*
20448 * This handles the process stack:
20449 */
20450 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
20451 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
20452 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
20453 +out:
20454 put_cpu();
20455 }
20456 EXPORT_SYMBOL(dump_trace);
20457 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
20458
20459 return ud2 == 0x0b0f;
20460 }
20461 +
20462 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20463 +void pax_check_alloca(unsigned long size)
20464 +{
20465 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
20466 + unsigned cpu, used;
20467 + char *id;
20468 +
20469 + /* check the process stack first */
20470 + stack_start = (unsigned long)task_stack_page(current);
20471 + stack_end = stack_start + THREAD_SIZE;
20472 + if (likely(stack_start <= sp && sp < stack_end)) {
20473 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
20474 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20475 + return;
20476 + }
20477 +
20478 + cpu = get_cpu();
20479 +
20480 + /* check the irq stacks */
20481 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
20482 + stack_start = stack_end - IRQ_STACK_SIZE;
20483 + if (stack_start <= sp && sp < stack_end) {
20484 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
20485 + put_cpu();
20486 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20487 + return;
20488 + }
20489 +
20490 + /* check the exception stacks */
20491 + used = 0;
20492 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
20493 + stack_start = stack_end - EXCEPTION_STKSZ;
20494 + if (stack_end && stack_start <= sp && sp < stack_end) {
20495 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
20496 + put_cpu();
20497 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
20498 + return;
20499 + }
20500 +
20501 + put_cpu();
20502 +
20503 + /* unknown stack */
20504 + BUG();
20505 +}
20506 +EXPORT_SYMBOL(pax_check_alloca);
20507 +#endif
20508 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
20509 index 174da5f..5e55606 100644
20510 --- a/arch/x86/kernel/e820.c
20511 +++ b/arch/x86/kernel/e820.c
20512 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
20513
20514 static void early_panic(char *msg)
20515 {
20516 - early_printk(msg);
20517 - panic(msg);
20518 + early_printk("%s", msg);
20519 + panic("%s", msg);
20520 }
20521
20522 static int userdef __initdata;
20523 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
20524 index d15f575..d692043 100644
20525 --- a/arch/x86/kernel/early_printk.c
20526 +++ b/arch/x86/kernel/early_printk.c
20527 @@ -7,6 +7,7 @@
20528 #include <linux/pci_regs.h>
20529 #include <linux/pci_ids.h>
20530 #include <linux/errno.h>
20531 +#include <linux/sched.h>
20532 #include <asm/io.h>
20533 #include <asm/processor.h>
20534 #include <asm/fcntl.h>
20535 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
20536 index 2cfbc3a..b756682 100644
20537 --- a/arch/x86/kernel/entry_32.S
20538 +++ b/arch/x86/kernel/entry_32.S
20539 @@ -177,13 +177,153 @@
20540 /*CFI_REL_OFFSET gs, PT_GS*/
20541 .endm
20542 .macro SET_KERNEL_GS reg
20543 +
20544 +#ifdef CONFIG_CC_STACKPROTECTOR
20545 movl $(__KERNEL_STACK_CANARY), \reg
20546 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20547 + movl $(__USER_DS), \reg
20548 +#else
20549 + xorl \reg, \reg
20550 +#endif
20551 +
20552 movl \reg, %gs
20553 .endm
20554
20555 #endif /* CONFIG_X86_32_LAZY_GS */
20556
20557 -.macro SAVE_ALL
20558 +.macro pax_enter_kernel
20559 +#ifdef CONFIG_PAX_KERNEXEC
20560 + call pax_enter_kernel
20561 +#endif
20562 +.endm
20563 +
20564 +.macro pax_exit_kernel
20565 +#ifdef CONFIG_PAX_KERNEXEC
20566 + call pax_exit_kernel
20567 +#endif
20568 +.endm
20569 +
20570 +#ifdef CONFIG_PAX_KERNEXEC
20571 +ENTRY(pax_enter_kernel)
20572 +#ifdef CONFIG_PARAVIRT
20573 + pushl %eax
20574 + pushl %ecx
20575 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
20576 + mov %eax, %esi
20577 +#else
20578 + mov %cr0, %esi
20579 +#endif
20580 + bts $16, %esi
20581 + jnc 1f
20582 + mov %cs, %esi
20583 + cmp $__KERNEL_CS, %esi
20584 + jz 3f
20585 + ljmp $__KERNEL_CS, $3f
20586 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
20587 +2:
20588 +#ifdef CONFIG_PARAVIRT
20589 + mov %esi, %eax
20590 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
20591 +#else
20592 + mov %esi, %cr0
20593 +#endif
20594 +3:
20595 +#ifdef CONFIG_PARAVIRT
20596 + popl %ecx
20597 + popl %eax
20598 +#endif
20599 + ret
20600 +ENDPROC(pax_enter_kernel)
20601 +
20602 +ENTRY(pax_exit_kernel)
20603 +#ifdef CONFIG_PARAVIRT
20604 + pushl %eax
20605 + pushl %ecx
20606 +#endif
20607 + mov %cs, %esi
20608 + cmp $__KERNEXEC_KERNEL_CS, %esi
20609 + jnz 2f
20610 +#ifdef CONFIG_PARAVIRT
20611 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
20612 + mov %eax, %esi
20613 +#else
20614 + mov %cr0, %esi
20615 +#endif
20616 + btr $16, %esi
20617 + ljmp $__KERNEL_CS, $1f
20618 +1:
20619 +#ifdef CONFIG_PARAVIRT
20620 + mov %esi, %eax
20621 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
20622 +#else
20623 + mov %esi, %cr0
20624 +#endif
20625 +2:
20626 +#ifdef CONFIG_PARAVIRT
20627 + popl %ecx
20628 + popl %eax
20629 +#endif
20630 + ret
20631 +ENDPROC(pax_exit_kernel)
20632 +#endif
20633 +
20634 + .macro pax_erase_kstack
20635 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20636 + call pax_erase_kstack
20637 +#endif
20638 + .endm
20639 +
20640 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20641 +/*
20642 + * ebp: thread_info
20643 + */
20644 +ENTRY(pax_erase_kstack)
20645 + pushl %edi
20646 + pushl %ecx
20647 + pushl %eax
20648 +
20649 + mov TI_lowest_stack(%ebp), %edi
20650 + mov $-0xBEEF, %eax
20651 + std
20652 +
20653 +1: mov %edi, %ecx
20654 + and $THREAD_SIZE_asm - 1, %ecx
20655 + shr $2, %ecx
20656 + repne scasl
20657 + jecxz 2f
20658 +
20659 + cmp $2*16, %ecx
20660 + jc 2f
20661 +
20662 + mov $2*16, %ecx
20663 + repe scasl
20664 + jecxz 2f
20665 + jne 1b
20666 +
20667 +2: cld
20668 + mov %esp, %ecx
20669 + sub %edi, %ecx
20670 +
20671 + cmp $THREAD_SIZE_asm, %ecx
20672 + jb 3f
20673 + ud2
20674 +3:
20675 +
20676 + shr $2, %ecx
20677 + rep stosl
20678 +
20679 + mov TI_task_thread_sp0(%ebp), %edi
20680 + sub $128, %edi
20681 + mov %edi, TI_lowest_stack(%ebp)
20682 +
20683 + popl %eax
20684 + popl %ecx
20685 + popl %edi
20686 + ret
20687 +ENDPROC(pax_erase_kstack)
20688 +#endif
20689 +
20690 +.macro __SAVE_ALL _DS
20691 cld
20692 PUSH_GS
20693 pushl_cfi %fs
20694 @@ -206,7 +346,7 @@
20695 CFI_REL_OFFSET ecx, 0
20696 pushl_cfi %ebx
20697 CFI_REL_OFFSET ebx, 0
20698 - movl $(__USER_DS), %edx
20699 + movl $\_DS, %edx
20700 movl %edx, %ds
20701 movl %edx, %es
20702 movl $(__KERNEL_PERCPU), %edx
20703 @@ -214,6 +354,15 @@
20704 SET_KERNEL_GS %edx
20705 .endm
20706
20707 +.macro SAVE_ALL
20708 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20709 + __SAVE_ALL __KERNEL_DS
20710 + pax_enter_kernel
20711 +#else
20712 + __SAVE_ALL __USER_DS
20713 +#endif
20714 +.endm
20715 +
20716 .macro RESTORE_INT_REGS
20717 popl_cfi %ebx
20718 CFI_RESTORE ebx
20719 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
20720 popfl_cfi
20721 jmp syscall_exit
20722 CFI_ENDPROC
20723 -END(ret_from_fork)
20724 +ENDPROC(ret_from_fork)
20725
20726 ENTRY(ret_from_kernel_thread)
20727 CFI_STARTPROC
20728 @@ -344,7 +493,15 @@ ret_from_intr:
20729 andl $SEGMENT_RPL_MASK, %eax
20730 #endif
20731 cmpl $USER_RPL, %eax
20732 +
20733 +#ifdef CONFIG_PAX_KERNEXEC
20734 + jae resume_userspace
20735 +
20736 + pax_exit_kernel
20737 + jmp resume_kernel
20738 +#else
20739 jb resume_kernel # not returning to v8086 or userspace
20740 +#endif
20741
20742 ENTRY(resume_userspace)
20743 LOCKDEP_SYS_EXIT
20744 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
20745 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
20746 # int/exception return?
20747 jne work_pending
20748 - jmp restore_all
20749 -END(ret_from_exception)
20750 + jmp restore_all_pax
20751 +ENDPROC(ret_from_exception)
20752
20753 #ifdef CONFIG_PREEMPT
20754 ENTRY(resume_kernel)
20755 @@ -372,7 +529,7 @@ need_resched:
20756 jz restore_all
20757 call preempt_schedule_irq
20758 jmp need_resched
20759 -END(resume_kernel)
20760 +ENDPROC(resume_kernel)
20761 #endif
20762 CFI_ENDPROC
20763 /*
20764 @@ -406,30 +563,45 @@ sysenter_past_esp:
20765 /*CFI_REL_OFFSET cs, 0*/
20766 /*
20767 * Push current_thread_info()->sysenter_return to the stack.
20768 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
20769 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
20770 */
20771 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
20772 + pushl_cfi $0
20773 CFI_REL_OFFSET eip, 0
20774
20775 pushl_cfi %eax
20776 SAVE_ALL
20777 + GET_THREAD_INFO(%ebp)
20778 + movl TI_sysenter_return(%ebp),%ebp
20779 + movl %ebp,PT_EIP(%esp)
20780 ENABLE_INTERRUPTS(CLBR_NONE)
20781
20782 /*
20783 * Load the potential sixth argument from user stack.
20784 * Careful about security.
20785 */
20786 + movl PT_OLDESP(%esp),%ebp
20787 +
20788 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20789 + mov PT_OLDSS(%esp),%ds
20790 +1: movl %ds:(%ebp),%ebp
20791 + push %ss
20792 + pop %ds
20793 +#else
20794 cmpl $__PAGE_OFFSET-3,%ebp
20795 jae syscall_fault
20796 ASM_STAC
20797 1: movl (%ebp),%ebp
20798 ASM_CLAC
20799 +#endif
20800 +
20801 movl %ebp,PT_EBP(%esp)
20802 _ASM_EXTABLE(1b,syscall_fault)
20803
20804 GET_THREAD_INFO(%ebp)
20805
20806 +#ifdef CONFIG_PAX_RANDKSTACK
20807 + pax_erase_kstack
20808 +#endif
20809 +
20810 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20811 jnz sysenter_audit
20812 sysenter_do_call:
20813 @@ -444,12 +616,24 @@ sysenter_do_call:
20814 testl $_TIF_ALLWORK_MASK, %ecx
20815 jne sysexit_audit
20816 sysenter_exit:
20817 +
20818 +#ifdef CONFIG_PAX_RANDKSTACK
20819 + pushl_cfi %eax
20820 + movl %esp, %eax
20821 + call pax_randomize_kstack
20822 + popl_cfi %eax
20823 +#endif
20824 +
20825 + pax_erase_kstack
20826 +
20827 /* if something modifies registers it must also disable sysexit */
20828 movl PT_EIP(%esp), %edx
20829 movl PT_OLDESP(%esp), %ecx
20830 xorl %ebp,%ebp
20831 TRACE_IRQS_ON
20832 1: mov PT_FS(%esp), %fs
20833 +2: mov PT_DS(%esp), %ds
20834 +3: mov PT_ES(%esp), %es
20835 PTGS_TO_GS
20836 ENABLE_INTERRUPTS_SYSEXIT
20837
20838 @@ -466,6 +650,9 @@ sysenter_audit:
20839 movl %eax,%edx /* 2nd arg: syscall number */
20840 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
20841 call __audit_syscall_entry
20842 +
20843 + pax_erase_kstack
20844 +
20845 pushl_cfi %ebx
20846 movl PT_EAX(%esp),%eax /* reload syscall number */
20847 jmp sysenter_do_call
20848 @@ -491,10 +678,16 @@ sysexit_audit:
20849
20850 CFI_ENDPROC
20851 .pushsection .fixup,"ax"
20852 -2: movl $0,PT_FS(%esp)
20853 +4: movl $0,PT_FS(%esp)
20854 + jmp 1b
20855 +5: movl $0,PT_DS(%esp)
20856 + jmp 1b
20857 +6: movl $0,PT_ES(%esp)
20858 jmp 1b
20859 .popsection
20860 - _ASM_EXTABLE(1b,2b)
20861 + _ASM_EXTABLE(1b,4b)
20862 + _ASM_EXTABLE(2b,5b)
20863 + _ASM_EXTABLE(3b,6b)
20864 PTGS_TO_GS_EX
20865 ENDPROC(ia32_sysenter_target)
20866
20867 @@ -509,6 +702,11 @@ ENTRY(system_call)
20868 pushl_cfi %eax # save orig_eax
20869 SAVE_ALL
20870 GET_THREAD_INFO(%ebp)
20871 +
20872 +#ifdef CONFIG_PAX_RANDKSTACK
20873 + pax_erase_kstack
20874 +#endif
20875 +
20876 # system call tracing in operation / emulation
20877 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
20878 jnz syscall_trace_entry
20879 @@ -527,6 +725,15 @@ syscall_exit:
20880 testl $_TIF_ALLWORK_MASK, %ecx # current->work
20881 jne syscall_exit_work
20882
20883 +restore_all_pax:
20884 +
20885 +#ifdef CONFIG_PAX_RANDKSTACK
20886 + movl %esp, %eax
20887 + call pax_randomize_kstack
20888 +#endif
20889 +
20890 + pax_erase_kstack
20891 +
20892 restore_all:
20893 TRACE_IRQS_IRET
20894 restore_all_notrace:
20895 @@ -583,14 +790,34 @@ ldt_ss:
20896 * compensating for the offset by changing to the ESPFIX segment with
20897 * a base address that matches for the difference.
20898 */
20899 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
20900 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
20901 mov %esp, %edx /* load kernel esp */
20902 mov PT_OLDESP(%esp), %eax /* load userspace esp */
20903 mov %dx, %ax /* eax: new kernel esp */
20904 sub %eax, %edx /* offset (low word is 0) */
20905 +#ifdef CONFIG_SMP
20906 + movl PER_CPU_VAR(cpu_number), %ebx
20907 + shll $PAGE_SHIFT_asm, %ebx
20908 + addl $cpu_gdt_table, %ebx
20909 +#else
20910 + movl $cpu_gdt_table, %ebx
20911 +#endif
20912 shr $16, %edx
20913 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
20914 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
20915 +
20916 +#ifdef CONFIG_PAX_KERNEXEC
20917 + mov %cr0, %esi
20918 + btr $16, %esi
20919 + mov %esi, %cr0
20920 +#endif
20921 +
20922 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
20923 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
20924 +
20925 +#ifdef CONFIG_PAX_KERNEXEC
20926 + bts $16, %esi
20927 + mov %esi, %cr0
20928 +#endif
20929 +
20930 pushl_cfi $__ESPFIX_SS
20931 pushl_cfi %eax /* new kernel esp */
20932 /* Disable interrupts, but do not irqtrace this section: we
20933 @@ -619,20 +846,18 @@ work_resched:
20934 movl TI_flags(%ebp), %ecx
20935 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
20936 # than syscall tracing?
20937 - jz restore_all
20938 + jz restore_all_pax
20939 testb $_TIF_NEED_RESCHED, %cl
20940 jnz work_resched
20941
20942 work_notifysig: # deal with pending signals and
20943 # notify-resume requests
20944 + movl %esp, %eax
20945 #ifdef CONFIG_VM86
20946 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
20947 - movl %esp, %eax
20948 jne work_notifysig_v86 # returning to kernel-space or
20949 # vm86-space
20950 1:
20951 -#else
20952 - movl %esp, %eax
20953 #endif
20954 TRACE_IRQS_ON
20955 ENABLE_INTERRUPTS(CLBR_NONE)
20956 @@ -653,7 +878,7 @@ work_notifysig_v86:
20957 movl %eax, %esp
20958 jmp 1b
20959 #endif
20960 -END(work_pending)
20961 +ENDPROC(work_pending)
20962
20963 # perform syscall exit tracing
20964 ALIGN
20965 @@ -661,11 +886,14 @@ syscall_trace_entry:
20966 movl $-ENOSYS,PT_EAX(%esp)
20967 movl %esp, %eax
20968 call syscall_trace_enter
20969 +
20970 + pax_erase_kstack
20971 +
20972 /* What it returned is what we'll actually use. */
20973 cmpl $(NR_syscalls), %eax
20974 jnae syscall_call
20975 jmp syscall_exit
20976 -END(syscall_trace_entry)
20977 +ENDPROC(syscall_trace_entry)
20978
20979 # perform syscall exit tracing
20980 ALIGN
20981 @@ -678,21 +906,25 @@ syscall_exit_work:
20982 movl %esp, %eax
20983 call syscall_trace_leave
20984 jmp resume_userspace
20985 -END(syscall_exit_work)
20986 +ENDPROC(syscall_exit_work)
20987 CFI_ENDPROC
20988
20989 RING0_INT_FRAME # can't unwind into user space anyway
20990 syscall_fault:
20991 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20992 + push %ss
20993 + pop %ds
20994 +#endif
20995 ASM_CLAC
20996 GET_THREAD_INFO(%ebp)
20997 movl $-EFAULT,PT_EAX(%esp)
20998 jmp resume_userspace
20999 -END(syscall_fault)
21000 +ENDPROC(syscall_fault)
21001
21002 syscall_badsys:
21003 movl $-ENOSYS,PT_EAX(%esp)
21004 jmp resume_userspace
21005 -END(syscall_badsys)
21006 +ENDPROC(syscall_badsys)
21007 CFI_ENDPROC
21008 /*
21009 * End of kprobes section
21010 @@ -708,8 +940,15 @@ END(syscall_badsys)
21011 * normal stack and adjusts ESP with the matching offset.
21012 */
21013 /* fixup the stack */
21014 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21015 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21016 +#ifdef CONFIG_SMP
21017 + movl PER_CPU_VAR(cpu_number), %ebx
21018 + shll $PAGE_SHIFT_asm, %ebx
21019 + addl $cpu_gdt_table, %ebx
21020 +#else
21021 + movl $cpu_gdt_table, %ebx
21022 +#endif
21023 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21024 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21025 shl $16, %eax
21026 addl %esp, %eax /* the adjusted stack pointer */
21027 pushl_cfi $__KERNEL_DS
21028 @@ -762,7 +1001,7 @@ vector=vector+1
21029 .endr
21030 2: jmp common_interrupt
21031 .endr
21032 -END(irq_entries_start)
21033 +ENDPROC(irq_entries_start)
21034
21035 .previous
21036 END(interrupt)
21037 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21038 pushl_cfi $do_coprocessor_error
21039 jmp error_code
21040 CFI_ENDPROC
21041 -END(coprocessor_error)
21042 +ENDPROC(coprocessor_error)
21043
21044 ENTRY(simd_coprocessor_error)
21045 RING0_INT_FRAME
21046 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21047 .section .altinstructions,"a"
21048 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21049 .previous
21050 -.section .altinstr_replacement,"ax"
21051 +.section .altinstr_replacement,"a"
21052 663: pushl $do_simd_coprocessor_error
21053 664:
21054 .previous
21055 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21056 #endif
21057 jmp error_code
21058 CFI_ENDPROC
21059 -END(simd_coprocessor_error)
21060 +ENDPROC(simd_coprocessor_error)
21061
21062 ENTRY(device_not_available)
21063 RING0_INT_FRAME
21064 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21065 pushl_cfi $do_device_not_available
21066 jmp error_code
21067 CFI_ENDPROC
21068 -END(device_not_available)
21069 +ENDPROC(device_not_available)
21070
21071 #ifdef CONFIG_PARAVIRT
21072 ENTRY(native_iret)
21073 iret
21074 _ASM_EXTABLE(native_iret, iret_exc)
21075 -END(native_iret)
21076 +ENDPROC(native_iret)
21077
21078 ENTRY(native_irq_enable_sysexit)
21079 sti
21080 sysexit
21081 -END(native_irq_enable_sysexit)
21082 +ENDPROC(native_irq_enable_sysexit)
21083 #endif
21084
21085 ENTRY(overflow)
21086 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21087 pushl_cfi $do_overflow
21088 jmp error_code
21089 CFI_ENDPROC
21090 -END(overflow)
21091 +ENDPROC(overflow)
21092
21093 ENTRY(bounds)
21094 RING0_INT_FRAME
21095 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21096 pushl_cfi $do_bounds
21097 jmp error_code
21098 CFI_ENDPROC
21099 -END(bounds)
21100 +ENDPROC(bounds)
21101
21102 ENTRY(invalid_op)
21103 RING0_INT_FRAME
21104 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21105 pushl_cfi $do_invalid_op
21106 jmp error_code
21107 CFI_ENDPROC
21108 -END(invalid_op)
21109 +ENDPROC(invalid_op)
21110
21111 ENTRY(coprocessor_segment_overrun)
21112 RING0_INT_FRAME
21113 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21114 pushl_cfi $do_coprocessor_segment_overrun
21115 jmp error_code
21116 CFI_ENDPROC
21117 -END(coprocessor_segment_overrun)
21118 +ENDPROC(coprocessor_segment_overrun)
21119
21120 ENTRY(invalid_TSS)
21121 RING0_EC_FRAME
21122 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21123 pushl_cfi $do_invalid_TSS
21124 jmp error_code
21125 CFI_ENDPROC
21126 -END(invalid_TSS)
21127 +ENDPROC(invalid_TSS)
21128
21129 ENTRY(segment_not_present)
21130 RING0_EC_FRAME
21131 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21132 pushl_cfi $do_segment_not_present
21133 jmp error_code
21134 CFI_ENDPROC
21135 -END(segment_not_present)
21136 +ENDPROC(segment_not_present)
21137
21138 ENTRY(stack_segment)
21139 RING0_EC_FRAME
21140 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21141 pushl_cfi $do_stack_segment
21142 jmp error_code
21143 CFI_ENDPROC
21144 -END(stack_segment)
21145 +ENDPROC(stack_segment)
21146
21147 ENTRY(alignment_check)
21148 RING0_EC_FRAME
21149 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21150 pushl_cfi $do_alignment_check
21151 jmp error_code
21152 CFI_ENDPROC
21153 -END(alignment_check)
21154 +ENDPROC(alignment_check)
21155
21156 ENTRY(divide_error)
21157 RING0_INT_FRAME
21158 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21159 pushl_cfi $do_divide_error
21160 jmp error_code
21161 CFI_ENDPROC
21162 -END(divide_error)
21163 +ENDPROC(divide_error)
21164
21165 #ifdef CONFIG_X86_MCE
21166 ENTRY(machine_check)
21167 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21168 pushl_cfi machine_check_vector
21169 jmp error_code
21170 CFI_ENDPROC
21171 -END(machine_check)
21172 +ENDPROC(machine_check)
21173 #endif
21174
21175 ENTRY(spurious_interrupt_bug)
21176 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21177 pushl_cfi $do_spurious_interrupt_bug
21178 jmp error_code
21179 CFI_ENDPROC
21180 -END(spurious_interrupt_bug)
21181 +ENDPROC(spurious_interrupt_bug)
21182 /*
21183 * End of kprobes section
21184 */
21185 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21186
21187 ENTRY(mcount)
21188 ret
21189 -END(mcount)
21190 +ENDPROC(mcount)
21191
21192 ENTRY(ftrace_caller)
21193 cmpl $0, function_trace_stop
21194 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21195 .globl ftrace_stub
21196 ftrace_stub:
21197 ret
21198 -END(ftrace_caller)
21199 +ENDPROC(ftrace_caller)
21200
21201 ENTRY(ftrace_regs_caller)
21202 pushf /* push flags before compare (in cs location) */
21203 @@ -1207,7 +1446,7 @@ trace:
21204 popl %ecx
21205 popl %eax
21206 jmp ftrace_stub
21207 -END(mcount)
21208 +ENDPROC(mcount)
21209 #endif /* CONFIG_DYNAMIC_FTRACE */
21210 #endif /* CONFIG_FUNCTION_TRACER */
21211
21212 @@ -1225,7 +1464,7 @@ ENTRY(ftrace_graph_caller)
21213 popl %ecx
21214 popl %eax
21215 ret
21216 -END(ftrace_graph_caller)
21217 +ENDPROC(ftrace_graph_caller)
21218
21219 .globl return_to_handler
21220 return_to_handler:
21221 @@ -1281,15 +1520,18 @@ error_code:
21222 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21223 REG_TO_PTGS %ecx
21224 SET_KERNEL_GS %ecx
21225 - movl $(__USER_DS), %ecx
21226 + movl $(__KERNEL_DS), %ecx
21227 movl %ecx, %ds
21228 movl %ecx, %es
21229 +
21230 + pax_enter_kernel
21231 +
21232 TRACE_IRQS_OFF
21233 movl %esp,%eax # pt_regs pointer
21234 call *%edi
21235 jmp ret_from_exception
21236 CFI_ENDPROC
21237 -END(page_fault)
21238 +ENDPROC(page_fault)
21239
21240 /*
21241 * Debug traps and NMI can happen at the one SYSENTER instruction
21242 @@ -1332,7 +1574,7 @@ debug_stack_correct:
21243 call do_debug
21244 jmp ret_from_exception
21245 CFI_ENDPROC
21246 -END(debug)
21247 +ENDPROC(debug)
21248
21249 /*
21250 * NMI is doubly nasty. It can happen _while_ we're handling
21251 @@ -1370,6 +1612,9 @@ nmi_stack_correct:
21252 xorl %edx,%edx # zero error code
21253 movl %esp,%eax # pt_regs pointer
21254 call do_nmi
21255 +
21256 + pax_exit_kernel
21257 +
21258 jmp restore_all_notrace
21259 CFI_ENDPROC
21260
21261 @@ -1406,12 +1651,15 @@ nmi_espfix_stack:
21262 FIXUP_ESPFIX_STACK # %eax == %esp
21263 xorl %edx,%edx # zero error code
21264 call do_nmi
21265 +
21266 + pax_exit_kernel
21267 +
21268 RESTORE_REGS
21269 lss 12+4(%esp), %esp # back to espfix stack
21270 CFI_ADJUST_CFA_OFFSET -24
21271 jmp irq_return
21272 CFI_ENDPROC
21273 -END(nmi)
21274 +ENDPROC(nmi)
21275
21276 ENTRY(int3)
21277 RING0_INT_FRAME
21278 @@ -1424,14 +1672,14 @@ ENTRY(int3)
21279 call do_int3
21280 jmp ret_from_exception
21281 CFI_ENDPROC
21282 -END(int3)
21283 +ENDPROC(int3)
21284
21285 ENTRY(general_protection)
21286 RING0_EC_FRAME
21287 pushl_cfi $do_general_protection
21288 jmp error_code
21289 CFI_ENDPROC
21290 -END(general_protection)
21291 +ENDPROC(general_protection)
21292
21293 #ifdef CONFIG_KVM_GUEST
21294 ENTRY(async_page_fault)
21295 @@ -1440,7 +1688,7 @@ ENTRY(async_page_fault)
21296 pushl_cfi $do_async_page_fault
21297 jmp error_code
21298 CFI_ENDPROC
21299 -END(async_page_fault)
21300 +ENDPROC(async_page_fault)
21301 #endif
21302
21303 /*
21304 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
21305 index 1b69951..8430a6d 100644
21306 --- a/arch/x86/kernel/entry_64.S
21307 +++ b/arch/x86/kernel/entry_64.S
21308 @@ -59,6 +59,8 @@
21309 #include <asm/context_tracking.h>
21310 #include <asm/smap.h>
21311 #include <linux/err.h>
21312 +#include <asm/pgtable.h>
21313 +#include <asm/alternative-asm.h>
21314
21315 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
21316 #include <linux/elf-em.h>
21317 @@ -80,8 +82,9 @@
21318 #ifdef CONFIG_DYNAMIC_FTRACE
21319
21320 ENTRY(function_hook)
21321 + pax_force_retaddr
21322 retq
21323 -END(function_hook)
21324 +ENDPROC(function_hook)
21325
21326 /* skip is set if stack has been adjusted */
21327 .macro ftrace_caller_setup skip=0
21328 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
21329 #endif
21330
21331 GLOBAL(ftrace_stub)
21332 + pax_force_retaddr
21333 retq
21334 -END(ftrace_caller)
21335 +ENDPROC(ftrace_caller)
21336
21337 ENTRY(ftrace_regs_caller)
21338 /* Save the current flags before compare (in SS location)*/
21339 @@ -191,7 +195,7 @@ ftrace_restore_flags:
21340 popfq
21341 jmp ftrace_stub
21342
21343 -END(ftrace_regs_caller)
21344 +ENDPROC(ftrace_regs_caller)
21345
21346
21347 #else /* ! CONFIG_DYNAMIC_FTRACE */
21348 @@ -212,6 +216,7 @@ ENTRY(function_hook)
21349 #endif
21350
21351 GLOBAL(ftrace_stub)
21352 + pax_force_retaddr
21353 retq
21354
21355 trace:
21356 @@ -225,12 +230,13 @@ trace:
21357 #endif
21358 subq $MCOUNT_INSN_SIZE, %rdi
21359
21360 + pax_force_fptr ftrace_trace_function
21361 call *ftrace_trace_function
21362
21363 MCOUNT_RESTORE_FRAME
21364
21365 jmp ftrace_stub
21366 -END(function_hook)
21367 +ENDPROC(function_hook)
21368 #endif /* CONFIG_DYNAMIC_FTRACE */
21369 #endif /* CONFIG_FUNCTION_TRACER */
21370
21371 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
21372
21373 MCOUNT_RESTORE_FRAME
21374
21375 + pax_force_retaddr
21376 retq
21377 -END(ftrace_graph_caller)
21378 +ENDPROC(ftrace_graph_caller)
21379
21380 GLOBAL(return_to_handler)
21381 subq $24, %rsp
21382 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
21383 movq 8(%rsp), %rdx
21384 movq (%rsp), %rax
21385 addq $24, %rsp
21386 + pax_force_fptr %rdi
21387 jmp *%rdi
21388 +ENDPROC(return_to_handler)
21389 #endif
21390
21391
21392 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
21393 ENDPROC(native_usergs_sysret64)
21394 #endif /* CONFIG_PARAVIRT */
21395
21396 + .macro ljmpq sel, off
21397 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
21398 + .byte 0x48; ljmp *1234f(%rip)
21399 + .pushsection .rodata
21400 + .align 16
21401 + 1234: .quad \off; .word \sel
21402 + .popsection
21403 +#else
21404 + pushq $\sel
21405 + pushq $\off
21406 + lretq
21407 +#endif
21408 + .endm
21409 +
21410 + .macro pax_enter_kernel
21411 + pax_set_fptr_mask
21412 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21413 + call pax_enter_kernel
21414 +#endif
21415 + .endm
21416 +
21417 + .macro pax_exit_kernel
21418 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21419 + call pax_exit_kernel
21420 +#endif
21421 +
21422 + .endm
21423 +
21424 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21425 +ENTRY(pax_enter_kernel)
21426 + pushq %rdi
21427 +
21428 +#ifdef CONFIG_PARAVIRT
21429 + PV_SAVE_REGS(CLBR_RDI)
21430 +#endif
21431 +
21432 +#ifdef CONFIG_PAX_KERNEXEC
21433 + GET_CR0_INTO_RDI
21434 + bts $16,%rdi
21435 + jnc 3f
21436 + mov %cs,%edi
21437 + cmp $__KERNEL_CS,%edi
21438 + jnz 2f
21439 +1:
21440 +#endif
21441 +
21442 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21443 + 661: jmp 111f
21444 + .pushsection .altinstr_replacement, "a"
21445 + 662: ASM_NOP2
21446 + .popsection
21447 + .pushsection .altinstructions, "a"
21448 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21449 + .popsection
21450 + GET_CR3_INTO_RDI
21451 + cmp $0,%dil
21452 + jnz 112f
21453 + mov $__KERNEL_DS,%edi
21454 + mov %edi,%ss
21455 + jmp 111f
21456 +112: cmp $1,%dil
21457 + jz 113f
21458 + ud2
21459 +113: sub $4097,%rdi
21460 + bts $63,%rdi
21461 + SET_RDI_INTO_CR3
21462 + mov $__UDEREF_KERNEL_DS,%edi
21463 + mov %edi,%ss
21464 +111:
21465 +#endif
21466 +
21467 +#ifdef CONFIG_PARAVIRT
21468 + PV_RESTORE_REGS(CLBR_RDI)
21469 +#endif
21470 +
21471 + popq %rdi
21472 + pax_force_retaddr
21473 + retq
21474 +
21475 +#ifdef CONFIG_PAX_KERNEXEC
21476 +2: ljmpq __KERNEL_CS,1b
21477 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
21478 +4: SET_RDI_INTO_CR0
21479 + jmp 1b
21480 +#endif
21481 +ENDPROC(pax_enter_kernel)
21482 +
21483 +ENTRY(pax_exit_kernel)
21484 + pushq %rdi
21485 +
21486 +#ifdef CONFIG_PARAVIRT
21487 + PV_SAVE_REGS(CLBR_RDI)
21488 +#endif
21489 +
21490 +#ifdef CONFIG_PAX_KERNEXEC
21491 + mov %cs,%rdi
21492 + cmp $__KERNEXEC_KERNEL_CS,%edi
21493 + jz 2f
21494 + GET_CR0_INTO_RDI
21495 + bts $16,%rdi
21496 + jnc 4f
21497 +1:
21498 +#endif
21499 +
21500 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21501 + 661: jmp 111f
21502 + .pushsection .altinstr_replacement, "a"
21503 + 662: ASM_NOP2
21504 + .popsection
21505 + .pushsection .altinstructions, "a"
21506 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21507 + .popsection
21508 + mov %ss,%edi
21509 + cmp $__UDEREF_KERNEL_DS,%edi
21510 + jnz 111f
21511 + GET_CR3_INTO_RDI
21512 + cmp $0,%dil
21513 + jz 112f
21514 + ud2
21515 +112: add $4097,%rdi
21516 + bts $63,%rdi
21517 + SET_RDI_INTO_CR3
21518 + mov $__KERNEL_DS,%edi
21519 + mov %edi,%ss
21520 +111:
21521 +#endif
21522 +
21523 +#ifdef CONFIG_PARAVIRT
21524 + PV_RESTORE_REGS(CLBR_RDI);
21525 +#endif
21526 +
21527 + popq %rdi
21528 + pax_force_retaddr
21529 + retq
21530 +
21531 +#ifdef CONFIG_PAX_KERNEXEC
21532 +2: GET_CR0_INTO_RDI
21533 + btr $16,%rdi
21534 + jnc 4f
21535 + ljmpq __KERNEL_CS,3f
21536 +3: SET_RDI_INTO_CR0
21537 + jmp 1b
21538 +4: ud2
21539 + jmp 4b
21540 +#endif
21541 +ENDPROC(pax_exit_kernel)
21542 +#endif
21543 +
21544 + .macro pax_enter_kernel_user
21545 + pax_set_fptr_mask
21546 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21547 + call pax_enter_kernel_user
21548 +#endif
21549 + .endm
21550 +
21551 + .macro pax_exit_kernel_user
21552 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21553 + call pax_exit_kernel_user
21554 +#endif
21555 +#ifdef CONFIG_PAX_RANDKSTACK
21556 + pushq %rax
21557 + pushq %r11
21558 + call pax_randomize_kstack
21559 + popq %r11
21560 + popq %rax
21561 +#endif
21562 + .endm
21563 +
21564 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21565 +ENTRY(pax_enter_kernel_user)
21566 + pushq %rdi
21567 + pushq %rbx
21568 +
21569 +#ifdef CONFIG_PARAVIRT
21570 + PV_SAVE_REGS(CLBR_RDI)
21571 +#endif
21572 +
21573 + 661: jmp 111f
21574 + .pushsection .altinstr_replacement, "a"
21575 + 662: ASM_NOP2
21576 + .popsection
21577 + .pushsection .altinstructions, "a"
21578 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21579 + .popsection
21580 + GET_CR3_INTO_RDI
21581 + cmp $1,%dil
21582 + jnz 4f
21583 + sub $4097,%rdi
21584 + bts $63,%rdi
21585 + SET_RDI_INTO_CR3
21586 + jmp 3f
21587 +111:
21588 +
21589 + GET_CR3_INTO_RDI
21590 + mov %rdi,%rbx
21591 + add $__START_KERNEL_map,%rbx
21592 + sub phys_base(%rip),%rbx
21593 +
21594 +#ifdef CONFIG_PARAVIRT
21595 + cmpl $0, pv_info+PARAVIRT_enabled
21596 + jz 1f
21597 + pushq %rdi
21598 + i = 0
21599 + .rept USER_PGD_PTRS
21600 + mov i*8(%rbx),%rsi
21601 + mov $0,%sil
21602 + lea i*8(%rbx),%rdi
21603 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21604 + i = i + 1
21605 + .endr
21606 + popq %rdi
21607 + jmp 2f
21608 +1:
21609 +#endif
21610 +
21611 + i = 0
21612 + .rept USER_PGD_PTRS
21613 + movb $0,i*8(%rbx)
21614 + i = i + 1
21615 + .endr
21616 +
21617 +2: SET_RDI_INTO_CR3
21618 +
21619 +#ifdef CONFIG_PAX_KERNEXEC
21620 + GET_CR0_INTO_RDI
21621 + bts $16,%rdi
21622 + SET_RDI_INTO_CR0
21623 +#endif
21624 +
21625 +3:
21626 +
21627 +#ifdef CONFIG_PARAVIRT
21628 + PV_RESTORE_REGS(CLBR_RDI)
21629 +#endif
21630 +
21631 + popq %rbx
21632 + popq %rdi
21633 + pax_force_retaddr
21634 + retq
21635 +4: ud2
21636 +ENDPROC(pax_enter_kernel_user)
21637 +
21638 +ENTRY(pax_exit_kernel_user)
21639 + pushq %rdi
21640 + pushq %rbx
21641 +
21642 +#ifdef CONFIG_PARAVIRT
21643 + PV_SAVE_REGS(CLBR_RDI)
21644 +#endif
21645 +
21646 + GET_CR3_INTO_RDI
21647 + 661: jmp 1f
21648 + .pushsection .altinstr_replacement, "a"
21649 + 662: ASM_NOP2
21650 + .popsection
21651 + .pushsection .altinstructions, "a"
21652 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21653 + .popsection
21654 + cmp $0,%dil
21655 + jnz 3f
21656 + add $4097,%rdi
21657 + bts $63,%rdi
21658 + SET_RDI_INTO_CR3
21659 + jmp 2f
21660 +1:
21661 +
21662 + mov %rdi,%rbx
21663 +
21664 +#ifdef CONFIG_PAX_KERNEXEC
21665 + GET_CR0_INTO_RDI
21666 + btr $16,%rdi
21667 + jnc 3f
21668 + SET_RDI_INTO_CR0
21669 +#endif
21670 +
21671 + add $__START_KERNEL_map,%rbx
21672 + sub phys_base(%rip),%rbx
21673 +
21674 +#ifdef CONFIG_PARAVIRT
21675 + cmpl $0, pv_info+PARAVIRT_enabled
21676 + jz 1f
21677 + i = 0
21678 + .rept USER_PGD_PTRS
21679 + mov i*8(%rbx),%rsi
21680 + mov $0x67,%sil
21681 + lea i*8(%rbx),%rdi
21682 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
21683 + i = i + 1
21684 + .endr
21685 + jmp 2f
21686 +1:
21687 +#endif
21688 +
21689 + i = 0
21690 + .rept USER_PGD_PTRS
21691 + movb $0x67,i*8(%rbx)
21692 + i = i + 1
21693 + .endr
21694 +2:
21695 +
21696 +#ifdef CONFIG_PARAVIRT
21697 + PV_RESTORE_REGS(CLBR_RDI)
21698 +#endif
21699 +
21700 + popq %rbx
21701 + popq %rdi
21702 + pax_force_retaddr
21703 + retq
21704 +3: ud2
21705 +ENDPROC(pax_exit_kernel_user)
21706 +#endif
21707 +
21708 + .macro pax_enter_kernel_nmi
21709 + pax_set_fptr_mask
21710 +
21711 +#ifdef CONFIG_PAX_KERNEXEC
21712 + GET_CR0_INTO_RDI
21713 + bts $16,%rdi
21714 + jc 110f
21715 + SET_RDI_INTO_CR0
21716 + or $2,%ebx
21717 +110:
21718 +#endif
21719 +
21720 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21721 + 661: jmp 111f
21722 + .pushsection .altinstr_replacement, "a"
21723 + 662: ASM_NOP2
21724 + .popsection
21725 + .pushsection .altinstructions, "a"
21726 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
21727 + .popsection
21728 + GET_CR3_INTO_RDI
21729 + cmp $0,%dil
21730 + jz 111f
21731 + sub $4097,%rdi
21732 + or $4,%ebx
21733 + bts $63,%rdi
21734 + SET_RDI_INTO_CR3
21735 + mov $__UDEREF_KERNEL_DS,%edi
21736 + mov %edi,%ss
21737 +111:
21738 +#endif
21739 + .endm
21740 +
21741 + .macro pax_exit_kernel_nmi
21742 +#ifdef CONFIG_PAX_KERNEXEC
21743 + btr $1,%ebx
21744 + jnc 110f
21745 + GET_CR0_INTO_RDI
21746 + btr $16,%rdi
21747 + SET_RDI_INTO_CR0
21748 +110:
21749 +#endif
21750 +
21751 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21752 + btr $2,%ebx
21753 + jnc 111f
21754 + GET_CR3_INTO_RDI
21755 + add $4097,%rdi
21756 + bts $63,%rdi
21757 + SET_RDI_INTO_CR3
21758 + mov $__KERNEL_DS,%edi
21759 + mov %edi,%ss
21760 +111:
21761 +#endif
21762 + .endm
21763 +
21764 + .macro pax_erase_kstack
21765 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21766 + call pax_erase_kstack
21767 +#endif
21768 + .endm
21769 +
21770 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21771 +ENTRY(pax_erase_kstack)
21772 + pushq %rdi
21773 + pushq %rcx
21774 + pushq %rax
21775 + pushq %r11
21776 +
21777 + GET_THREAD_INFO(%r11)
21778 + mov TI_lowest_stack(%r11), %rdi
21779 + mov $-0xBEEF, %rax
21780 + std
21781 +
21782 +1: mov %edi, %ecx
21783 + and $THREAD_SIZE_asm - 1, %ecx
21784 + shr $3, %ecx
21785 + repne scasq
21786 + jecxz 2f
21787 +
21788 + cmp $2*8, %ecx
21789 + jc 2f
21790 +
21791 + mov $2*8, %ecx
21792 + repe scasq
21793 + jecxz 2f
21794 + jne 1b
21795 +
21796 +2: cld
21797 + mov %esp, %ecx
21798 + sub %edi, %ecx
21799 +
21800 + cmp $THREAD_SIZE_asm, %rcx
21801 + jb 3f
21802 + ud2
21803 +3:
21804 +
21805 + shr $3, %ecx
21806 + rep stosq
21807 +
21808 + mov TI_task_thread_sp0(%r11), %rdi
21809 + sub $256, %rdi
21810 + mov %rdi, TI_lowest_stack(%r11)
21811 +
21812 + popq %r11
21813 + popq %rax
21814 + popq %rcx
21815 + popq %rdi
21816 + pax_force_retaddr
21817 + ret
21818 +ENDPROC(pax_erase_kstack)
21819 +#endif
21820
21821 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
21822 #ifdef CONFIG_TRACE_IRQFLAGS
21823 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
21824 .endm
21825
21826 .macro UNFAKE_STACK_FRAME
21827 - addq $8*6, %rsp
21828 - CFI_ADJUST_CFA_OFFSET -(6*8)
21829 + addq $8*6 + ARG_SKIP, %rsp
21830 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
21831 .endm
21832
21833 /*
21834 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
21835 movq %rsp, %rsi
21836
21837 leaq -RBP(%rsp),%rdi /* arg1 for handler */
21838 - testl $3, CS-RBP(%rsi)
21839 + testb $3, CS-RBP(%rsi)
21840 je 1f
21841 SWAPGS
21842 /*
21843 @@ -498,9 +931,10 @@ ENTRY(save_rest)
21844 movq_cfi r15, R15+16
21845 movq %r11, 8(%rsp) /* return address */
21846 FIXUP_TOP_OF_STACK %r11, 16
21847 + pax_force_retaddr
21848 ret
21849 CFI_ENDPROC
21850 -END(save_rest)
21851 +ENDPROC(save_rest)
21852
21853 /* save complete stack frame */
21854 .pushsection .kprobes.text, "ax"
21855 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
21856 js 1f /* negative -> in kernel */
21857 SWAPGS
21858 xorl %ebx,%ebx
21859 -1: ret
21860 +1: pax_force_retaddr_bts
21861 + ret
21862 CFI_ENDPROC
21863 -END(save_paranoid)
21864 +ENDPROC(save_paranoid)
21865 .popsection
21866
21867 /*
21868 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
21869
21870 RESTORE_REST
21871
21872 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21873 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
21874 jz 1f
21875
21876 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
21877 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
21878 RESTORE_REST
21879 jmp int_ret_from_sys_call
21880 CFI_ENDPROC
21881 -END(ret_from_fork)
21882 +ENDPROC(ret_from_fork)
21883
21884 /*
21885 * System call entry. Up to 6 arguments in registers are supported.
21886 @@ -608,7 +1043,7 @@ END(ret_from_fork)
21887 ENTRY(system_call)
21888 CFI_STARTPROC simple
21889 CFI_SIGNAL_FRAME
21890 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
21891 + CFI_DEF_CFA rsp,0
21892 CFI_REGISTER rip,rcx
21893 /*CFI_REGISTER rflags,r11*/
21894 SWAPGS_UNSAFE_STACK
21895 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
21896
21897 movq %rsp,PER_CPU_VAR(old_rsp)
21898 movq PER_CPU_VAR(kernel_stack),%rsp
21899 + SAVE_ARGS 8*6,0
21900 + pax_enter_kernel_user
21901 +
21902 +#ifdef CONFIG_PAX_RANDKSTACK
21903 + pax_erase_kstack
21904 +#endif
21905 +
21906 /*
21907 * No need to follow this irqs off/on section - it's straight
21908 * and short:
21909 */
21910 ENABLE_INTERRUPTS(CLBR_NONE)
21911 - SAVE_ARGS 8,0
21912 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
21913 movq %rcx,RIP-ARGOFFSET(%rsp)
21914 CFI_REL_OFFSET rip,RIP-ARGOFFSET
21915 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21916 + GET_THREAD_INFO(%rcx)
21917 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
21918 jnz tracesys
21919 system_call_fastpath:
21920 #if __SYSCALL_MASK == ~0
21921 @@ -640,7 +1082,7 @@ system_call_fastpath:
21922 cmpl $__NR_syscall_max,%eax
21923 #endif
21924 ja badsys
21925 - movq %r10,%rcx
21926 + movq R10-ARGOFFSET(%rsp),%rcx
21927 call *sys_call_table(,%rax,8) # XXX: rip relative
21928 movq %rax,RAX-ARGOFFSET(%rsp)
21929 /*
21930 @@ -654,10 +1096,13 @@ sysret_check:
21931 LOCKDEP_SYS_EXIT
21932 DISABLE_INTERRUPTS(CLBR_NONE)
21933 TRACE_IRQS_OFF
21934 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
21935 + GET_THREAD_INFO(%rcx)
21936 + movl TI_flags(%rcx),%edx
21937 andl %edi,%edx
21938 jnz sysret_careful
21939 CFI_REMEMBER_STATE
21940 + pax_exit_kernel_user
21941 + pax_erase_kstack
21942 /*
21943 * sysretq will re-enable interrupts:
21944 */
21945 @@ -709,14 +1154,18 @@ badsys:
21946 * jump back to the normal fast path.
21947 */
21948 auditsys:
21949 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
21950 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
21951 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
21952 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
21953 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
21954 movq %rax,%rsi /* 2nd arg: syscall number */
21955 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
21956 call __audit_syscall_entry
21957 +
21958 + pax_erase_kstack
21959 +
21960 LOAD_ARGS 0 /* reload call-clobbered registers */
21961 + pax_set_fptr_mask
21962 jmp system_call_fastpath
21963
21964 /*
21965 @@ -737,7 +1186,7 @@ sysret_audit:
21966 /* Do syscall tracing */
21967 tracesys:
21968 #ifdef CONFIG_AUDITSYSCALL
21969 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21970 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21971 jz auditsys
21972 #endif
21973 SAVE_REST
21974 @@ -745,12 +1194,16 @@ tracesys:
21975 FIXUP_TOP_OF_STACK %rdi
21976 movq %rsp,%rdi
21977 call syscall_trace_enter
21978 +
21979 + pax_erase_kstack
21980 +
21981 /*
21982 * Reload arg registers from stack in case ptrace changed them.
21983 * We don't reload %rax because syscall_trace_enter() returned
21984 * the value it wants us to use in the table lookup.
21985 */
21986 LOAD_ARGS ARGOFFSET, 1
21987 + pax_set_fptr_mask
21988 RESTORE_REST
21989 #if __SYSCALL_MASK == ~0
21990 cmpq $__NR_syscall_max,%rax
21991 @@ -759,7 +1212,7 @@ tracesys:
21992 cmpl $__NR_syscall_max,%eax
21993 #endif
21994 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21995 - movq %r10,%rcx /* fixup for C */
21996 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21997 call *sys_call_table(,%rax,8)
21998 movq %rax,RAX-ARGOFFSET(%rsp)
21999 /* Use IRET because user could have changed frame */
22000 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
22001 andl %edi,%edx
22002 jnz int_careful
22003 andl $~TS_COMPAT,TI_status(%rcx)
22004 - jmp retint_swapgs
22005 + pax_exit_kernel_user
22006 + pax_erase_kstack
22007 + jmp retint_swapgs_pax
22008
22009 /* Either reschedule or signal or syscall exit tracking needed. */
22010 /* First do a reschedule test. */
22011 @@ -826,7 +1281,7 @@ int_restore_rest:
22012 TRACE_IRQS_OFF
22013 jmp int_with_check
22014 CFI_ENDPROC
22015 -END(system_call)
22016 +ENDPROC(system_call)
22017
22018 .macro FORK_LIKE func
22019 ENTRY(stub_\func)
22020 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
22021 DEFAULT_FRAME 0 8 /* offset 8: return address */
22022 call sys_\func
22023 RESTORE_TOP_OF_STACK %r11, 8
22024 + pax_force_retaddr
22025 ret $REST_SKIP /* pop extended registers */
22026 CFI_ENDPROC
22027 -END(stub_\func)
22028 +ENDPROC(stub_\func)
22029 .endm
22030
22031 .macro FIXED_FRAME label,func
22032 @@ -851,9 +1307,10 @@ ENTRY(\label)
22033 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22034 call \func
22035 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22036 + pax_force_retaddr
22037 ret
22038 CFI_ENDPROC
22039 -END(\label)
22040 +ENDPROC(\label)
22041 .endm
22042
22043 FORK_LIKE clone
22044 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
22045 movq_cfi_restore R12+8, r12
22046 movq_cfi_restore RBP+8, rbp
22047 movq_cfi_restore RBX+8, rbx
22048 + pax_force_retaddr
22049 ret $REST_SKIP /* pop extended registers */
22050 CFI_ENDPROC
22051 -END(ptregscall_common)
22052 +ENDPROC(ptregscall_common)
22053
22054 ENTRY(stub_execve)
22055 CFI_STARTPROC
22056 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
22057 RESTORE_REST
22058 jmp int_ret_from_sys_call
22059 CFI_ENDPROC
22060 -END(stub_execve)
22061 +ENDPROC(stub_execve)
22062
22063 /*
22064 * sigreturn is special because it needs to restore all registers on return.
22065 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
22066 RESTORE_REST
22067 jmp int_ret_from_sys_call
22068 CFI_ENDPROC
22069 -END(stub_rt_sigreturn)
22070 +ENDPROC(stub_rt_sigreturn)
22071
22072 #ifdef CONFIG_X86_X32_ABI
22073 ENTRY(stub_x32_rt_sigreturn)
22074 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
22075 RESTORE_REST
22076 jmp int_ret_from_sys_call
22077 CFI_ENDPROC
22078 -END(stub_x32_rt_sigreturn)
22079 +ENDPROC(stub_x32_rt_sigreturn)
22080
22081 ENTRY(stub_x32_execve)
22082 CFI_STARTPROC
22083 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
22084 RESTORE_REST
22085 jmp int_ret_from_sys_call
22086 CFI_ENDPROC
22087 -END(stub_x32_execve)
22088 +ENDPROC(stub_x32_execve)
22089
22090 #endif
22091
22092 @@ -967,7 +1425,7 @@ vector=vector+1
22093 2: jmp common_interrupt
22094 .endr
22095 CFI_ENDPROC
22096 -END(irq_entries_start)
22097 +ENDPROC(irq_entries_start)
22098
22099 .previous
22100 END(interrupt)
22101 @@ -987,6 +1445,16 @@ END(interrupt)
22102 subq $ORIG_RAX-RBP, %rsp
22103 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22104 SAVE_ARGS_IRQ
22105 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22106 + testb $3, CS(%rdi)
22107 + jnz 1f
22108 + pax_enter_kernel
22109 + jmp 2f
22110 +1: pax_enter_kernel_user
22111 +2:
22112 +#else
22113 + pax_enter_kernel
22114 +#endif
22115 call \func
22116 .endm
22117
22118 @@ -1019,7 +1487,7 @@ ret_from_intr:
22119
22120 exit_intr:
22121 GET_THREAD_INFO(%rcx)
22122 - testl $3,CS-ARGOFFSET(%rsp)
22123 + testb $3,CS-ARGOFFSET(%rsp)
22124 je retint_kernel
22125
22126 /* Interrupt came from user space */
22127 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
22128 * The iretq could re-enable interrupts:
22129 */
22130 DISABLE_INTERRUPTS(CLBR_ANY)
22131 + pax_exit_kernel_user
22132 +retint_swapgs_pax:
22133 TRACE_IRQS_IRETQ
22134 SWAPGS
22135 jmp restore_args
22136
22137 retint_restore_args: /* return to kernel space */
22138 DISABLE_INTERRUPTS(CLBR_ANY)
22139 + pax_exit_kernel
22140 + pax_force_retaddr (RIP-ARGOFFSET)
22141 /*
22142 * The iretq could re-enable interrupts:
22143 */
22144 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
22145 #endif
22146
22147 CFI_ENDPROC
22148 -END(common_interrupt)
22149 +ENDPROC(common_interrupt)
22150 /*
22151 * End of kprobes section
22152 */
22153 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
22154 interrupt \do_sym
22155 jmp ret_from_intr
22156 CFI_ENDPROC
22157 -END(\sym)
22158 +ENDPROC(\sym)
22159 .endm
22160
22161 #ifdef CONFIG_TRACING
22162 @@ -1230,12 +1702,22 @@ ENTRY(\sym)
22163 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22164 call error_entry
22165 DEFAULT_FRAME 0
22166 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22167 + testb $3, CS(%rsp)
22168 + jnz 1f
22169 + pax_enter_kernel
22170 + jmp 2f
22171 +1: pax_enter_kernel_user
22172 +2:
22173 +#else
22174 + pax_enter_kernel
22175 +#endif
22176 movq %rsp,%rdi /* pt_regs pointer */
22177 xorl %esi,%esi /* no error code */
22178 call \do_sym
22179 jmp error_exit /* %ebx: no swapgs flag */
22180 CFI_ENDPROC
22181 -END(\sym)
22182 +ENDPROC(\sym)
22183 .endm
22184
22185 .macro paranoidzeroentry sym do_sym
22186 @@ -1248,15 +1730,25 @@ ENTRY(\sym)
22187 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22188 call save_paranoid
22189 TRACE_IRQS_OFF
22190 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22191 + testb $3, CS(%rsp)
22192 + jnz 1f
22193 + pax_enter_kernel
22194 + jmp 2f
22195 +1: pax_enter_kernel_user
22196 +2:
22197 +#else
22198 + pax_enter_kernel
22199 +#endif
22200 movq %rsp,%rdi /* pt_regs pointer */
22201 xorl %esi,%esi /* no error code */
22202 call \do_sym
22203 jmp paranoid_exit /* %ebx: no swapgs flag */
22204 CFI_ENDPROC
22205 -END(\sym)
22206 +ENDPROC(\sym)
22207 .endm
22208
22209 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22210 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
22211 .macro paranoidzeroentry_ist sym do_sym ist
22212 ENTRY(\sym)
22213 INTR_FRAME
22214 @@ -1267,14 +1759,30 @@ ENTRY(\sym)
22215 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22216 call save_paranoid
22217 TRACE_IRQS_OFF_DEBUG
22218 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22219 + testb $3, CS(%rsp)
22220 + jnz 1f
22221 + pax_enter_kernel
22222 + jmp 2f
22223 +1: pax_enter_kernel_user
22224 +2:
22225 +#else
22226 + pax_enter_kernel
22227 +#endif
22228 movq %rsp,%rdi /* pt_regs pointer */
22229 xorl %esi,%esi /* no error code */
22230 +#ifdef CONFIG_SMP
22231 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
22232 + lea init_tss(%r12), %r12
22233 +#else
22234 + lea init_tss(%rip), %r12
22235 +#endif
22236 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22237 call \do_sym
22238 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22239 jmp paranoid_exit /* %ebx: no swapgs flag */
22240 CFI_ENDPROC
22241 -END(\sym)
22242 +ENDPROC(\sym)
22243 .endm
22244
22245 .macro errorentry sym do_sym
22246 @@ -1286,13 +1794,23 @@ ENTRY(\sym)
22247 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22248 call error_entry
22249 DEFAULT_FRAME 0
22250 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22251 + testb $3, CS(%rsp)
22252 + jnz 1f
22253 + pax_enter_kernel
22254 + jmp 2f
22255 +1: pax_enter_kernel_user
22256 +2:
22257 +#else
22258 + pax_enter_kernel
22259 +#endif
22260 movq %rsp,%rdi /* pt_regs pointer */
22261 movq ORIG_RAX(%rsp),%rsi /* get error code */
22262 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22263 call \do_sym
22264 jmp error_exit /* %ebx: no swapgs flag */
22265 CFI_ENDPROC
22266 -END(\sym)
22267 +ENDPROC(\sym)
22268 .endm
22269
22270 /* error code is on the stack already */
22271 @@ -1306,13 +1824,23 @@ ENTRY(\sym)
22272 call save_paranoid
22273 DEFAULT_FRAME 0
22274 TRACE_IRQS_OFF
22275 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22276 + testb $3, CS(%rsp)
22277 + jnz 1f
22278 + pax_enter_kernel
22279 + jmp 2f
22280 +1: pax_enter_kernel_user
22281 +2:
22282 +#else
22283 + pax_enter_kernel
22284 +#endif
22285 movq %rsp,%rdi /* pt_regs pointer */
22286 movq ORIG_RAX(%rsp),%rsi /* get error code */
22287 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
22288 call \do_sym
22289 jmp paranoid_exit /* %ebx: no swapgs flag */
22290 CFI_ENDPROC
22291 -END(\sym)
22292 +ENDPROC(\sym)
22293 .endm
22294
22295 zeroentry divide_error do_divide_error
22296 @@ -1342,9 +1870,10 @@ gs_change:
22297 2: mfence /* workaround */
22298 SWAPGS
22299 popfq_cfi
22300 + pax_force_retaddr
22301 ret
22302 CFI_ENDPROC
22303 -END(native_load_gs_index)
22304 +ENDPROC(native_load_gs_index)
22305
22306 _ASM_EXTABLE(gs_change,bad_gs)
22307 .section .fixup,"ax"
22308 @@ -1372,9 +1901,10 @@ ENTRY(call_softirq)
22309 CFI_DEF_CFA_REGISTER rsp
22310 CFI_ADJUST_CFA_OFFSET -8
22311 decl PER_CPU_VAR(irq_count)
22312 + pax_force_retaddr
22313 ret
22314 CFI_ENDPROC
22315 -END(call_softirq)
22316 +ENDPROC(call_softirq)
22317
22318 #ifdef CONFIG_XEN
22319 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
22320 @@ -1412,7 +1942,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
22321 decl PER_CPU_VAR(irq_count)
22322 jmp error_exit
22323 CFI_ENDPROC
22324 -END(xen_do_hypervisor_callback)
22325 +ENDPROC(xen_do_hypervisor_callback)
22326
22327 /*
22328 * Hypervisor uses this for application faults while it executes.
22329 @@ -1471,7 +2001,7 @@ ENTRY(xen_failsafe_callback)
22330 SAVE_ALL
22331 jmp error_exit
22332 CFI_ENDPROC
22333 -END(xen_failsafe_callback)
22334 +ENDPROC(xen_failsafe_callback)
22335
22336 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
22337 xen_hvm_callback_vector xen_evtchn_do_upcall
22338 @@ -1523,18 +2053,33 @@ ENTRY(paranoid_exit)
22339 DEFAULT_FRAME
22340 DISABLE_INTERRUPTS(CLBR_NONE)
22341 TRACE_IRQS_OFF_DEBUG
22342 - testl %ebx,%ebx /* swapgs needed? */
22343 + testl $1,%ebx /* swapgs needed? */
22344 jnz paranoid_restore
22345 - testl $3,CS(%rsp)
22346 + testb $3,CS(%rsp)
22347 jnz paranoid_userspace
22348 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22349 + pax_exit_kernel
22350 + TRACE_IRQS_IRETQ 0
22351 + SWAPGS_UNSAFE_STACK
22352 + RESTORE_ALL 8
22353 + pax_force_retaddr_bts
22354 + jmp irq_return
22355 +#endif
22356 paranoid_swapgs:
22357 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22358 + pax_exit_kernel_user
22359 +#else
22360 + pax_exit_kernel
22361 +#endif
22362 TRACE_IRQS_IRETQ 0
22363 SWAPGS_UNSAFE_STACK
22364 RESTORE_ALL 8
22365 jmp irq_return
22366 paranoid_restore:
22367 + pax_exit_kernel
22368 TRACE_IRQS_IRETQ_DEBUG 0
22369 RESTORE_ALL 8
22370 + pax_force_retaddr_bts
22371 jmp irq_return
22372 paranoid_userspace:
22373 GET_THREAD_INFO(%rcx)
22374 @@ -1563,7 +2108,7 @@ paranoid_schedule:
22375 TRACE_IRQS_OFF
22376 jmp paranoid_userspace
22377 CFI_ENDPROC
22378 -END(paranoid_exit)
22379 +ENDPROC(paranoid_exit)
22380
22381 /*
22382 * Exception entry point. This expects an error code/orig_rax on the stack.
22383 @@ -1590,12 +2135,13 @@ ENTRY(error_entry)
22384 movq_cfi r14, R14+8
22385 movq_cfi r15, R15+8
22386 xorl %ebx,%ebx
22387 - testl $3,CS+8(%rsp)
22388 + testb $3,CS+8(%rsp)
22389 je error_kernelspace
22390 error_swapgs:
22391 SWAPGS
22392 error_sti:
22393 TRACE_IRQS_OFF
22394 + pax_force_retaddr_bts
22395 ret
22396
22397 /*
22398 @@ -1622,7 +2168,7 @@ bstep_iret:
22399 movq %rcx,RIP+8(%rsp)
22400 jmp error_swapgs
22401 CFI_ENDPROC
22402 -END(error_entry)
22403 +ENDPROC(error_entry)
22404
22405
22406 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
22407 @@ -1633,7 +2179,7 @@ ENTRY(error_exit)
22408 DISABLE_INTERRUPTS(CLBR_NONE)
22409 TRACE_IRQS_OFF
22410 GET_THREAD_INFO(%rcx)
22411 - testl %eax,%eax
22412 + testl $1,%eax
22413 jne retint_kernel
22414 LOCKDEP_SYS_EXIT_IRQ
22415 movl TI_flags(%rcx),%edx
22416 @@ -1642,7 +2188,7 @@ ENTRY(error_exit)
22417 jnz retint_careful
22418 jmp retint_swapgs
22419 CFI_ENDPROC
22420 -END(error_exit)
22421 +ENDPROC(error_exit)
22422
22423 /*
22424 * Test if a given stack is an NMI stack or not.
22425 @@ -1700,9 +2246,11 @@ ENTRY(nmi)
22426 * If %cs was not the kernel segment, then the NMI triggered in user
22427 * space, which means it is definitely not nested.
22428 */
22429 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
22430 + je 1f
22431 cmpl $__KERNEL_CS, 16(%rsp)
22432 jne first_nmi
22433 -
22434 +1:
22435 /*
22436 * Check the special variable on the stack to see if NMIs are
22437 * executing.
22438 @@ -1736,8 +2284,7 @@ nested_nmi:
22439
22440 1:
22441 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
22442 - leaq -1*8(%rsp), %rdx
22443 - movq %rdx, %rsp
22444 + subq $8, %rsp
22445 CFI_ADJUST_CFA_OFFSET 1*8
22446 leaq -10*8(%rsp), %rdx
22447 pushq_cfi $__KERNEL_DS
22448 @@ -1755,6 +2302,7 @@ nested_nmi_out:
22449 CFI_RESTORE rdx
22450
22451 /* No need to check faults here */
22452 +# pax_force_retaddr_bts
22453 INTERRUPT_RETURN
22454
22455 CFI_RESTORE_STATE
22456 @@ -1871,6 +2419,8 @@ end_repeat_nmi:
22457 */
22458 movq %cr2, %r12
22459
22460 + pax_enter_kernel_nmi
22461 +
22462 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
22463 movq %rsp,%rdi
22464 movq $-1,%rsi
22465 @@ -1883,26 +2433,31 @@ end_repeat_nmi:
22466 movq %r12, %cr2
22467 1:
22468
22469 - testl %ebx,%ebx /* swapgs needed? */
22470 + testl $1,%ebx /* swapgs needed? */
22471 jnz nmi_restore
22472 nmi_swapgs:
22473 SWAPGS_UNSAFE_STACK
22474 nmi_restore:
22475 + pax_exit_kernel_nmi
22476 /* Pop the extra iret frame at once */
22477 RESTORE_ALL 6*8
22478 + testb $3, 8(%rsp)
22479 + jnz 1f
22480 + pax_force_retaddr_bts
22481 +1:
22482
22483 /* Clear the NMI executing stack variable */
22484 movq $0, 5*8(%rsp)
22485 jmp irq_return
22486 CFI_ENDPROC
22487 -END(nmi)
22488 +ENDPROC(nmi)
22489
22490 ENTRY(ignore_sysret)
22491 CFI_STARTPROC
22492 mov $-ENOSYS,%eax
22493 sysret
22494 CFI_ENDPROC
22495 -END(ignore_sysret)
22496 +ENDPROC(ignore_sysret)
22497
22498 /*
22499 * End of kprobes section
22500 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
22501 index 42a392a..fbbd930 100644
22502 --- a/arch/x86/kernel/ftrace.c
22503 +++ b/arch/x86/kernel/ftrace.c
22504 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
22505 {
22506 unsigned char replaced[MCOUNT_INSN_SIZE];
22507
22508 + ip = ktla_ktva(ip);
22509 +
22510 /*
22511 * Note: Due to modules and __init, code can
22512 * disappear and change, we need to protect against faulting
22513 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22514 unsigned char old[MCOUNT_INSN_SIZE], *new;
22515 int ret;
22516
22517 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
22518 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
22519 new = ftrace_call_replace(ip, (unsigned long)func);
22520
22521 /* See comment above by declaration of modifying_ftrace_code */
22522 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
22523 /* Also update the regs callback function */
22524 if (!ret) {
22525 ip = (unsigned long)(&ftrace_regs_call);
22526 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
22527 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
22528 new = ftrace_call_replace(ip, (unsigned long)func);
22529 ret = ftrace_modify_code(ip, old, new);
22530 }
22531 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
22532 * kernel identity mapping to modify code.
22533 */
22534 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
22535 - ip = (unsigned long)__va(__pa_symbol(ip));
22536 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
22537
22538 return probe_kernel_write((void *)ip, val, size);
22539 }
22540 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
22541 unsigned char replaced[MCOUNT_INSN_SIZE];
22542 unsigned char brk = BREAKPOINT_INSTRUCTION;
22543
22544 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
22545 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
22546 return -EFAULT;
22547
22548 /* Make sure it is what we expect it to be */
22549 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
22550 return ret;
22551
22552 fail_update:
22553 - probe_kernel_write((void *)ip, &old_code[0], 1);
22554 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
22555 goto out;
22556 }
22557
22558 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
22559 {
22560 unsigned char code[MCOUNT_INSN_SIZE];
22561
22562 + ip = ktla_ktva(ip);
22563 +
22564 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
22565 return -EFAULT;
22566
22567 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
22568 index 55b6761..a6456fc 100644
22569 --- a/arch/x86/kernel/head64.c
22570 +++ b/arch/x86/kernel/head64.c
22571 @@ -67,12 +67,12 @@ again:
22572 pgd = *pgd_p;
22573
22574 /*
22575 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
22576 - * critical -- __PAGE_OFFSET would point us back into the dynamic
22577 + * The use of __early_va rather than __va here is critical:
22578 + * __va would point us back into the dynamic
22579 * range and we might end up looping forever...
22580 */
22581 if (pgd)
22582 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22583 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
22584 else {
22585 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22586 reset_early_page_tables();
22587 @@ -82,13 +82,13 @@ again:
22588 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
22589 for (i = 0; i < PTRS_PER_PUD; i++)
22590 pud_p[i] = 0;
22591 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22592 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
22593 }
22594 pud_p += pud_index(address);
22595 pud = *pud_p;
22596
22597 if (pud)
22598 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
22599 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
22600 else {
22601 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
22602 reset_early_page_tables();
22603 @@ -98,7 +98,7 @@ again:
22604 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
22605 for (i = 0; i < PTRS_PER_PMD; i++)
22606 pmd_p[i] = 0;
22607 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
22608 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
22609 }
22610 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
22611 pmd_p[pmd_index(address)] = pmd;
22612 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
22613 if (console_loglevel == 10)
22614 early_printk("Kernel alive\n");
22615
22616 - clear_page(init_level4_pgt);
22617 /* set init_level4_pgt kernel high mapping*/
22618 init_level4_pgt[511] = early_level4_pgt[511];
22619
22620 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
22621 index 5dd87a8..d68b3f4 100644
22622 --- a/arch/x86/kernel/head_32.S
22623 +++ b/arch/x86/kernel/head_32.S
22624 @@ -26,6 +26,12 @@
22625 /* Physical address */
22626 #define pa(X) ((X) - __PAGE_OFFSET)
22627
22628 +#ifdef CONFIG_PAX_KERNEXEC
22629 +#define ta(X) (X)
22630 +#else
22631 +#define ta(X) ((X) - __PAGE_OFFSET)
22632 +#endif
22633 +
22634 /*
22635 * References to members of the new_cpu_data structure.
22636 */
22637 @@ -55,11 +61,7 @@
22638 * and small than max_low_pfn, otherwise will waste some page table entries
22639 */
22640
22641 -#if PTRS_PER_PMD > 1
22642 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
22643 -#else
22644 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
22645 -#endif
22646 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
22647
22648 /* Number of possible pages in the lowmem region */
22649 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
22650 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
22651 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22652
22653 /*
22654 + * Real beginning of normal "text" segment
22655 + */
22656 +ENTRY(stext)
22657 +ENTRY(_stext)
22658 +
22659 +/*
22660 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
22661 * %esi points to the real-mode code as a 32-bit pointer.
22662 * CS and DS must be 4 GB flat segments, but we don't depend on
22663 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
22664 * can.
22665 */
22666 __HEAD
22667 +
22668 +#ifdef CONFIG_PAX_KERNEXEC
22669 + jmp startup_32
22670 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
22671 +.fill PAGE_SIZE-5,1,0xcc
22672 +#endif
22673 +
22674 ENTRY(startup_32)
22675 movl pa(stack_start),%ecx
22676
22677 @@ -106,6 +121,59 @@ ENTRY(startup_32)
22678 2:
22679 leal -__PAGE_OFFSET(%ecx),%esp
22680
22681 +#ifdef CONFIG_SMP
22682 + movl $pa(cpu_gdt_table),%edi
22683 + movl $__per_cpu_load,%eax
22684 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
22685 + rorl $16,%eax
22686 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
22687 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
22688 + movl $__per_cpu_end - 1,%eax
22689 + subl $__per_cpu_start,%eax
22690 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
22691 +#endif
22692 +
22693 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22694 + movl $NR_CPUS,%ecx
22695 + movl $pa(cpu_gdt_table),%edi
22696 +1:
22697 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
22698 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
22699 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
22700 + addl $PAGE_SIZE_asm,%edi
22701 + loop 1b
22702 +#endif
22703 +
22704 +#ifdef CONFIG_PAX_KERNEXEC
22705 + movl $pa(boot_gdt),%edi
22706 + movl $__LOAD_PHYSICAL_ADDR,%eax
22707 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
22708 + rorl $16,%eax
22709 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
22710 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
22711 + rorl $16,%eax
22712 +
22713 + ljmp $(__BOOT_CS),$1f
22714 +1:
22715 +
22716 + movl $NR_CPUS,%ecx
22717 + movl $pa(cpu_gdt_table),%edi
22718 + addl $__PAGE_OFFSET,%eax
22719 +1:
22720 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
22721 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
22722 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
22723 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
22724 + rorl $16,%eax
22725 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
22726 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
22727 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
22728 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
22729 + rorl $16,%eax
22730 + addl $PAGE_SIZE_asm,%edi
22731 + loop 1b
22732 +#endif
22733 +
22734 /*
22735 * Clear BSS first so that there are no surprises...
22736 */
22737 @@ -201,8 +269,11 @@ ENTRY(startup_32)
22738 movl %eax, pa(max_pfn_mapped)
22739
22740 /* Do early initialization of the fixmap area */
22741 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22742 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
22743 +#ifdef CONFIG_COMPAT_VDSO
22744 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
22745 +#else
22746 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
22747 +#endif
22748 #else /* Not PAE */
22749
22750 page_pde_offset = (__PAGE_OFFSET >> 20);
22751 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22752 movl %eax, pa(max_pfn_mapped)
22753
22754 /* Do early initialization of the fixmap area */
22755 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
22756 - movl %eax,pa(initial_page_table+0xffc)
22757 +#ifdef CONFIG_COMPAT_VDSO
22758 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
22759 +#else
22760 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
22761 +#endif
22762 #endif
22763
22764 #ifdef CONFIG_PARAVIRT
22765 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
22766 cmpl $num_subarch_entries, %eax
22767 jae bad_subarch
22768
22769 - movl pa(subarch_entries)(,%eax,4), %eax
22770 - subl $__PAGE_OFFSET, %eax
22771 - jmp *%eax
22772 + jmp *pa(subarch_entries)(,%eax,4)
22773
22774 bad_subarch:
22775 WEAK(lguest_entry)
22776 @@ -261,10 +333,10 @@ WEAK(xen_entry)
22777 __INITDATA
22778
22779 subarch_entries:
22780 - .long default_entry /* normal x86/PC */
22781 - .long lguest_entry /* lguest hypervisor */
22782 - .long xen_entry /* Xen hypervisor */
22783 - .long default_entry /* Moorestown MID */
22784 + .long ta(default_entry) /* normal x86/PC */
22785 + .long ta(lguest_entry) /* lguest hypervisor */
22786 + .long ta(xen_entry) /* Xen hypervisor */
22787 + .long ta(default_entry) /* Moorestown MID */
22788 num_subarch_entries = (. - subarch_entries) / 4
22789 .previous
22790 #else
22791 @@ -354,6 +426,7 @@ default_entry:
22792 movl pa(mmu_cr4_features),%eax
22793 movl %eax,%cr4
22794
22795 +#ifdef CONFIG_X86_PAE
22796 testb $X86_CR4_PAE, %al # check if PAE is enabled
22797 jz enable_paging
22798
22799 @@ -382,6 +455,9 @@ default_entry:
22800 /* Make changes effective */
22801 wrmsr
22802
22803 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
22804 +#endif
22805 +
22806 enable_paging:
22807
22808 /*
22809 @@ -449,14 +525,20 @@ is486:
22810 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
22811 movl %eax,%ss # after changing gdt.
22812
22813 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
22814 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
22815 movl %eax,%ds
22816 movl %eax,%es
22817
22818 movl $(__KERNEL_PERCPU), %eax
22819 movl %eax,%fs # set this cpu's percpu
22820
22821 +#ifdef CONFIG_CC_STACKPROTECTOR
22822 movl $(__KERNEL_STACK_CANARY),%eax
22823 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
22824 + movl $(__USER_DS),%eax
22825 +#else
22826 + xorl %eax,%eax
22827 +#endif
22828 movl %eax,%gs
22829
22830 xorl %eax,%eax # Clear LDT
22831 @@ -512,8 +594,11 @@ setup_once:
22832 * relocation. Manually set base address in stack canary
22833 * segment descriptor.
22834 */
22835 - movl $gdt_page,%eax
22836 + movl $cpu_gdt_table,%eax
22837 movl $stack_canary,%ecx
22838 +#ifdef CONFIG_SMP
22839 + addl $__per_cpu_load,%ecx
22840 +#endif
22841 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
22842 shrl $16, %ecx
22843 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
22844 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
22845 /* This is global to keep gas from relaxing the jumps */
22846 ENTRY(early_idt_handler)
22847 cld
22848 - cmpl $2,%ss:early_recursion_flag
22849 + cmpl $1,%ss:early_recursion_flag
22850 je hlt_loop
22851 incl %ss:early_recursion_flag
22852
22853 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
22854 pushl (20+6*4)(%esp) /* trapno */
22855 pushl $fault_msg
22856 call printk
22857 -#endif
22858 call dump_stack
22859 +#endif
22860 hlt_loop:
22861 hlt
22862 jmp hlt_loop
22863 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
22864 /* This is the default interrupt "handler" :-) */
22865 ALIGN
22866 ignore_int:
22867 - cld
22868 #ifdef CONFIG_PRINTK
22869 + cmpl $2,%ss:early_recursion_flag
22870 + je hlt_loop
22871 + incl %ss:early_recursion_flag
22872 + cld
22873 pushl %eax
22874 pushl %ecx
22875 pushl %edx
22876 @@ -612,9 +700,6 @@ ignore_int:
22877 movl $(__KERNEL_DS),%eax
22878 movl %eax,%ds
22879 movl %eax,%es
22880 - cmpl $2,early_recursion_flag
22881 - je hlt_loop
22882 - incl early_recursion_flag
22883 pushl 16(%esp)
22884 pushl 24(%esp)
22885 pushl 32(%esp)
22886 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
22887 /*
22888 * BSS section
22889 */
22890 -__PAGE_ALIGNED_BSS
22891 - .align PAGE_SIZE
22892 #ifdef CONFIG_X86_PAE
22893 +.section .initial_pg_pmd,"a",@progbits
22894 initial_pg_pmd:
22895 .fill 1024*KPMDS,4,0
22896 #else
22897 +.section .initial_page_table,"a",@progbits
22898 ENTRY(initial_page_table)
22899 .fill 1024,4,0
22900 #endif
22901 +.section .initial_pg_fixmap,"a",@progbits
22902 initial_pg_fixmap:
22903 .fill 1024,4,0
22904 +.section .empty_zero_page,"a",@progbits
22905 ENTRY(empty_zero_page)
22906 .fill 4096,1,0
22907 +.section .swapper_pg_dir,"a",@progbits
22908 ENTRY(swapper_pg_dir)
22909 +#ifdef CONFIG_X86_PAE
22910 + .fill 4,8,0
22911 +#else
22912 .fill 1024,4,0
22913 +#endif
22914
22915 /*
22916 * This starts the data section.
22917 */
22918 #ifdef CONFIG_X86_PAE
22919 -__PAGE_ALIGNED_DATA
22920 - /* Page-aligned for the benefit of paravirt? */
22921 - .align PAGE_SIZE
22922 +.section .initial_page_table,"a",@progbits
22923 ENTRY(initial_page_table)
22924 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
22925 # if KPMDS == 3
22926 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
22927 # error "Kernel PMDs should be 1, 2 or 3"
22928 # endif
22929 .align PAGE_SIZE /* needs to be page-sized too */
22930 +
22931 +#ifdef CONFIG_PAX_PER_CPU_PGD
22932 +ENTRY(cpu_pgd)
22933 + .rept 2*NR_CPUS
22934 + .fill 4,8,0
22935 + .endr
22936 +#endif
22937 +
22938 #endif
22939
22940 .data
22941 .balign 4
22942 ENTRY(stack_start)
22943 - .long init_thread_union+THREAD_SIZE
22944 + .long init_thread_union+THREAD_SIZE-8
22945
22946 __INITRODATA
22947 int_msg:
22948 @@ -722,7 +820,7 @@ fault_msg:
22949 * segment size, and 32-bit linear address value:
22950 */
22951
22952 - .data
22953 +.section .rodata,"a",@progbits
22954 .globl boot_gdt_descr
22955 .globl idt_descr
22956
22957 @@ -731,7 +829,7 @@ fault_msg:
22958 .word 0 # 32 bit align gdt_desc.address
22959 boot_gdt_descr:
22960 .word __BOOT_DS+7
22961 - .long boot_gdt - __PAGE_OFFSET
22962 + .long pa(boot_gdt)
22963
22964 .word 0 # 32-bit align idt_desc.address
22965 idt_descr:
22966 @@ -742,7 +840,7 @@ idt_descr:
22967 .word 0 # 32 bit align gdt_desc.address
22968 ENTRY(early_gdt_descr)
22969 .word GDT_ENTRIES*8-1
22970 - .long gdt_page /* Overwritten for secondary CPUs */
22971 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22972
22973 /*
22974 * The boot_gdt must mirror the equivalent in setup.S and is
22975 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
22976 .align L1_CACHE_BYTES
22977 ENTRY(boot_gdt)
22978 .fill GDT_ENTRY_BOOT_CS,8,0
22979 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22980 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22981 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22982 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22983 +
22984 + .align PAGE_SIZE_asm
22985 +ENTRY(cpu_gdt_table)
22986 + .rept NR_CPUS
22987 + .quad 0x0000000000000000 /* NULL descriptor */
22988 + .quad 0x0000000000000000 /* 0x0b reserved */
22989 + .quad 0x0000000000000000 /* 0x13 reserved */
22990 + .quad 0x0000000000000000 /* 0x1b reserved */
22991 +
22992 +#ifdef CONFIG_PAX_KERNEXEC
22993 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22994 +#else
22995 + .quad 0x0000000000000000 /* 0x20 unused */
22996 +#endif
22997 +
22998 + .quad 0x0000000000000000 /* 0x28 unused */
22999 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
23000 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
23001 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
23002 + .quad 0x0000000000000000 /* 0x4b reserved */
23003 + .quad 0x0000000000000000 /* 0x53 reserved */
23004 + .quad 0x0000000000000000 /* 0x5b reserved */
23005 +
23006 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23007 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23008 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23009 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23010 +
23011 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23012 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23013 +
23014 + /*
23015 + * Segments used for calling PnP BIOS have byte granularity.
23016 + * The code segments and data segments have fixed 64k limits,
23017 + * the transfer segment sizes are set at run time.
23018 + */
23019 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23020 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23021 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23022 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23023 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23024 +
23025 + /*
23026 + * The APM segments have byte granularity and their bases
23027 + * are set at run time. All have 64k limits.
23028 + */
23029 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23030 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23031 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23032 +
23033 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23034 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23035 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23036 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23037 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23038 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23039 +
23040 + /* Be sure this is zeroed to avoid false validations in Xen */
23041 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23042 + .endr
23043 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23044 index e1aabdb..73dcad8 100644
23045 --- a/arch/x86/kernel/head_64.S
23046 +++ b/arch/x86/kernel/head_64.S
23047 @@ -20,6 +20,8 @@
23048 #include <asm/processor-flags.h>
23049 #include <asm/percpu.h>
23050 #include <asm/nops.h>
23051 +#include <asm/cpufeature.h>
23052 +#include <asm/alternative-asm.h>
23053
23054 #ifdef CONFIG_PARAVIRT
23055 #include <asm/asm-offsets.h>
23056 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23057 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23058 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23059 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23060 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23061 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23062 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23063 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23064 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23065 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23066
23067 .text
23068 __HEAD
23069 @@ -89,11 +97,23 @@ startup_64:
23070 * Fixup the physical addresses in the page table
23071 */
23072 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23073 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23074 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23075 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23076 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23077 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23078
23079 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23080 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23081 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23082 +#ifndef CONFIG_XEN
23083 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23084 +#endif
23085
23086 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23087 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23088 +
23089 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23090 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23091 +
23092 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23093
23094 /*
23095 * Set up the identity mapping for the switchover. These
23096 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
23097 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23098 1:
23099
23100 - /* Enable PAE mode and PGE */
23101 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23102 + /* Enable PAE mode and PSE/PGE */
23103 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23104 movq %rcx, %cr4
23105
23106 /* Setup early boot stage 4 level pagetables. */
23107 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
23108 movl $MSR_EFER, %ecx
23109 rdmsr
23110 btsl $_EFER_SCE, %eax /* Enable System Call */
23111 - btl $20,%edi /* No Execute supported? */
23112 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23113 jnc 1f
23114 btsl $_EFER_NX, %eax
23115 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23116 + leaq init_level4_pgt(%rip), %rdi
23117 +#ifndef CONFIG_EFI
23118 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
23119 +#endif
23120 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
23121 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
23122 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
23123 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23124 1: wrmsr /* Make changes effective */
23125
23126 /* Setup cr0 */
23127 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
23128 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23129 * address given in m16:64.
23130 */
23131 + pax_set_fptr_mask
23132 movq initial_code(%rip),%rax
23133 pushq $0 # fake return address to stop unwinder
23134 pushq $__KERNEL_CS # set correct cs
23135 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
23136 call dump_stack
23137 #ifdef CONFIG_KALLSYMS
23138 leaq early_idt_ripmsg(%rip),%rdi
23139 - movq 40(%rsp),%rsi # %rip again
23140 + movq 88(%rsp),%rsi # %rip again
23141 call __print_symbol
23142 #endif
23143 #endif /* EARLY_PRINTK */
23144 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
23145 early_recursion_flag:
23146 .long 0
23147
23148 + .section .rodata,"a",@progbits
23149 #ifdef CONFIG_EARLY_PRINTK
23150 early_idt_msg:
23151 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23152 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
23153 NEXT_PAGE(early_dynamic_pgts)
23154 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23155
23156 - .data
23157 + .section .rodata,"a",@progbits
23158
23159 -#ifndef CONFIG_XEN
23160 NEXT_PAGE(init_level4_pgt)
23161 - .fill 512,8,0
23162 -#else
23163 -NEXT_PAGE(init_level4_pgt)
23164 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23165 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23166 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23167 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23168 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23169 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23170 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23171 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23172 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23173 .org init_level4_pgt + L4_START_KERNEL*8, 0
23174 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23175 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23176
23177 +#ifdef CONFIG_PAX_PER_CPU_PGD
23178 +NEXT_PAGE(cpu_pgd)
23179 + .rept 2*NR_CPUS
23180 + .fill 512,8,0
23181 + .endr
23182 +#endif
23183 +
23184 NEXT_PAGE(level3_ident_pgt)
23185 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23186 +#ifdef CONFIG_XEN
23187 .fill 511, 8, 0
23188 +#else
23189 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23190 + .fill 510,8,0
23191 +#endif
23192 +
23193 +NEXT_PAGE(level3_vmalloc_start_pgt)
23194 + .fill 512,8,0
23195 +
23196 +NEXT_PAGE(level3_vmalloc_end_pgt)
23197 + .fill 512,8,0
23198 +
23199 +NEXT_PAGE(level3_vmemmap_pgt)
23200 + .fill L3_VMEMMAP_START,8,0
23201 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23202 +
23203 NEXT_PAGE(level2_ident_pgt)
23204 - /* Since I easily can, map the first 1G.
23205 + /* Since I easily can, map the first 2G.
23206 * Don't set NX because code runs from these pages.
23207 */
23208 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23209 -#endif
23210 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23211
23212 NEXT_PAGE(level3_kernel_pgt)
23213 .fill L3_START_KERNEL,8,0
23214 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
23215 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23216 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23217
23218 +NEXT_PAGE(level2_vmemmap_pgt)
23219 + .fill 512,8,0
23220 +
23221 NEXT_PAGE(level2_kernel_pgt)
23222 /*
23223 * 512 MB kernel mapping. We spend a full page on this pagetable
23224 @@ -488,30 +544,62 @@ NEXT_PAGE(level2_kernel_pgt)
23225 KERNEL_IMAGE_SIZE/PMD_SIZE)
23226
23227 NEXT_PAGE(level2_fixmap_pgt)
23228 - .fill 506,8,0
23229 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23230 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23231 - .fill 5,8,0
23232 + .fill 507,8,0
23233 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
23234 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
23235 + .fill 4,8,0
23236
23237 -NEXT_PAGE(level1_fixmap_pgt)
23238 +NEXT_PAGE(level1_vsyscall_pgt)
23239 .fill 512,8,0
23240
23241 #undef PMDS
23242
23243 - .data
23244 + .align PAGE_SIZE
23245 +ENTRY(cpu_gdt_table)
23246 + .rept NR_CPUS
23247 + .quad 0x0000000000000000 /* NULL descriptor */
23248 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
23249 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
23250 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
23251 + .quad 0x00cffb000000ffff /* __USER32_CS */
23252 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
23253 + .quad 0x00affb000000ffff /* __USER_CS */
23254 +
23255 +#ifdef CONFIG_PAX_KERNEXEC
23256 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
23257 +#else
23258 + .quad 0x0 /* unused */
23259 +#endif
23260 +
23261 + .quad 0,0 /* TSS */
23262 + .quad 0,0 /* LDT */
23263 + .quad 0,0,0 /* three TLS descriptors */
23264 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
23265 + /* asm/segment.h:GDT_ENTRIES must match this */
23266 +
23267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23268 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
23269 +#else
23270 + .quad 0x0 /* unused */
23271 +#endif
23272 +
23273 + /* zero the remaining page */
23274 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
23275 + .endr
23276 +
23277 .align 16
23278 .globl early_gdt_descr
23279 early_gdt_descr:
23280 .word GDT_ENTRIES*8-1
23281 early_gdt_descr_base:
23282 - .quad INIT_PER_CPU_VAR(gdt_page)
23283 + .quad cpu_gdt_table
23284
23285 ENTRY(phys_base)
23286 /* This must match the first entry in level2_kernel_pgt */
23287 .quad 0x0000000000000000
23288
23289 #include "../../x86/xen/xen-head.S"
23290 -
23291 - __PAGE_ALIGNED_BSS
23292 +
23293 + .section .rodata,"a",@progbits
23294 NEXT_PAGE(empty_zero_page)
23295 .skip PAGE_SIZE
23296 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
23297 index 0fa6912..b37438b 100644
23298 --- a/arch/x86/kernel/i386_ksyms_32.c
23299 +++ b/arch/x86/kernel/i386_ksyms_32.c
23300 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
23301 EXPORT_SYMBOL(cmpxchg8b_emu);
23302 #endif
23303
23304 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
23305 +
23306 /* Networking helper routines. */
23307 EXPORT_SYMBOL(csum_partial_copy_generic);
23308 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
23309 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
23310
23311 EXPORT_SYMBOL(__get_user_1);
23312 EXPORT_SYMBOL(__get_user_2);
23313 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
23314
23315 EXPORT_SYMBOL(csum_partial);
23316 EXPORT_SYMBOL(empty_zero_page);
23317 +
23318 +#ifdef CONFIG_PAX_KERNEXEC
23319 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
23320 +#endif
23321 +
23322 +#ifdef CONFIG_PAX_PER_CPU_PGD
23323 +EXPORT_SYMBOL(cpu_pgd);
23324 +#endif
23325 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
23326 index 5d576ab..1403a03 100644
23327 --- a/arch/x86/kernel/i387.c
23328 +++ b/arch/x86/kernel/i387.c
23329 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
23330 static inline bool interrupted_user_mode(void)
23331 {
23332 struct pt_regs *regs = get_irq_regs();
23333 - return regs && user_mode_vm(regs);
23334 + return regs && user_mode(regs);
23335 }
23336
23337 /*
23338 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
23339 index 9a5c460..84868423 100644
23340 --- a/arch/x86/kernel/i8259.c
23341 +++ b/arch/x86/kernel/i8259.c
23342 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
23343 static void make_8259A_irq(unsigned int irq)
23344 {
23345 disable_irq_nosync(irq);
23346 - io_apic_irqs &= ~(1<<irq);
23347 + io_apic_irqs &= ~(1UL<<irq);
23348 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
23349 i8259A_chip.name);
23350 enable_irq(irq);
23351 @@ -209,7 +209,7 @@ spurious_8259A_irq:
23352 "spurious 8259A interrupt: IRQ%d.\n", irq);
23353 spurious_irq_mask |= irqmask;
23354 }
23355 - atomic_inc(&irq_err_count);
23356 + atomic_inc_unchecked(&irq_err_count);
23357 /*
23358 * Theoretically we do not have to handle this IRQ,
23359 * but in Linux this does not cause problems and is
23360 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
23361 /* (slave's support for AEOI in flat mode is to be investigated) */
23362 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
23363
23364 + pax_open_kernel();
23365 if (auto_eoi)
23366 /*
23367 * In AEOI mode we just have to mask the interrupt
23368 * when acking.
23369 */
23370 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
23371 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
23372 else
23373 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23374 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
23375 + pax_close_kernel();
23376
23377 udelay(100); /* wait for 8259A to initialize */
23378
23379 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
23380 index a979b5b..1d6db75 100644
23381 --- a/arch/x86/kernel/io_delay.c
23382 +++ b/arch/x86/kernel/io_delay.c
23383 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
23384 * Quirk table for systems that misbehave (lock up, etc.) if port
23385 * 0x80 is used:
23386 */
23387 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
23388 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
23389 {
23390 .callback = dmi_io_delay_0xed_port,
23391 .ident = "Compaq Presario V6000",
23392 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
23393 index 4ddaf66..6292f4e 100644
23394 --- a/arch/x86/kernel/ioport.c
23395 +++ b/arch/x86/kernel/ioport.c
23396 @@ -6,6 +6,7 @@
23397 #include <linux/sched.h>
23398 #include <linux/kernel.h>
23399 #include <linux/capability.h>
23400 +#include <linux/security.h>
23401 #include <linux/errno.h>
23402 #include <linux/types.h>
23403 #include <linux/ioport.h>
23404 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23405
23406 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
23407 return -EINVAL;
23408 +#ifdef CONFIG_GRKERNSEC_IO
23409 + if (turn_on && grsec_disable_privio) {
23410 + gr_handle_ioperm();
23411 + return -EPERM;
23412 + }
23413 +#endif
23414 if (turn_on && !capable(CAP_SYS_RAWIO))
23415 return -EPERM;
23416
23417 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
23418 * because the ->io_bitmap_max value must match the bitmap
23419 * contents:
23420 */
23421 - tss = &per_cpu(init_tss, get_cpu());
23422 + tss = init_tss + get_cpu();
23423
23424 if (turn_on)
23425 bitmap_clear(t->io_bitmap_ptr, from, num);
23426 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
23427 return -EINVAL;
23428 /* Trying to gain more privileges? */
23429 if (level > old) {
23430 +#ifdef CONFIG_GRKERNSEC_IO
23431 + if (grsec_disable_privio) {
23432 + gr_handle_iopl();
23433 + return -EPERM;
23434 + }
23435 +#endif
23436 if (!capable(CAP_SYS_RAWIO))
23437 return -EPERM;
23438 }
23439 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
23440 index 3a8185c..3c042ee 100644
23441 --- a/arch/x86/kernel/irq.c
23442 +++ b/arch/x86/kernel/irq.c
23443 @@ -21,7 +21,7 @@
23444 #define CREATE_TRACE_POINTS
23445 #include <asm/trace/irq_vectors.h>
23446
23447 -atomic_t irq_err_count;
23448 +atomic_unchecked_t irq_err_count;
23449
23450 /* Function pointer for generic interrupt vector handling */
23451 void (*x86_platform_ipi_callback)(void) = NULL;
23452 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
23453 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
23454 seq_printf(p, " Machine check polls\n");
23455 #endif
23456 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
23457 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
23458 #if defined(CONFIG_X86_IO_APIC)
23459 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
23460 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
23461 #endif
23462 return 0;
23463 }
23464 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
23465
23466 u64 arch_irq_stat(void)
23467 {
23468 - u64 sum = atomic_read(&irq_err_count);
23469 + u64 sum = atomic_read_unchecked(&irq_err_count);
23470 return sum;
23471 }
23472
23473 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
23474 index 4186755..784efa0 100644
23475 --- a/arch/x86/kernel/irq_32.c
23476 +++ b/arch/x86/kernel/irq_32.c
23477 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
23478 __asm__ __volatile__("andl %%esp,%0" :
23479 "=r" (sp) : "0" (THREAD_SIZE - 1));
23480
23481 - return sp < (sizeof(struct thread_info) + STACK_WARN);
23482 + return sp < STACK_WARN;
23483 }
23484
23485 static void print_stack_overflow(void)
23486 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
23487 * per-CPU IRQ handling contexts (thread information and stack)
23488 */
23489 union irq_ctx {
23490 - struct thread_info tinfo;
23491 - u32 stack[THREAD_SIZE/sizeof(u32)];
23492 + unsigned long previous_esp;
23493 + u32 stack[THREAD_SIZE/sizeof(u32)];
23494 } __attribute__((aligned(THREAD_SIZE)));
23495
23496 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
23497 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
23498 static inline int
23499 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23500 {
23501 - union irq_ctx *curctx, *irqctx;
23502 + union irq_ctx *irqctx;
23503 u32 *isp, arg1, arg2;
23504
23505 - curctx = (union irq_ctx *) current_thread_info();
23506 irqctx = __this_cpu_read(hardirq_ctx);
23507
23508 /*
23509 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23510 * handler) we can't do that and just have to keep using the
23511 * current stack (which is the irq stack already after all)
23512 */
23513 - if (unlikely(curctx == irqctx))
23514 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
23515 return 0;
23516
23517 /* build the stack frame on the IRQ stack */
23518 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23519 - irqctx->tinfo.task = curctx->tinfo.task;
23520 - irqctx->tinfo.previous_esp = current_stack_pointer;
23521 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23522 + irqctx->previous_esp = current_stack_pointer;
23523
23524 - /* Copy the preempt_count so that the [soft]irq checks work. */
23525 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
23526 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23527 + __set_fs(MAKE_MM_SEG(0));
23528 +#endif
23529
23530 if (unlikely(overflow))
23531 call_on_stack(print_stack_overflow, isp);
23532 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23533 : "0" (irq), "1" (desc), "2" (isp),
23534 "D" (desc->handle_irq)
23535 : "memory", "cc", "ecx");
23536 +
23537 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23538 + __set_fs(current_thread_info()->addr_limit);
23539 +#endif
23540 +
23541 return 1;
23542 }
23543
23544 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
23545 */
23546 void irq_ctx_init(int cpu)
23547 {
23548 - union irq_ctx *irqctx;
23549 -
23550 if (per_cpu(hardirq_ctx, cpu))
23551 return;
23552
23553 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23554 - THREADINFO_GFP,
23555 - THREAD_SIZE_ORDER));
23556 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23557 - irqctx->tinfo.cpu = cpu;
23558 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
23559 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23560 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23561 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
23562
23563 - per_cpu(hardirq_ctx, cpu) = irqctx;
23564 -
23565 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
23566 - THREADINFO_GFP,
23567 - THREAD_SIZE_ORDER));
23568 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
23569 - irqctx->tinfo.cpu = cpu;
23570 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
23571 -
23572 - per_cpu(softirq_ctx, cpu) = irqctx;
23573 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23574 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23575
23576 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
23577 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
23578 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
23579 asmlinkage void do_softirq(void)
23580 {
23581 unsigned long flags;
23582 - struct thread_info *curctx;
23583 union irq_ctx *irqctx;
23584 u32 *isp;
23585
23586 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
23587 local_irq_save(flags);
23588
23589 if (local_softirq_pending()) {
23590 - curctx = current_thread_info();
23591 irqctx = __this_cpu_read(softirq_ctx);
23592 - irqctx->tinfo.task = curctx->task;
23593 - irqctx->tinfo.previous_esp = current_stack_pointer;
23594 + irqctx->previous_esp = current_stack_pointer;
23595
23596 /* build the stack frame on the softirq stack */
23597 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
23598 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
23599 +
23600 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23601 + __set_fs(MAKE_MM_SEG(0));
23602 +#endif
23603
23604 call_on_stack(__do_softirq, isp);
23605 +
23606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23607 + __set_fs(current_thread_info()->addr_limit);
23608 +#endif
23609 +
23610 /*
23611 * Shouldn't happen, we returned above if in_interrupt():
23612 */
23613 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
23614 if (unlikely(!desc))
23615 return false;
23616
23617 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23618 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
23619 if (unlikely(overflow))
23620 print_stack_overflow();
23621 desc->handle_irq(irq, desc);
23622 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
23623 index d04d3ec..ea4b374 100644
23624 --- a/arch/x86/kernel/irq_64.c
23625 +++ b/arch/x86/kernel/irq_64.c
23626 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
23627 u64 estack_top, estack_bottom;
23628 u64 curbase = (u64)task_stack_page(current);
23629
23630 - if (user_mode_vm(regs))
23631 + if (user_mode(regs))
23632 return;
23633
23634 if (regs->sp >= curbase + sizeof(struct thread_info) +
23635 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
23636 index dc1404b..bbc43e7 100644
23637 --- a/arch/x86/kernel/kdebugfs.c
23638 +++ b/arch/x86/kernel/kdebugfs.c
23639 @@ -27,7 +27,7 @@ struct setup_data_node {
23640 u32 len;
23641 };
23642
23643 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
23644 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
23645 size_t count, loff_t *ppos)
23646 {
23647 struct setup_data_node *node = file->private_data;
23648 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
23649 index 836f832..a8bda67 100644
23650 --- a/arch/x86/kernel/kgdb.c
23651 +++ b/arch/x86/kernel/kgdb.c
23652 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
23653 #ifdef CONFIG_X86_32
23654 switch (regno) {
23655 case GDB_SS:
23656 - if (!user_mode_vm(regs))
23657 + if (!user_mode(regs))
23658 *(unsigned long *)mem = __KERNEL_DS;
23659 break;
23660 case GDB_SP:
23661 - if (!user_mode_vm(regs))
23662 + if (!user_mode(regs))
23663 *(unsigned long *)mem = kernel_stack_pointer(regs);
23664 break;
23665 case GDB_GS:
23666 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
23667 bp->attr.bp_addr = breakinfo[breakno].addr;
23668 bp->attr.bp_len = breakinfo[breakno].len;
23669 bp->attr.bp_type = breakinfo[breakno].type;
23670 - info->address = breakinfo[breakno].addr;
23671 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
23672 + info->address = ktla_ktva(breakinfo[breakno].addr);
23673 + else
23674 + info->address = breakinfo[breakno].addr;
23675 info->len = breakinfo[breakno].len;
23676 info->type = breakinfo[breakno].type;
23677 val = arch_install_hw_breakpoint(bp);
23678 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
23679 case 'k':
23680 /* clear the trace bit */
23681 linux_regs->flags &= ~X86_EFLAGS_TF;
23682 - atomic_set(&kgdb_cpu_doing_single_step, -1);
23683 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
23684
23685 /* set the trace bit if we're stepping */
23686 if (remcomInBuffer[0] == 's') {
23687 linux_regs->flags |= X86_EFLAGS_TF;
23688 - atomic_set(&kgdb_cpu_doing_single_step,
23689 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
23690 raw_smp_processor_id());
23691 }
23692
23693 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
23694
23695 switch (cmd) {
23696 case DIE_DEBUG:
23697 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
23698 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
23699 if (user_mode(regs))
23700 return single_step_cont(regs, args);
23701 break;
23702 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23703 #endif /* CONFIG_DEBUG_RODATA */
23704
23705 bpt->type = BP_BREAKPOINT;
23706 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
23707 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
23708 BREAK_INSTR_SIZE);
23709 if (err)
23710 return err;
23711 - err = probe_kernel_write((char *)bpt->bpt_addr,
23712 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23713 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
23714 #ifdef CONFIG_DEBUG_RODATA
23715 if (!err)
23716 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
23717 return -EBUSY;
23718 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
23719 BREAK_INSTR_SIZE);
23720 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23721 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23722 if (err)
23723 return err;
23724 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
23725 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
23726 if (mutex_is_locked(&text_mutex))
23727 goto knl_write;
23728 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
23729 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
23730 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
23731 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
23732 goto knl_write;
23733 return err;
23734 knl_write:
23735 #endif /* CONFIG_DEBUG_RODATA */
23736 - return probe_kernel_write((char *)bpt->bpt_addr,
23737 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
23738 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
23739 }
23740
23741 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
23742 index 211bce4..6e2580a 100644
23743 --- a/arch/x86/kernel/kprobes/core.c
23744 +++ b/arch/x86/kernel/kprobes/core.c
23745 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
23746 s32 raddr;
23747 } __packed *insn;
23748
23749 - insn = (struct __arch_relative_insn *)from;
23750 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
23751 +
23752 + pax_open_kernel();
23753 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
23754 insn->op = op;
23755 + pax_close_kernel();
23756 }
23757
23758 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
23759 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
23760 kprobe_opcode_t opcode;
23761 kprobe_opcode_t *orig_opcodes = opcodes;
23762
23763 - if (search_exception_tables((unsigned long)opcodes))
23764 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
23765 return 0; /* Page fault may occur on this address. */
23766
23767 retry:
23768 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
23769 * for the first byte, we can recover the original instruction
23770 * from it and kp->opcode.
23771 */
23772 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23773 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
23774 buf[0] = kp->opcode;
23775 - return (unsigned long)buf;
23776 + return ktva_ktla((unsigned long)buf);
23777 }
23778
23779 /*
23780 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23781 /* Another subsystem puts a breakpoint, failed to recover */
23782 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
23783 return 0;
23784 + pax_open_kernel();
23785 memcpy(dest, insn.kaddr, insn.length);
23786 + pax_close_kernel();
23787
23788 #ifdef CONFIG_X86_64
23789 if (insn_rip_relative(&insn)) {
23790 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
23791 return 0;
23792 }
23793 disp = (u8 *) dest + insn_offset_displacement(&insn);
23794 + pax_open_kernel();
23795 *(s32 *) disp = (s32) newdisp;
23796 + pax_close_kernel();
23797 }
23798 #endif
23799 return insn.length;
23800 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23801 * nor set current_kprobe, because it doesn't use single
23802 * stepping.
23803 */
23804 - regs->ip = (unsigned long)p->ainsn.insn;
23805 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23806 preempt_enable_no_resched();
23807 return;
23808 }
23809 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
23810 regs->flags &= ~X86_EFLAGS_IF;
23811 /* single step inline if the instruction is an int3 */
23812 if (p->opcode == BREAKPOINT_INSTRUCTION)
23813 - regs->ip = (unsigned long)p->addr;
23814 + regs->ip = ktla_ktva((unsigned long)p->addr);
23815 else
23816 - regs->ip = (unsigned long)p->ainsn.insn;
23817 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
23818 }
23819
23820 /*
23821 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
23822 setup_singlestep(p, regs, kcb, 0);
23823 return 1;
23824 }
23825 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
23826 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
23827 /*
23828 * The breakpoint instruction was removed right
23829 * after we hit it. Another cpu has removed
23830 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
23831 " movq %rax, 152(%rsp)\n"
23832 RESTORE_REGS_STRING
23833 " popfq\n"
23834 +#ifdef KERNEXEC_PLUGIN
23835 + " btsq $63,(%rsp)\n"
23836 +#endif
23837 #else
23838 " pushf\n"
23839 SAVE_REGS_STRING
23840 @@ -779,7 +789,7 @@ static void __kprobes
23841 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
23842 {
23843 unsigned long *tos = stack_addr(regs);
23844 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
23845 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
23846 unsigned long orig_ip = (unsigned long)p->addr;
23847 kprobe_opcode_t *insn = p->ainsn.insn;
23848
23849 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
23850 struct die_args *args = data;
23851 int ret = NOTIFY_DONE;
23852
23853 - if (args->regs && user_mode_vm(args->regs))
23854 + if (args->regs && user_mode(args->regs))
23855 return ret;
23856
23857 switch (val) {
23858 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
23859 index 76dc6f0..66bdfc3 100644
23860 --- a/arch/x86/kernel/kprobes/opt.c
23861 +++ b/arch/x86/kernel/kprobes/opt.c
23862 @@ -79,6 +79,7 @@ found:
23863 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
23864 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
23865 {
23866 + pax_open_kernel();
23867 #ifdef CONFIG_X86_64
23868 *addr++ = 0x48;
23869 *addr++ = 0xbf;
23870 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
23871 *addr++ = 0xb8;
23872 #endif
23873 *(unsigned long *)addr = val;
23874 + pax_close_kernel();
23875 }
23876
23877 static void __used __kprobes kprobes_optinsn_template_holder(void)
23878 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23879 * Verify if the address gap is in 2GB range, because this uses
23880 * a relative jump.
23881 */
23882 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
23883 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
23884 if (abs(rel) > 0x7fffffff)
23885 return -ERANGE;
23886
23887 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
23888 op->optinsn.size = ret;
23889
23890 /* Copy arch-dep-instance from template */
23891 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
23892 + pax_open_kernel();
23893 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
23894 + pax_close_kernel();
23895
23896 /* Set probe information */
23897 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
23898
23899 /* Set probe function call */
23900 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
23901 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
23902
23903 /* Set returning jmp instruction at the tail of out-of-line buffer */
23904 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
23905 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
23906 (u8 *)op->kp.addr + op->optinsn.size);
23907
23908 flush_icache_range((unsigned long) buf,
23909 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
23910 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
23911
23912 /* Backup instructions which will be replaced by jump address */
23913 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
23914 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
23915 RELATIVE_ADDR_SIZE);
23916
23917 insn_buf[0] = RELATIVEJUMP_OPCODE;
23918 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
23919 /* This kprobe is really able to run optimized path. */
23920 op = container_of(p, struct optimized_kprobe, kp);
23921 /* Detour through copied instructions */
23922 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
23923 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
23924 if (!reenter)
23925 reset_current_kprobe();
23926 preempt_enable_no_resched();
23927 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
23928 index ebc9873..1b9724b 100644
23929 --- a/arch/x86/kernel/ldt.c
23930 +++ b/arch/x86/kernel/ldt.c
23931 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
23932 if (reload) {
23933 #ifdef CONFIG_SMP
23934 preempt_disable();
23935 - load_LDT(pc);
23936 + load_LDT_nolock(pc);
23937 if (!cpumask_equal(mm_cpumask(current->mm),
23938 cpumask_of(smp_processor_id())))
23939 smp_call_function(flush_ldt, current->mm, 1);
23940 preempt_enable();
23941 #else
23942 - load_LDT(pc);
23943 + load_LDT_nolock(pc);
23944 #endif
23945 }
23946 if (oldsize) {
23947 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23948 return err;
23949
23950 for (i = 0; i < old->size; i++)
23951 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23952 + write_ldt_entry(new->ldt, i, old->ldt + i);
23953 return 0;
23954 }
23955
23956 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23957 retval = copy_ldt(&mm->context, &old_mm->context);
23958 mutex_unlock(&old_mm->context.lock);
23959 }
23960 +
23961 + if (tsk == current) {
23962 + mm->context.vdso = 0;
23963 +
23964 +#ifdef CONFIG_X86_32
23965 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23966 + mm->context.user_cs_base = 0UL;
23967 + mm->context.user_cs_limit = ~0UL;
23968 +
23969 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23970 + cpus_clear(mm->context.cpu_user_cs_mask);
23971 +#endif
23972 +
23973 +#endif
23974 +#endif
23975 +
23976 + }
23977 +
23978 return retval;
23979 }
23980
23981 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23982 }
23983 }
23984
23985 +#ifdef CONFIG_PAX_SEGMEXEC
23986 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23987 + error = -EINVAL;
23988 + goto out_unlock;
23989 + }
23990 +#endif
23991 +
23992 fill_ldt(&ldt, &ldt_info);
23993 if (oldmode)
23994 ldt.avl = 0;
23995 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23996 index 5b19e4d..6476a76 100644
23997 --- a/arch/x86/kernel/machine_kexec_32.c
23998 +++ b/arch/x86/kernel/machine_kexec_32.c
23999 @@ -26,7 +26,7 @@
24000 #include <asm/cacheflush.h>
24001 #include <asm/debugreg.h>
24002
24003 -static void set_idt(void *newidt, __u16 limit)
24004 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24005 {
24006 struct desc_ptr curidt;
24007
24008 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24009 }
24010
24011
24012 -static void set_gdt(void *newgdt, __u16 limit)
24013 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24014 {
24015 struct desc_ptr curgdt;
24016
24017 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24018 }
24019
24020 control_page = page_address(image->control_code_page);
24021 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24022 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24023
24024 relocate_kernel_ptr = control_page;
24025 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24026 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24027 index 15c9876..0a43909 100644
24028 --- a/arch/x86/kernel/microcode_core.c
24029 +++ b/arch/x86/kernel/microcode_core.c
24030 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24031 return NOTIFY_OK;
24032 }
24033
24034 -static struct notifier_block __refdata mc_cpu_notifier = {
24035 +static struct notifier_block mc_cpu_notifier = {
24036 .notifier_call = mc_cpu_callback,
24037 };
24038
24039 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24040 index 5fb2ceb..3ae90bb 100644
24041 --- a/arch/x86/kernel/microcode_intel.c
24042 +++ b/arch/x86/kernel/microcode_intel.c
24043 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24044
24045 static int get_ucode_user(void *to, const void *from, size_t n)
24046 {
24047 - return copy_from_user(to, from, n);
24048 + return copy_from_user(to, (const void __force_user *)from, n);
24049 }
24050
24051 static enum ucode_state
24052 request_microcode_user(int cpu, const void __user *buf, size_t size)
24053 {
24054 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24055 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24056 }
24057
24058 static void microcode_fini_cpu(int cpu)
24059 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24060 index 216a4d7..228255a 100644
24061 --- a/arch/x86/kernel/module.c
24062 +++ b/arch/x86/kernel/module.c
24063 @@ -43,15 +43,60 @@ do { \
24064 } while (0)
24065 #endif
24066
24067 -void *module_alloc(unsigned long size)
24068 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24069 {
24070 - if (PAGE_ALIGN(size) > MODULES_LEN)
24071 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24072 return NULL;
24073 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24074 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24075 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24076 -1, __builtin_return_address(0));
24077 }
24078
24079 +void *module_alloc(unsigned long size)
24080 +{
24081 +
24082 +#ifdef CONFIG_PAX_KERNEXEC
24083 + return __module_alloc(size, PAGE_KERNEL);
24084 +#else
24085 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24086 +#endif
24087 +
24088 +}
24089 +
24090 +#ifdef CONFIG_PAX_KERNEXEC
24091 +#ifdef CONFIG_X86_32
24092 +void *module_alloc_exec(unsigned long size)
24093 +{
24094 + struct vm_struct *area;
24095 +
24096 + if (size == 0)
24097 + return NULL;
24098 +
24099 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24100 + return area ? area->addr : NULL;
24101 +}
24102 +EXPORT_SYMBOL(module_alloc_exec);
24103 +
24104 +void module_free_exec(struct module *mod, void *module_region)
24105 +{
24106 + vunmap(module_region);
24107 +}
24108 +EXPORT_SYMBOL(module_free_exec);
24109 +#else
24110 +void module_free_exec(struct module *mod, void *module_region)
24111 +{
24112 + module_free(mod, module_region);
24113 +}
24114 +EXPORT_SYMBOL(module_free_exec);
24115 +
24116 +void *module_alloc_exec(unsigned long size)
24117 +{
24118 + return __module_alloc(size, PAGE_KERNEL_RX);
24119 +}
24120 +EXPORT_SYMBOL(module_alloc_exec);
24121 +#endif
24122 +#endif
24123 +
24124 #ifdef CONFIG_X86_32
24125 int apply_relocate(Elf32_Shdr *sechdrs,
24126 const char *strtab,
24127 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24128 unsigned int i;
24129 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24130 Elf32_Sym *sym;
24131 - uint32_t *location;
24132 + uint32_t *plocation, location;
24133
24134 DEBUGP("Applying relocate section %u to %u\n",
24135 relsec, sechdrs[relsec].sh_info);
24136 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24137 /* This is where to make the change */
24138 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24139 - + rel[i].r_offset;
24140 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24141 + location = (uint32_t)plocation;
24142 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24143 + plocation = ktla_ktva((void *)plocation);
24144 /* This is the symbol it is referring to. Note that all
24145 undefined symbols have been resolved. */
24146 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24147 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24148 switch (ELF32_R_TYPE(rel[i].r_info)) {
24149 case R_386_32:
24150 /* We add the value into the location given */
24151 - *location += sym->st_value;
24152 + pax_open_kernel();
24153 + *plocation += sym->st_value;
24154 + pax_close_kernel();
24155 break;
24156 case R_386_PC32:
24157 /* Add the value, subtract its position */
24158 - *location += sym->st_value - (uint32_t)location;
24159 + pax_open_kernel();
24160 + *plocation += sym->st_value - location;
24161 + pax_close_kernel();
24162 break;
24163 default:
24164 pr_err("%s: Unknown relocation: %u\n",
24165 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24166 case R_X86_64_NONE:
24167 break;
24168 case R_X86_64_64:
24169 + pax_open_kernel();
24170 *(u64 *)loc = val;
24171 + pax_close_kernel();
24172 break;
24173 case R_X86_64_32:
24174 + pax_open_kernel();
24175 *(u32 *)loc = val;
24176 + pax_close_kernel();
24177 if (val != *(u32 *)loc)
24178 goto overflow;
24179 break;
24180 case R_X86_64_32S:
24181 + pax_open_kernel();
24182 *(s32 *)loc = val;
24183 + pax_close_kernel();
24184 if ((s64)val != *(s32 *)loc)
24185 goto overflow;
24186 break;
24187 case R_X86_64_PC32:
24188 val -= (u64)loc;
24189 + pax_open_kernel();
24190 *(u32 *)loc = val;
24191 + pax_close_kernel();
24192 +
24193 #if 0
24194 if ((s64)val != *(s32 *)loc)
24195 goto overflow;
24196 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24197 index 88458fa..349f7a4 100644
24198 --- a/arch/x86/kernel/msr.c
24199 +++ b/arch/x86/kernel/msr.c
24200 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24201 return notifier_from_errno(err);
24202 }
24203
24204 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24205 +static struct notifier_block msr_class_cpu_notifier = {
24206 .notifier_call = msr_class_cpu_callback,
24207 };
24208
24209 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24210 index ba77ebc..65da999 100644
24211 --- a/arch/x86/kernel/nmi.c
24212 +++ b/arch/x86/kernel/nmi.c
24213 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24214 return handled;
24215 }
24216
24217 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24218 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
24219 {
24220 struct nmi_desc *desc = nmi_to_desc(type);
24221 unsigned long flags;
24222 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
24223 * event confuses some handlers (kdump uses this flag)
24224 */
24225 if (action->flags & NMI_FLAG_FIRST)
24226 - list_add_rcu(&action->list, &desc->head);
24227 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
24228 else
24229 - list_add_tail_rcu(&action->list, &desc->head);
24230 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
24231
24232 spin_unlock_irqrestore(&desc->lock, flags);
24233 return 0;
24234 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
24235 if (!strcmp(n->name, name)) {
24236 WARN(in_nmi(),
24237 "Trying to free NMI (%s) from NMI context!\n", n->name);
24238 - list_del_rcu(&n->list);
24239 + pax_list_del_rcu((struct list_head *)&n->list);
24240 break;
24241 }
24242 }
24243 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
24244 dotraplinkage notrace __kprobes void
24245 do_nmi(struct pt_regs *regs, long error_code)
24246 {
24247 +
24248 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24249 + if (!user_mode(regs)) {
24250 + unsigned long cs = regs->cs & 0xFFFF;
24251 + unsigned long ip = ktva_ktla(regs->ip);
24252 +
24253 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
24254 + regs->ip = ip;
24255 + }
24256 +#endif
24257 +
24258 nmi_nesting_preprocess(regs);
24259
24260 nmi_enter();
24261 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
24262 index 6d9582e..f746287 100644
24263 --- a/arch/x86/kernel/nmi_selftest.c
24264 +++ b/arch/x86/kernel/nmi_selftest.c
24265 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
24266 {
24267 /* trap all the unknown NMIs we may generate */
24268 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
24269 - __initdata);
24270 + __initconst);
24271 }
24272
24273 static void __init cleanup_nmi_testsuite(void)
24274 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
24275 unsigned long timeout;
24276
24277 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
24278 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
24279 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
24280 nmi_fail = FAILURE;
24281 return;
24282 }
24283 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
24284 index 676b8c7..870ba04 100644
24285 --- a/arch/x86/kernel/paravirt-spinlocks.c
24286 +++ b/arch/x86/kernel/paravirt-spinlocks.c
24287 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
24288 arch_spin_lock(lock);
24289 }
24290
24291 -struct pv_lock_ops pv_lock_ops = {
24292 +struct pv_lock_ops pv_lock_ops __read_only = {
24293 #ifdef CONFIG_SMP
24294 .spin_is_locked = __ticket_spin_is_locked,
24295 .spin_is_contended = __ticket_spin_is_contended,
24296 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
24297 index cd6de64..27c6af0 100644
24298 --- a/arch/x86/kernel/paravirt.c
24299 +++ b/arch/x86/kernel/paravirt.c
24300 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
24301 {
24302 return x;
24303 }
24304 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24305 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
24306 +#endif
24307
24308 void __init default_banner(void)
24309 {
24310 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
24311 if (opfunc == NULL)
24312 /* If there's no function, patch it with a ud2a (BUG) */
24313 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
24314 - else if (opfunc == _paravirt_nop)
24315 + else if (opfunc == (void *)_paravirt_nop)
24316 /* If the operation is a nop, then nop the callsite */
24317 ret = paravirt_patch_nop();
24318
24319 /* identity functions just return their single argument */
24320 - else if (opfunc == _paravirt_ident_32)
24321 + else if (opfunc == (void *)_paravirt_ident_32)
24322 ret = paravirt_patch_ident_32(insnbuf, len);
24323 - else if (opfunc == _paravirt_ident_64)
24324 + else if (opfunc == (void *)_paravirt_ident_64)
24325 ret = paravirt_patch_ident_64(insnbuf, len);
24326 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
24327 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
24328 + ret = paravirt_patch_ident_64(insnbuf, len);
24329 +#endif
24330
24331 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
24332 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
24333 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
24334 if (insn_len > len || start == NULL)
24335 insn_len = len;
24336 else
24337 - memcpy(insnbuf, start, insn_len);
24338 + memcpy(insnbuf, ktla_ktva(start), insn_len);
24339
24340 return insn_len;
24341 }
24342 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
24343 return this_cpu_read(paravirt_lazy_mode);
24344 }
24345
24346 -struct pv_info pv_info = {
24347 +struct pv_info pv_info __read_only = {
24348 .name = "bare hardware",
24349 .paravirt_enabled = 0,
24350 .kernel_rpl = 0,
24351 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
24352 #endif
24353 };
24354
24355 -struct pv_init_ops pv_init_ops = {
24356 +struct pv_init_ops pv_init_ops __read_only = {
24357 .patch = native_patch,
24358 };
24359
24360 -struct pv_time_ops pv_time_ops = {
24361 +struct pv_time_ops pv_time_ops __read_only = {
24362 .sched_clock = native_sched_clock,
24363 .steal_clock = native_steal_clock,
24364 };
24365
24366 -struct pv_irq_ops pv_irq_ops = {
24367 +struct pv_irq_ops pv_irq_ops __read_only = {
24368 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
24369 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
24370 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
24371 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
24372 #endif
24373 };
24374
24375 -struct pv_cpu_ops pv_cpu_ops = {
24376 +struct pv_cpu_ops pv_cpu_ops __read_only = {
24377 .cpuid = native_cpuid,
24378 .get_debugreg = native_get_debugreg,
24379 .set_debugreg = native_set_debugreg,
24380 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
24381 .end_context_switch = paravirt_nop,
24382 };
24383
24384 -struct pv_apic_ops pv_apic_ops = {
24385 +struct pv_apic_ops pv_apic_ops __read_only= {
24386 #ifdef CONFIG_X86_LOCAL_APIC
24387 .startup_ipi_hook = paravirt_nop,
24388 #endif
24389 };
24390
24391 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
24392 +#ifdef CONFIG_X86_32
24393 +#ifdef CONFIG_X86_PAE
24394 +/* 64-bit pagetable entries */
24395 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
24396 +#else
24397 /* 32-bit pagetable entries */
24398 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
24399 +#endif
24400 #else
24401 /* 64-bit pagetable entries */
24402 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
24403 #endif
24404
24405 -struct pv_mmu_ops pv_mmu_ops = {
24406 +struct pv_mmu_ops pv_mmu_ops __read_only = {
24407
24408 .read_cr2 = native_read_cr2,
24409 .write_cr2 = native_write_cr2,
24410 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
24411 .make_pud = PTE_IDENT,
24412
24413 .set_pgd = native_set_pgd,
24414 + .set_pgd_batched = native_set_pgd_batched,
24415 #endif
24416 #endif /* PAGETABLE_LEVELS >= 3 */
24417
24418 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
24419 },
24420
24421 .set_fixmap = native_set_fixmap,
24422 +
24423 +#ifdef CONFIG_PAX_KERNEXEC
24424 + .pax_open_kernel = native_pax_open_kernel,
24425 + .pax_close_kernel = native_pax_close_kernel,
24426 +#endif
24427 +
24428 };
24429
24430 EXPORT_SYMBOL_GPL(pv_time_ops);
24431 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
24432 index 299d493..2ccb0ee 100644
24433 --- a/arch/x86/kernel/pci-calgary_64.c
24434 +++ b/arch/x86/kernel/pci-calgary_64.c
24435 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
24436 tce_space = be64_to_cpu(readq(target));
24437 tce_space = tce_space & TAR_SW_BITS;
24438
24439 - tce_space = tce_space & (~specified_table_size);
24440 + tce_space = tce_space & (~(unsigned long)specified_table_size);
24441 info->tce_space = (u64 *)__va(tce_space);
24442 }
24443 }
24444 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
24445 index 35ccf75..7a15747 100644
24446 --- a/arch/x86/kernel/pci-iommu_table.c
24447 +++ b/arch/x86/kernel/pci-iommu_table.c
24448 @@ -2,7 +2,7 @@
24449 #include <asm/iommu_table.h>
24450 #include <linux/string.h>
24451 #include <linux/kallsyms.h>
24452 -
24453 +#include <linux/sched.h>
24454
24455 #define DEBUG 1
24456
24457 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
24458 index 6c483ba..d10ce2f 100644
24459 --- a/arch/x86/kernel/pci-swiotlb.c
24460 +++ b/arch/x86/kernel/pci-swiotlb.c
24461 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
24462 void *vaddr, dma_addr_t dma_addr,
24463 struct dma_attrs *attrs)
24464 {
24465 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
24466 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
24467 }
24468
24469 static struct dma_map_ops swiotlb_dma_ops = {
24470 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
24471 index 83369e5..52b93f0 100644
24472 --- a/arch/x86/kernel/process.c
24473 +++ b/arch/x86/kernel/process.c
24474 @@ -36,7 +36,8 @@
24475 * section. Since TSS's are completely CPU-local, we want them
24476 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
24477 */
24478 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
24479 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
24480 +EXPORT_SYMBOL(init_tss);
24481
24482 #ifdef CONFIG_X86_64
24483 static DEFINE_PER_CPU(unsigned char, is_idle);
24484 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
24485 task_xstate_cachep =
24486 kmem_cache_create("task_xstate", xstate_size,
24487 __alignof__(union thread_xstate),
24488 - SLAB_PANIC | SLAB_NOTRACK, NULL);
24489 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
24490 }
24491
24492 /*
24493 @@ -105,7 +106,7 @@ void exit_thread(void)
24494 unsigned long *bp = t->io_bitmap_ptr;
24495
24496 if (bp) {
24497 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
24498 + struct tss_struct *tss = init_tss + get_cpu();
24499
24500 t->io_bitmap_ptr = NULL;
24501 clear_thread_flag(TIF_IO_BITMAP);
24502 @@ -125,6 +126,9 @@ void flush_thread(void)
24503 {
24504 struct task_struct *tsk = current;
24505
24506 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
24507 + loadsegment(gs, 0);
24508 +#endif
24509 flush_ptrace_hw_breakpoint(tsk);
24510 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
24511 drop_init_fpu(tsk);
24512 @@ -271,7 +275,7 @@ static void __exit_idle(void)
24513 void exit_idle(void)
24514 {
24515 /* idle loop has pid 0 */
24516 - if (current->pid)
24517 + if (task_pid_nr(current))
24518 return;
24519 __exit_idle();
24520 }
24521 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
24522 return ret;
24523 }
24524 #endif
24525 -void stop_this_cpu(void *dummy)
24526 +__noreturn void stop_this_cpu(void *dummy)
24527 {
24528 local_irq_disable();
24529 /*
24530 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
24531 }
24532 early_param("idle", idle_setup);
24533
24534 -unsigned long arch_align_stack(unsigned long sp)
24535 +#ifdef CONFIG_PAX_RANDKSTACK
24536 +void pax_randomize_kstack(struct pt_regs *regs)
24537 {
24538 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
24539 - sp -= get_random_int() % 8192;
24540 - return sp & ~0xf;
24541 -}
24542 + struct thread_struct *thread = &current->thread;
24543 + unsigned long time;
24544
24545 -unsigned long arch_randomize_brk(struct mm_struct *mm)
24546 -{
24547 - unsigned long range_end = mm->brk + 0x02000000;
24548 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
24549 -}
24550 + if (!randomize_va_space)
24551 + return;
24552 +
24553 + if (v8086_mode(regs))
24554 + return;
24555
24556 + rdtscl(time);
24557 +
24558 + /* P4 seems to return a 0 LSB, ignore it */
24559 +#ifdef CONFIG_MPENTIUM4
24560 + time &= 0x3EUL;
24561 + time <<= 2;
24562 +#elif defined(CONFIG_X86_64)
24563 + time &= 0xFUL;
24564 + time <<= 4;
24565 +#else
24566 + time &= 0x1FUL;
24567 + time <<= 3;
24568 +#endif
24569 +
24570 + thread->sp0 ^= time;
24571 + load_sp0(init_tss + smp_processor_id(), thread);
24572 +
24573 +#ifdef CONFIG_X86_64
24574 + this_cpu_write(kernel_stack, thread->sp0);
24575 +#endif
24576 +}
24577 +#endif
24578 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
24579 index f8adefc..4bce3d6 100644
24580 --- a/arch/x86/kernel/process_32.c
24581 +++ b/arch/x86/kernel/process_32.c
24582 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
24583 unsigned long thread_saved_pc(struct task_struct *tsk)
24584 {
24585 return ((unsigned long *)tsk->thread.sp)[3];
24586 +//XXX return tsk->thread.eip;
24587 }
24588
24589 void __show_regs(struct pt_regs *regs, int all)
24590 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
24591 unsigned long sp;
24592 unsigned short ss, gs;
24593
24594 - if (user_mode_vm(regs)) {
24595 + if (user_mode(regs)) {
24596 sp = regs->sp;
24597 ss = regs->ss & 0xffff;
24598 - gs = get_user_gs(regs);
24599 } else {
24600 sp = kernel_stack_pointer(regs);
24601 savesegment(ss, ss);
24602 - savesegment(gs, gs);
24603 }
24604 + gs = get_user_gs(regs);
24605
24606 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
24607 (u16)regs->cs, regs->ip, regs->flags,
24608 - smp_processor_id());
24609 + raw_smp_processor_id());
24610 print_symbol("EIP is at %s\n", regs->ip);
24611
24612 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
24613 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
24614 int copy_thread(unsigned long clone_flags, unsigned long sp,
24615 unsigned long arg, struct task_struct *p)
24616 {
24617 - struct pt_regs *childregs = task_pt_regs(p);
24618 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
24619 struct task_struct *tsk;
24620 int err;
24621
24622 p->thread.sp = (unsigned long) childregs;
24623 p->thread.sp0 = (unsigned long) (childregs+1);
24624 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24625
24626 if (unlikely(p->flags & PF_KTHREAD)) {
24627 /* kernel thread */
24628 memset(childregs, 0, sizeof(struct pt_regs));
24629 p->thread.ip = (unsigned long) ret_from_kernel_thread;
24630 - task_user_gs(p) = __KERNEL_STACK_CANARY;
24631 - childregs->ds = __USER_DS;
24632 - childregs->es = __USER_DS;
24633 + savesegment(gs, childregs->gs);
24634 + childregs->ds = __KERNEL_DS;
24635 + childregs->es = __KERNEL_DS;
24636 childregs->fs = __KERNEL_PERCPU;
24637 childregs->bx = sp; /* function */
24638 childregs->bp = arg;
24639 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24640 struct thread_struct *prev = &prev_p->thread,
24641 *next = &next_p->thread;
24642 int cpu = smp_processor_id();
24643 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24644 + struct tss_struct *tss = init_tss + cpu;
24645 fpu_switch_t fpu;
24646
24647 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
24648 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24649 */
24650 lazy_save_gs(prev->gs);
24651
24652 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24653 + __set_fs(task_thread_info(next_p)->addr_limit);
24654 +#endif
24655 +
24656 /*
24657 * Load the per-thread Thread-Local Storage descriptor.
24658 */
24659 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24660 */
24661 arch_end_context_switch(next_p);
24662
24663 + this_cpu_write(current_task, next_p);
24664 + this_cpu_write(current_tinfo, &next_p->tinfo);
24665 +
24666 /*
24667 * Restore %gs if needed (which is common)
24668 */
24669 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24670
24671 switch_fpu_finish(next_p, fpu);
24672
24673 - this_cpu_write(current_task, next_p);
24674 -
24675 return prev_p;
24676 }
24677
24678 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
24679 } while (count++ < 16);
24680 return 0;
24681 }
24682 -
24683 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
24684 index 05646ba..0c2906d 100644
24685 --- a/arch/x86/kernel/process_64.c
24686 +++ b/arch/x86/kernel/process_64.c
24687 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24688 struct pt_regs *childregs;
24689 struct task_struct *me = current;
24690
24691 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
24692 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
24693 childregs = task_pt_regs(p);
24694 p->thread.sp = (unsigned long) childregs;
24695 p->thread.usersp = me->thread.usersp;
24696 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
24697 set_tsk_thread_flag(p, TIF_FORK);
24698 p->fpu_counter = 0;
24699 p->thread.io_bitmap_ptr = NULL;
24700 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
24701 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
24702 savesegment(es, p->thread.es);
24703 savesegment(ds, p->thread.ds);
24704 + savesegment(ss, p->thread.ss);
24705 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
24706 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
24707
24708 if (unlikely(p->flags & PF_KTHREAD)) {
24709 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24710 struct thread_struct *prev = &prev_p->thread;
24711 struct thread_struct *next = &next_p->thread;
24712 int cpu = smp_processor_id();
24713 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
24714 + struct tss_struct *tss = init_tss + cpu;
24715 unsigned fsindex, gsindex;
24716 fpu_switch_t fpu;
24717
24718 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24719 if (unlikely(next->ds | prev->ds))
24720 loadsegment(ds, next->ds);
24721
24722 + savesegment(ss, prev->ss);
24723 + if (unlikely(next->ss != prev->ss))
24724 + loadsegment(ss, next->ss);
24725
24726 /* We must save %fs and %gs before load_TLS() because
24727 * %fs and %gs may be cleared by load_TLS().
24728 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
24729 prev->usersp = this_cpu_read(old_rsp);
24730 this_cpu_write(old_rsp, next->usersp);
24731 this_cpu_write(current_task, next_p);
24732 + this_cpu_write(current_tinfo, &next_p->tinfo);
24733
24734 - this_cpu_write(kernel_stack,
24735 - (unsigned long)task_stack_page(next_p) +
24736 - THREAD_SIZE - KERNEL_STACK_OFFSET);
24737 + this_cpu_write(kernel_stack, next->sp0);
24738
24739 /*
24740 * Now maybe reload the debug registers and handle I/O bitmaps
24741 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
24742 if (!p || p == current || p->state == TASK_RUNNING)
24743 return 0;
24744 stack = (unsigned long)task_stack_page(p);
24745 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
24746 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
24747 return 0;
24748 fp = *(u64 *)(p->thread.sp);
24749 do {
24750 - if (fp < (unsigned long)stack ||
24751 - fp >= (unsigned long)stack+THREAD_SIZE)
24752 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
24753 return 0;
24754 ip = *(u64 *)(fp+8);
24755 if (!in_sched_functions(ip))
24756 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
24757 index 7461f50..1334029 100644
24758 --- a/arch/x86/kernel/ptrace.c
24759 +++ b/arch/x86/kernel/ptrace.c
24760 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
24761 {
24762 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
24763 unsigned long sp = (unsigned long)&regs->sp;
24764 - struct thread_info *tinfo;
24765
24766 - if (context == (sp & ~(THREAD_SIZE - 1)))
24767 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
24768 return sp;
24769
24770 - tinfo = (struct thread_info *)context;
24771 - if (tinfo->previous_esp)
24772 - return tinfo->previous_esp;
24773 + sp = *(unsigned long *)context;
24774 + if (sp)
24775 + return sp;
24776
24777 return (unsigned long)regs;
24778 }
24779 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
24780 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
24781 {
24782 int i;
24783 - int dr7 = 0;
24784 + unsigned long dr7 = 0;
24785 struct arch_hw_breakpoint *info;
24786
24787 for (i = 0; i < HBP_NUM; i++) {
24788 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
24789 unsigned long addr, unsigned long data)
24790 {
24791 int ret;
24792 - unsigned long __user *datap = (unsigned long __user *)data;
24793 + unsigned long __user *datap = (__force unsigned long __user *)data;
24794
24795 switch (request) {
24796 /* read the word at location addr in the USER area. */
24797 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
24798 if ((int) addr < 0)
24799 return -EIO;
24800 ret = do_get_thread_area(child, addr,
24801 - (struct user_desc __user *)data);
24802 + (__force struct user_desc __user *) data);
24803 break;
24804
24805 case PTRACE_SET_THREAD_AREA:
24806 if ((int) addr < 0)
24807 return -EIO;
24808 ret = do_set_thread_area(child, addr,
24809 - (struct user_desc __user *)data, 0);
24810 + (__force struct user_desc __user *) data, 0);
24811 break;
24812 #endif
24813
24814 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
24815
24816 #ifdef CONFIG_X86_64
24817
24818 -static struct user_regset x86_64_regsets[] __read_mostly = {
24819 +static user_regset_no_const x86_64_regsets[] __read_only = {
24820 [REGSET_GENERAL] = {
24821 .core_note_type = NT_PRSTATUS,
24822 .n = sizeof(struct user_regs_struct) / sizeof(long),
24823 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
24824 #endif /* CONFIG_X86_64 */
24825
24826 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
24827 -static struct user_regset x86_32_regsets[] __read_mostly = {
24828 +static user_regset_no_const x86_32_regsets[] __read_only = {
24829 [REGSET_GENERAL] = {
24830 .core_note_type = NT_PRSTATUS,
24831 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
24832 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
24833 */
24834 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
24835
24836 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24837 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
24838 {
24839 #ifdef CONFIG_X86_64
24840 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
24841 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
24842 memset(info, 0, sizeof(*info));
24843 info->si_signo = SIGTRAP;
24844 info->si_code = si_code;
24845 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
24846 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
24847 }
24848
24849 void user_single_step_siginfo(struct task_struct *tsk,
24850 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
24851 # define IS_IA32 0
24852 #endif
24853
24854 +#ifdef CONFIG_GRKERNSEC_SETXID
24855 +extern void gr_delayed_cred_worker(void);
24856 +#endif
24857 +
24858 /*
24859 * We must return the syscall number to actually look up in the table.
24860 * This can be -1L to skip running any syscall at all.
24861 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
24862
24863 user_exit();
24864
24865 +#ifdef CONFIG_GRKERNSEC_SETXID
24866 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24867 + gr_delayed_cred_worker();
24868 +#endif
24869 +
24870 /*
24871 * If we stepped into a sysenter/syscall insn, it trapped in
24872 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
24873 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
24874 */
24875 user_exit();
24876
24877 +#ifdef CONFIG_GRKERNSEC_SETXID
24878 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
24879 + gr_delayed_cred_worker();
24880 +#endif
24881 +
24882 audit_syscall_exit(regs);
24883
24884 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
24885 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
24886 index 2cb9470..ff1fd80 100644
24887 --- a/arch/x86/kernel/pvclock.c
24888 +++ b/arch/x86/kernel/pvclock.c
24889 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
24890 return pv_tsc_khz;
24891 }
24892
24893 -static atomic64_t last_value = ATOMIC64_INIT(0);
24894 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
24895
24896 void pvclock_resume(void)
24897 {
24898 - atomic64_set(&last_value, 0);
24899 + atomic64_set_unchecked(&last_value, 0);
24900 }
24901
24902 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
24903 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
24904 * updating at the same time, and one of them could be slightly behind,
24905 * making the assumption that last_value always go forward fail to hold.
24906 */
24907 - last = atomic64_read(&last_value);
24908 + last = atomic64_read_unchecked(&last_value);
24909 do {
24910 if (ret < last)
24911 return last;
24912 - last = atomic64_cmpxchg(&last_value, last, ret);
24913 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
24914 } while (unlikely(last != ret));
24915
24916 return ret;
24917 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
24918 index 5f4ad27..9d96c99 100644
24919 --- a/arch/x86/kernel/reboot.c
24920 +++ b/arch/x86/kernel/reboot.c
24921 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
24922
24923 void __noreturn machine_real_restart(unsigned int type)
24924 {
24925 +
24926 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
24927 + struct desc_struct *gdt;
24928 +#endif
24929 +
24930 local_irq_disable();
24931
24932 /*
24933 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
24934
24935 /* Jump to the identity-mapped low memory code */
24936 #ifdef CONFIG_X86_32
24937 - asm volatile("jmpl *%0" : :
24938 +
24939 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24940 + gdt = get_cpu_gdt_table(smp_processor_id());
24941 + pax_open_kernel();
24942 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24943 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24944 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24945 + loadsegment(ds, __KERNEL_DS);
24946 + loadsegment(es, __KERNEL_DS);
24947 + loadsegment(ss, __KERNEL_DS);
24948 +#endif
24949 +#ifdef CONFIG_PAX_KERNEXEC
24950 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24951 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24952 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24953 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24954 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24955 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24956 +#endif
24957 + pax_close_kernel();
24958 +#endif
24959 +
24960 + asm volatile("ljmpl *%0" : :
24961 "rm" (real_mode_header->machine_real_restart_asm),
24962 "a" (type));
24963 #else
24964 @@ -458,7 +485,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24965 * try to force a triple fault and then cycle between hitting the keyboard
24966 * controller and doing that
24967 */
24968 -static void native_machine_emergency_restart(void)
24969 +static void __noreturn native_machine_emergency_restart(void)
24970 {
24971 int i;
24972 int attempt = 0;
24973 @@ -567,13 +594,13 @@ void native_machine_shutdown(void)
24974 #endif
24975 }
24976
24977 -static void __machine_emergency_restart(int emergency)
24978 +static void __noreturn __machine_emergency_restart(int emergency)
24979 {
24980 reboot_emergency = emergency;
24981 machine_ops.emergency_restart();
24982 }
24983
24984 -static void native_machine_restart(char *__unused)
24985 +static void __noreturn native_machine_restart(char *__unused)
24986 {
24987 pr_notice("machine restart\n");
24988
24989 @@ -582,7 +609,7 @@ static void native_machine_restart(char *__unused)
24990 __machine_emergency_restart(0);
24991 }
24992
24993 -static void native_machine_halt(void)
24994 +static void __noreturn native_machine_halt(void)
24995 {
24996 /* Stop other cpus and apics */
24997 machine_shutdown();
24998 @@ -592,7 +619,7 @@ static void native_machine_halt(void)
24999 stop_this_cpu(NULL);
25000 }
25001
25002 -static void native_machine_power_off(void)
25003 +static void __noreturn native_machine_power_off(void)
25004 {
25005 if (pm_power_off) {
25006 if (!reboot_force)
25007 @@ -601,9 +628,10 @@ static void native_machine_power_off(void)
25008 }
25009 /* A fallback in case there is no PM info available */
25010 tboot_shutdown(TB_SHUTDOWN_HALT);
25011 + unreachable();
25012 }
25013
25014 -struct machine_ops machine_ops = {
25015 +struct machine_ops machine_ops __read_only = {
25016 .power_off = native_machine_power_off,
25017 .shutdown = native_machine_shutdown,
25018 .emergency_restart = native_machine_emergency_restart,
25019 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25020 index c8e41e9..64049ef 100644
25021 --- a/arch/x86/kernel/reboot_fixups_32.c
25022 +++ b/arch/x86/kernel/reboot_fixups_32.c
25023 @@ -57,7 +57,7 @@ struct device_fixup {
25024 unsigned int vendor;
25025 unsigned int device;
25026 void (*reboot_fixup)(struct pci_dev *);
25027 -};
25028 +} __do_const;
25029
25030 /*
25031 * PCI ids solely used for fixups_table go here
25032 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25033 index 3fd2c69..16ef367 100644
25034 --- a/arch/x86/kernel/relocate_kernel_64.S
25035 +++ b/arch/x86/kernel/relocate_kernel_64.S
25036 @@ -11,6 +11,7 @@
25037 #include <asm/kexec.h>
25038 #include <asm/processor-flags.h>
25039 #include <asm/pgtable_types.h>
25040 +#include <asm/alternative-asm.h>
25041
25042 /*
25043 * Must be relocatable PIC code callable as a C function
25044 @@ -96,8 +97,7 @@ relocate_kernel:
25045
25046 /* jump to identity mapped page */
25047 addq $(identity_mapped - relocate_kernel), %r8
25048 - pushq %r8
25049 - ret
25050 + jmp *%r8
25051
25052 identity_mapped:
25053 /* set return address to 0 if not preserving context */
25054 @@ -167,6 +167,7 @@ identity_mapped:
25055 xorl %r14d, %r14d
25056 xorl %r15d, %r15d
25057
25058 + pax_force_retaddr 0, 1
25059 ret
25060
25061 1:
25062 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25063 index 234e1e3..1246d05 100644
25064 --- a/arch/x86/kernel/setup.c
25065 +++ b/arch/x86/kernel/setup.c
25066 @@ -110,6 +110,7 @@
25067 #include <asm/mce.h>
25068 #include <asm/alternative.h>
25069 #include <asm/prom.h>
25070 +#include <asm/boot.h>
25071
25072 /*
25073 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25074 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25075 #endif
25076
25077
25078 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25079 -unsigned long mmu_cr4_features;
25080 +#ifdef CONFIG_X86_64
25081 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25082 +#elif defined(CONFIG_X86_PAE)
25083 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25084 #else
25085 -unsigned long mmu_cr4_features = X86_CR4_PAE;
25086 +unsigned long mmu_cr4_features __read_only;
25087 #endif
25088
25089 +void set_in_cr4(unsigned long mask)
25090 +{
25091 + unsigned long cr4 = read_cr4();
25092 +
25093 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25094 + return;
25095 +
25096 + pax_open_kernel();
25097 + mmu_cr4_features |= mask;
25098 + pax_close_kernel();
25099 +
25100 + if (trampoline_cr4_features)
25101 + *trampoline_cr4_features = mmu_cr4_features;
25102 + cr4 |= mask;
25103 + write_cr4(cr4);
25104 +}
25105 +EXPORT_SYMBOL(set_in_cr4);
25106 +
25107 +void clear_in_cr4(unsigned long mask)
25108 +{
25109 + unsigned long cr4 = read_cr4();
25110 +
25111 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25112 + return;
25113 +
25114 + pax_open_kernel();
25115 + mmu_cr4_features &= ~mask;
25116 + pax_close_kernel();
25117 +
25118 + if (trampoline_cr4_features)
25119 + *trampoline_cr4_features = mmu_cr4_features;
25120 + cr4 &= ~mask;
25121 + write_cr4(cr4);
25122 +}
25123 +EXPORT_SYMBOL(clear_in_cr4);
25124 +
25125 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25126 int bootloader_type, bootloader_version;
25127
25128 @@ -442,7 +481,7 @@ static void __init parse_setup_data(void)
25129
25130 switch (data_type) {
25131 case SETUP_E820_EXT:
25132 - parse_e820_ext(pa_data, data_len);
25133 + parse_e820_ext((struct setup_data __force_kernel *)pa_data, data_len);
25134 break;
25135 case SETUP_DTB:
25136 add_dtb(pa_data);
25137 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25138 * area (640->1Mb) as ram even though it is not.
25139 * take them out.
25140 */
25141 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25142 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25143
25144 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25145 }
25146 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25147 /* called before trim_bios_range() to spare extra sanitize */
25148 static void __init e820_add_kernel_range(void)
25149 {
25150 - u64 start = __pa_symbol(_text);
25151 + u64 start = __pa_symbol(ktla_ktva(_text));
25152 u64 size = __pa_symbol(_end) - start;
25153
25154 /*
25155 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25156
25157 void __init setup_arch(char **cmdline_p)
25158 {
25159 +#ifdef CONFIG_X86_32
25160 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25161 +#else
25162 memblock_reserve(__pa_symbol(_text),
25163 (unsigned long)__bss_stop - (unsigned long)_text);
25164 +#endif
25165
25166 early_reserve_initrd();
25167
25168 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25169
25170 if (!boot_params.hdr.root_flags)
25171 root_mountflags &= ~MS_RDONLY;
25172 - init_mm.start_code = (unsigned long) _text;
25173 - init_mm.end_code = (unsigned long) _etext;
25174 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25175 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25176 init_mm.end_data = (unsigned long) _edata;
25177 init_mm.brk = _brk_end;
25178
25179 - code_resource.start = __pa_symbol(_text);
25180 - code_resource.end = __pa_symbol(_etext)-1;
25181 - data_resource.start = __pa_symbol(_etext);
25182 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25183 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25184 + data_resource.start = __pa_symbol(_sdata);
25185 data_resource.end = __pa_symbol(_edata)-1;
25186 bss_resource.start = __pa_symbol(__bss_start);
25187 bss_resource.end = __pa_symbol(__bss_stop)-1;
25188 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25189 index 5cdff03..80fa283 100644
25190 --- a/arch/x86/kernel/setup_percpu.c
25191 +++ b/arch/x86/kernel/setup_percpu.c
25192 @@ -21,19 +21,17 @@
25193 #include <asm/cpu.h>
25194 #include <asm/stackprotector.h>
25195
25196 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25197 +#ifdef CONFIG_SMP
25198 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25199 EXPORT_PER_CPU_SYMBOL(cpu_number);
25200 +#endif
25201
25202 -#ifdef CONFIG_X86_64
25203 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25204 -#else
25205 -#define BOOT_PERCPU_OFFSET 0
25206 -#endif
25207
25208 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25209 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25210
25211 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25212 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25213 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25214 };
25215 EXPORT_SYMBOL(__per_cpu_offset);
25216 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25217 {
25218 #ifdef CONFIG_NEED_MULTIPLE_NODES
25219 pg_data_t *last = NULL;
25220 - unsigned int cpu;
25221 + int cpu;
25222
25223 for_each_possible_cpu(cpu) {
25224 int node = early_cpu_to_node(cpu);
25225 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
25226 {
25227 #ifdef CONFIG_X86_32
25228 struct desc_struct gdt;
25229 + unsigned long base = per_cpu_offset(cpu);
25230
25231 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
25232 - 0x2 | DESCTYPE_S, 0x8);
25233 - gdt.s = 1;
25234 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
25235 + 0x83 | DESCTYPE_S, 0xC);
25236 write_gdt_entry(get_cpu_gdt_table(cpu),
25237 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
25238 #endif
25239 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
25240 /* alrighty, percpu areas up and running */
25241 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
25242 for_each_possible_cpu(cpu) {
25243 +#ifdef CONFIG_CC_STACKPROTECTOR
25244 +#ifdef CONFIG_X86_32
25245 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
25246 +#endif
25247 +#endif
25248 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
25249 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
25250 per_cpu(cpu_number, cpu) = cpu;
25251 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
25252 */
25253 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
25254 #endif
25255 +#ifdef CONFIG_CC_STACKPROTECTOR
25256 +#ifdef CONFIG_X86_32
25257 + if (!cpu)
25258 + per_cpu(stack_canary.canary, cpu) = canary;
25259 +#endif
25260 +#endif
25261 /*
25262 * Up to this point, the boot CPU has been using .init.data
25263 * area. Reload any changed state for the boot CPU.
25264 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
25265 index d859eea..44e17c4 100644
25266 --- a/arch/x86/kernel/signal.c
25267 +++ b/arch/x86/kernel/signal.c
25268 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
25269 * Align the stack pointer according to the i386 ABI,
25270 * i.e. so that on function entry ((sp + 4) & 15) == 0.
25271 */
25272 - sp = ((sp + 4) & -16ul) - 4;
25273 + sp = ((sp - 12) & -16ul) - 4;
25274 #else /* !CONFIG_X86_32 */
25275 sp = round_down(sp, 16) - 8;
25276 #endif
25277 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25278 }
25279
25280 if (current->mm->context.vdso)
25281 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25282 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
25283 else
25284 - restorer = &frame->retcode;
25285 + restorer = (void __user *)&frame->retcode;
25286 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25287 restorer = ksig->ka.sa.sa_restorer;
25288
25289 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
25290 * reasons and because gdb uses it as a signature to notice
25291 * signal handler stack frames.
25292 */
25293 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
25294 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
25295
25296 if (err)
25297 return -EFAULT;
25298 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25299 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
25300
25301 /* Set up to return from userspace. */
25302 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25303 + if (current->mm->context.vdso)
25304 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
25305 + else
25306 + restorer = (void __user *)&frame->retcode;
25307 if (ksig->ka.sa.sa_flags & SA_RESTORER)
25308 restorer = ksig->ka.sa.sa_restorer;
25309 put_user_ex(restorer, &frame->pretcode);
25310 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
25311 * reasons and because gdb uses it as a signature to notice
25312 * signal handler stack frames.
25313 */
25314 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
25315 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
25316 } put_user_catch(err);
25317
25318 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
25319 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25320 {
25321 int usig = signr_convert(ksig->sig);
25322 sigset_t *set = sigmask_to_save();
25323 - compat_sigset_t *cset = (compat_sigset_t *) set;
25324 + sigset_t sigcopy;
25325 + compat_sigset_t *cset;
25326 +
25327 + sigcopy = *set;
25328 +
25329 + cset = (compat_sigset_t *) &sigcopy;
25330
25331 /* Set up the stack frame */
25332 if (is_ia32_frame()) {
25333 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
25334 } else if (is_x32_frame()) {
25335 return x32_setup_rt_frame(ksig, cset, regs);
25336 } else {
25337 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
25338 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
25339 }
25340 }
25341
25342 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
25343 index cdaa347..f5af55d 100644
25344 --- a/arch/x86/kernel/smp.c
25345 +++ b/arch/x86/kernel/smp.c
25346 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
25347
25348 __setup("nonmi_ipi", nonmi_ipi_setup);
25349
25350 -struct smp_ops smp_ops = {
25351 +struct smp_ops smp_ops __read_only = {
25352 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
25353 .smp_prepare_cpus = native_smp_prepare_cpus,
25354 .smp_cpus_done = native_smp_cpus_done,
25355 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
25356 index aecc98a..0244a53 100644
25357 --- a/arch/x86/kernel/smpboot.c
25358 +++ b/arch/x86/kernel/smpboot.c
25359 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
25360
25361 enable_start_cpu0 = 0;
25362
25363 -#ifdef CONFIG_X86_32
25364 - /* switch away from the initial page table */
25365 - load_cr3(swapper_pg_dir);
25366 - __flush_tlb_all();
25367 -#endif
25368 -
25369 /* otherwise gcc will move up smp_processor_id before the cpu_init */
25370 barrier();
25371 +
25372 + /* switch away from the initial page table */
25373 +#ifdef CONFIG_PAX_PER_CPU_PGD
25374 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
25375 + __flush_tlb_all();
25376 +#elif defined(CONFIG_X86_32)
25377 + load_cr3(swapper_pg_dir);
25378 + __flush_tlb_all();
25379 +#endif
25380 +
25381 /*
25382 * Check TSC synchronization with the BP:
25383 */
25384 @@ -748,6 +752,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25385 idle->thread.sp = (unsigned long) (((struct pt_regs *)
25386 (THREAD_SIZE + task_stack_page(idle))) - 1);
25387 per_cpu(current_task, cpu) = idle;
25388 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
25389
25390 #ifdef CONFIG_X86_32
25391 /* Stack for startup_32 can be just as for start_secondary onwards */
25392 @@ -755,11 +760,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
25393 #else
25394 clear_tsk_thread_flag(idle, TIF_FORK);
25395 initial_gs = per_cpu_offset(cpu);
25396 - per_cpu(kernel_stack, cpu) =
25397 - (unsigned long)task_stack_page(idle) -
25398 - KERNEL_STACK_OFFSET + THREAD_SIZE;
25399 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
25400 #endif
25401 +
25402 + pax_open_kernel();
25403 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
25404 + pax_close_kernel();
25405 +
25406 initial_code = (unsigned long)start_secondary;
25407 stack_start = idle->thread.sp;
25408
25409 @@ -908,6 +915,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
25410 /* the FPU context is blank, nobody can own it */
25411 __cpu_disable_lazy_restore(cpu);
25412
25413 +#ifdef CONFIG_PAX_PER_CPU_PGD
25414 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
25415 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25416 + KERNEL_PGD_PTRS);
25417 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
25418 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
25419 + KERNEL_PGD_PTRS);
25420 +#endif
25421 +
25422 err = do_boot_cpu(apicid, cpu, tidle);
25423 if (err) {
25424 pr_debug("do_boot_cpu failed %d\n", err);
25425 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
25426 index 9b4d51d..5d28b58 100644
25427 --- a/arch/x86/kernel/step.c
25428 +++ b/arch/x86/kernel/step.c
25429 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25430 struct desc_struct *desc;
25431 unsigned long base;
25432
25433 - seg &= ~7UL;
25434 + seg >>= 3;
25435
25436 mutex_lock(&child->mm->context.lock);
25437 - if (unlikely((seg >> 3) >= child->mm->context.size))
25438 + if (unlikely(seg >= child->mm->context.size))
25439 addr = -1L; /* bogus selector, access would fault */
25440 else {
25441 desc = child->mm->context.ldt + seg;
25442 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
25443 addr += base;
25444 }
25445 mutex_unlock(&child->mm->context.lock);
25446 - }
25447 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
25448 + addr = ktla_ktva(addr);
25449
25450 return addr;
25451 }
25452 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
25453 unsigned char opcode[15];
25454 unsigned long addr = convert_ip_to_linear(child, regs);
25455
25456 + if (addr == -EINVAL)
25457 + return 0;
25458 +
25459 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
25460 for (i = 0; i < copied; i++) {
25461 switch (opcode[i]) {
25462 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
25463 new file mode 100644
25464 index 0000000..5877189
25465 --- /dev/null
25466 +++ b/arch/x86/kernel/sys_i386_32.c
25467 @@ -0,0 +1,189 @@
25468 +/*
25469 + * This file contains various random system calls that
25470 + * have a non-standard calling sequence on the Linux/i386
25471 + * platform.
25472 + */
25473 +
25474 +#include <linux/errno.h>
25475 +#include <linux/sched.h>
25476 +#include <linux/mm.h>
25477 +#include <linux/fs.h>
25478 +#include <linux/smp.h>
25479 +#include <linux/sem.h>
25480 +#include <linux/msg.h>
25481 +#include <linux/shm.h>
25482 +#include <linux/stat.h>
25483 +#include <linux/syscalls.h>
25484 +#include <linux/mman.h>
25485 +#include <linux/file.h>
25486 +#include <linux/utsname.h>
25487 +#include <linux/ipc.h>
25488 +#include <linux/elf.h>
25489 +
25490 +#include <linux/uaccess.h>
25491 +#include <linux/unistd.h>
25492 +
25493 +#include <asm/syscalls.h>
25494 +
25495 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
25496 +{
25497 + unsigned long pax_task_size = TASK_SIZE;
25498 +
25499 +#ifdef CONFIG_PAX_SEGMEXEC
25500 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
25501 + pax_task_size = SEGMEXEC_TASK_SIZE;
25502 +#endif
25503 +
25504 + if (flags & MAP_FIXED)
25505 + if (len > pax_task_size || addr > pax_task_size - len)
25506 + return -EINVAL;
25507 +
25508 + return 0;
25509 +}
25510 +
25511 +/*
25512 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
25513 + */
25514 +static unsigned long get_align_mask(void)
25515 +{
25516 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
25517 + return 0;
25518 +
25519 + if (!(current->flags & PF_RANDOMIZE))
25520 + return 0;
25521 +
25522 + return va_align.mask;
25523 +}
25524 +
25525 +unsigned long
25526 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
25527 + unsigned long len, unsigned long pgoff, unsigned long flags)
25528 +{
25529 + struct mm_struct *mm = current->mm;
25530 + struct vm_area_struct *vma;
25531 + unsigned long pax_task_size = TASK_SIZE;
25532 + struct vm_unmapped_area_info info;
25533 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25534 +
25535 +#ifdef CONFIG_PAX_SEGMEXEC
25536 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25537 + pax_task_size = SEGMEXEC_TASK_SIZE;
25538 +#endif
25539 +
25540 + pax_task_size -= PAGE_SIZE;
25541 +
25542 + if (len > pax_task_size)
25543 + return -ENOMEM;
25544 +
25545 + if (flags & MAP_FIXED)
25546 + return addr;
25547 +
25548 +#ifdef CONFIG_PAX_RANDMMAP
25549 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25550 +#endif
25551 +
25552 + if (addr) {
25553 + addr = PAGE_ALIGN(addr);
25554 + if (pax_task_size - len >= addr) {
25555 + vma = find_vma(mm, addr);
25556 + if (check_heap_stack_gap(vma, addr, len, offset))
25557 + return addr;
25558 + }
25559 + }
25560 +
25561 + info.flags = 0;
25562 + info.length = len;
25563 + info.align_mask = filp ? get_align_mask() : 0;
25564 + info.align_offset = pgoff << PAGE_SHIFT;
25565 + info.threadstack_offset = offset;
25566 +
25567 +#ifdef CONFIG_PAX_PAGEEXEC
25568 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
25569 + info.low_limit = 0x00110000UL;
25570 + info.high_limit = mm->start_code;
25571 +
25572 +#ifdef CONFIG_PAX_RANDMMAP
25573 + if (mm->pax_flags & MF_PAX_RANDMMAP)
25574 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
25575 +#endif
25576 +
25577 + if (info.low_limit < info.high_limit) {
25578 + addr = vm_unmapped_area(&info);
25579 + if (!IS_ERR_VALUE(addr))
25580 + return addr;
25581 + }
25582 + } else
25583 +#endif
25584 +
25585 + info.low_limit = mm->mmap_base;
25586 + info.high_limit = pax_task_size;
25587 +
25588 + return vm_unmapped_area(&info);
25589 +}
25590 +
25591 +unsigned long
25592 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25593 + const unsigned long len, const unsigned long pgoff,
25594 + const unsigned long flags)
25595 +{
25596 + struct vm_area_struct *vma;
25597 + struct mm_struct *mm = current->mm;
25598 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
25599 + struct vm_unmapped_area_info info;
25600 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25601 +
25602 +#ifdef CONFIG_PAX_SEGMEXEC
25603 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
25604 + pax_task_size = SEGMEXEC_TASK_SIZE;
25605 +#endif
25606 +
25607 + pax_task_size -= PAGE_SIZE;
25608 +
25609 + /* requested length too big for entire address space */
25610 + if (len > pax_task_size)
25611 + return -ENOMEM;
25612 +
25613 + if (flags & MAP_FIXED)
25614 + return addr;
25615 +
25616 +#ifdef CONFIG_PAX_PAGEEXEC
25617 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
25618 + goto bottomup;
25619 +#endif
25620 +
25621 +#ifdef CONFIG_PAX_RANDMMAP
25622 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25623 +#endif
25624 +
25625 + /* requesting a specific address */
25626 + if (addr) {
25627 + addr = PAGE_ALIGN(addr);
25628 + if (pax_task_size - len >= addr) {
25629 + vma = find_vma(mm, addr);
25630 + if (check_heap_stack_gap(vma, addr, len, offset))
25631 + return addr;
25632 + }
25633 + }
25634 +
25635 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
25636 + info.length = len;
25637 + info.low_limit = PAGE_SIZE;
25638 + info.high_limit = mm->mmap_base;
25639 + info.align_mask = filp ? get_align_mask() : 0;
25640 + info.align_offset = pgoff << PAGE_SHIFT;
25641 + info.threadstack_offset = offset;
25642 +
25643 + addr = vm_unmapped_area(&info);
25644 + if (!(addr & ~PAGE_MASK))
25645 + return addr;
25646 + VM_BUG_ON(addr != -ENOMEM);
25647 +
25648 +bottomup:
25649 + /*
25650 + * A failed mmap() very likely causes application failure,
25651 + * so fall back to the bottom-up function here. This scenario
25652 + * can happen with large stack limits and large mmap()
25653 + * allocations.
25654 + */
25655 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
25656 +}
25657 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
25658 index 30277e2..5664a29 100644
25659 --- a/arch/x86/kernel/sys_x86_64.c
25660 +++ b/arch/x86/kernel/sys_x86_64.c
25661 @@ -81,8 +81,8 @@ out:
25662 return error;
25663 }
25664
25665 -static void find_start_end(unsigned long flags, unsigned long *begin,
25666 - unsigned long *end)
25667 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
25668 + unsigned long *begin, unsigned long *end)
25669 {
25670 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
25671 unsigned long new_begin;
25672 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
25673 *begin = new_begin;
25674 }
25675 } else {
25676 - *begin = current->mm->mmap_legacy_base;
25677 + *begin = mm->mmap_legacy_base;
25678 *end = TASK_SIZE;
25679 }
25680 }
25681 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25682 struct vm_area_struct *vma;
25683 struct vm_unmapped_area_info info;
25684 unsigned long begin, end;
25685 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25686
25687 if (flags & MAP_FIXED)
25688 return addr;
25689
25690 - find_start_end(flags, &begin, &end);
25691 + find_start_end(mm, flags, &begin, &end);
25692
25693 if (len > end)
25694 return -ENOMEM;
25695
25696 +#ifdef CONFIG_PAX_RANDMMAP
25697 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25698 +#endif
25699 +
25700 if (addr) {
25701 addr = PAGE_ALIGN(addr);
25702 vma = find_vma(mm, addr);
25703 - if (end - len >= addr &&
25704 - (!vma || addr + len <= vma->vm_start))
25705 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25706 return addr;
25707 }
25708
25709 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
25710 info.high_limit = end;
25711 info.align_mask = filp ? get_align_mask() : 0;
25712 info.align_offset = pgoff << PAGE_SHIFT;
25713 + info.threadstack_offset = offset;
25714 return vm_unmapped_area(&info);
25715 }
25716
25717 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25718 struct mm_struct *mm = current->mm;
25719 unsigned long addr = addr0;
25720 struct vm_unmapped_area_info info;
25721 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
25722
25723 /* requested length too big for entire address space */
25724 if (len > TASK_SIZE)
25725 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25726 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
25727 goto bottomup;
25728
25729 +#ifdef CONFIG_PAX_RANDMMAP
25730 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
25731 +#endif
25732 +
25733 /* requesting a specific address */
25734 if (addr) {
25735 addr = PAGE_ALIGN(addr);
25736 vma = find_vma(mm, addr);
25737 - if (TASK_SIZE - len >= addr &&
25738 - (!vma || addr + len <= vma->vm_start))
25739 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
25740 return addr;
25741 }
25742
25743 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
25744 info.high_limit = mm->mmap_base;
25745 info.align_mask = filp ? get_align_mask() : 0;
25746 info.align_offset = pgoff << PAGE_SHIFT;
25747 + info.threadstack_offset = offset;
25748 addr = vm_unmapped_area(&info);
25749 if (!(addr & ~PAGE_MASK))
25750 return addr;
25751 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
25752 index addf7b5..f960685 100644
25753 --- a/arch/x86/kernel/tboot.c
25754 +++ b/arch/x86/kernel/tboot.c
25755 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
25756
25757 void tboot_shutdown(u32 shutdown_type)
25758 {
25759 - void (*shutdown)(void);
25760 + void (* __noreturn shutdown)(void);
25761
25762 if (!tboot_enabled())
25763 return;
25764 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
25765
25766 switch_to_tboot_pt();
25767
25768 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
25769 + shutdown = (void *)tboot->shutdown_entry;
25770 shutdown();
25771
25772 /* should not reach here */
25773 @@ -301,7 +301,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
25774 return 0;
25775 }
25776
25777 -static atomic_t ap_wfs_count;
25778 +static atomic_unchecked_t ap_wfs_count;
25779
25780 static int tboot_wait_for_aps(int num_aps)
25781 {
25782 @@ -325,9 +325,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
25783 {
25784 switch (action) {
25785 case CPU_DYING:
25786 - atomic_inc(&ap_wfs_count);
25787 + atomic_inc_unchecked(&ap_wfs_count);
25788 if (num_online_cpus() == 1)
25789 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
25790 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
25791 return NOTIFY_BAD;
25792 break;
25793 }
25794 @@ -413,7 +413,7 @@ static __init int tboot_late_init(void)
25795
25796 tboot_create_trampoline();
25797
25798 - atomic_set(&ap_wfs_count, 0);
25799 + atomic_set_unchecked(&ap_wfs_count, 0);
25800 register_hotcpu_notifier(&tboot_cpu_notifier);
25801
25802 #ifdef CONFIG_DEBUG_FS
25803 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
25804 index 24d3c91..d06b473 100644
25805 --- a/arch/x86/kernel/time.c
25806 +++ b/arch/x86/kernel/time.c
25807 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
25808 {
25809 unsigned long pc = instruction_pointer(regs);
25810
25811 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
25812 + if (!user_mode(regs) && in_lock_functions(pc)) {
25813 #ifdef CONFIG_FRAME_POINTER
25814 - return *(unsigned long *)(regs->bp + sizeof(long));
25815 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
25816 #else
25817 unsigned long *sp =
25818 (unsigned long *)kernel_stack_pointer(regs);
25819 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
25820 * or above a saved flags. Eflags has bits 22-31 zero,
25821 * kernel addresses don't.
25822 */
25823 +
25824 +#ifdef CONFIG_PAX_KERNEXEC
25825 + return ktla_ktva(sp[0]);
25826 +#else
25827 if (sp[0] >> 22)
25828 return sp[0];
25829 if (sp[1] >> 22)
25830 return sp[1];
25831 #endif
25832 +
25833 +#endif
25834 }
25835 return pc;
25836 }
25837 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
25838 index f7fec09..9991981 100644
25839 --- a/arch/x86/kernel/tls.c
25840 +++ b/arch/x86/kernel/tls.c
25841 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
25842 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
25843 return -EINVAL;
25844
25845 +#ifdef CONFIG_PAX_SEGMEXEC
25846 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
25847 + return -EINVAL;
25848 +#endif
25849 +
25850 set_tls_desc(p, idx, &info, 1);
25851
25852 return 0;
25853 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
25854
25855 if (kbuf)
25856 info = kbuf;
25857 - else if (__copy_from_user(infobuf, ubuf, count))
25858 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
25859 return -EFAULT;
25860 else
25861 info = infobuf;
25862 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
25863 index 1c113db..287b42e 100644
25864 --- a/arch/x86/kernel/tracepoint.c
25865 +++ b/arch/x86/kernel/tracepoint.c
25866 @@ -9,11 +9,11 @@
25867 #include <linux/atomic.h>
25868
25869 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
25870 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25871 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
25872 (unsigned long) trace_idt_table };
25873
25874 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25875 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
25876 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
25877
25878 static int trace_irq_vector_refcount;
25879 static DEFINE_MUTEX(irq_vector_mutex);
25880 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
25881 index 1b23a1c..910de0d 100644
25882 --- a/arch/x86/kernel/traps.c
25883 +++ b/arch/x86/kernel/traps.c
25884 @@ -65,7 +65,7 @@
25885 #include <asm/proto.h>
25886
25887 /* No need to be aligned, but done to keep all IDTs defined the same way. */
25888 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
25889 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
25890 #else
25891 #include <asm/processor-flags.h>
25892 #include <asm/setup.h>
25893 @@ -74,7 +74,7 @@ asmlinkage int system_call(void);
25894 #endif
25895
25896 /* Must be page-aligned because the real IDT is used in a fixmap. */
25897 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
25898 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
25899
25900 DECLARE_BITMAP(used_vectors, NR_VECTORS);
25901 EXPORT_SYMBOL_GPL(used_vectors);
25902 @@ -106,11 +106,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
25903 }
25904
25905 static int __kprobes
25906 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25907 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
25908 struct pt_regs *regs, long error_code)
25909 {
25910 #ifdef CONFIG_X86_32
25911 - if (regs->flags & X86_VM_MASK) {
25912 + if (v8086_mode(regs)) {
25913 /*
25914 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
25915 * On nmi (interrupt 2), do_trap should not be called.
25916 @@ -123,12 +123,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25917 return -1;
25918 }
25919 #endif
25920 - if (!user_mode(regs)) {
25921 + if (!user_mode_novm(regs)) {
25922 if (!fixup_exception(regs)) {
25923 tsk->thread.error_code = error_code;
25924 tsk->thread.trap_nr = trapnr;
25925 +
25926 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25927 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
25928 + str = "PAX: suspicious stack segment fault";
25929 +#endif
25930 +
25931 die(str, regs, error_code);
25932 }
25933 +
25934 +#ifdef CONFIG_PAX_REFCOUNT
25935 + if (trapnr == 4)
25936 + pax_report_refcount_overflow(regs);
25937 +#endif
25938 +
25939 return 0;
25940 }
25941
25942 @@ -136,7 +148,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25943 }
25944
25945 static void __kprobes
25946 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25947 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25948 long error_code, siginfo_t *info)
25949 {
25950 struct task_struct *tsk = current;
25951 @@ -160,7 +172,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25952 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25953 printk_ratelimit()) {
25954 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25955 - tsk->comm, tsk->pid, str,
25956 + tsk->comm, task_pid_nr(tsk), str,
25957 regs->ip, regs->sp, error_code);
25958 print_vma_addr(" in ", regs->ip);
25959 pr_cont("\n");
25960 @@ -276,7 +288,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25961 conditional_sti(regs);
25962
25963 #ifdef CONFIG_X86_32
25964 - if (regs->flags & X86_VM_MASK) {
25965 + if (v8086_mode(regs)) {
25966 local_irq_enable();
25967 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25968 goto exit;
25969 @@ -284,18 +296,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25970 #endif
25971
25972 tsk = current;
25973 - if (!user_mode(regs)) {
25974 + if (!user_mode_novm(regs)) {
25975 if (fixup_exception(regs))
25976 goto exit;
25977
25978 tsk->thread.error_code = error_code;
25979 tsk->thread.trap_nr = X86_TRAP_GP;
25980 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25981 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25982 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25983 +
25984 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25985 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25986 + die("PAX: suspicious general protection fault", regs, error_code);
25987 + else
25988 +#endif
25989 +
25990 die("general protection fault", regs, error_code);
25991 + }
25992 goto exit;
25993 }
25994
25995 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25996 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25997 + struct mm_struct *mm = tsk->mm;
25998 + unsigned long limit;
25999 +
26000 + down_write(&mm->mmap_sem);
26001 + limit = mm->context.user_cs_limit;
26002 + if (limit < TASK_SIZE) {
26003 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26004 + up_write(&mm->mmap_sem);
26005 + return;
26006 + }
26007 + up_write(&mm->mmap_sem);
26008 + }
26009 +#endif
26010 +
26011 tsk->thread.error_code = error_code;
26012 tsk->thread.trap_nr = X86_TRAP_GP;
26013
26014 @@ -453,7 +489,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26015 /* It's safe to allow irq's after DR6 has been saved */
26016 preempt_conditional_sti(regs);
26017
26018 - if (regs->flags & X86_VM_MASK) {
26019 + if (v8086_mode(regs)) {
26020 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26021 X86_TRAP_DB);
26022 preempt_conditional_cli(regs);
26023 @@ -468,7 +504,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26024 * We already checked v86 mode above, so we can check for kernel mode
26025 * by just checking the CPL of CS.
26026 */
26027 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26028 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26029 tsk->thread.debugreg6 &= ~DR_STEP;
26030 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26031 regs->flags &= ~X86_EFLAGS_TF;
26032 @@ -500,7 +536,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26033 return;
26034 conditional_sti(regs);
26035
26036 - if (!user_mode_vm(regs))
26037 + if (!user_mode(regs))
26038 {
26039 if (!fixup_exception(regs)) {
26040 task->thread.error_code = error_code;
26041 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26042 index 2ed8459..7cf329f 100644
26043 --- a/arch/x86/kernel/uprobes.c
26044 +++ b/arch/x86/kernel/uprobes.c
26045 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26046 int ret = NOTIFY_DONE;
26047
26048 /* We are only interested in userspace traps */
26049 - if (regs && !user_mode_vm(regs))
26050 + if (regs && !user_mode(regs))
26051 return NOTIFY_DONE;
26052
26053 switch (val) {
26054 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26055
26056 if (ncopied != rasize) {
26057 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26058 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26059 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26060
26061 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26062 }
26063 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26064 index b9242ba..50c5edd 100644
26065 --- a/arch/x86/kernel/verify_cpu.S
26066 +++ b/arch/x86/kernel/verify_cpu.S
26067 @@ -20,6 +20,7 @@
26068 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26069 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26070 * arch/x86/kernel/head_32.S: processor startup
26071 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26072 *
26073 * verify_cpu, returns the status of longmode and SSE in register %eax.
26074 * 0: Success 1: Failure
26075 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26076 index e8edcf5..27f9344 100644
26077 --- a/arch/x86/kernel/vm86_32.c
26078 +++ b/arch/x86/kernel/vm86_32.c
26079 @@ -44,6 +44,7 @@
26080 #include <linux/ptrace.h>
26081 #include <linux/audit.h>
26082 #include <linux/stddef.h>
26083 +#include <linux/grsecurity.h>
26084
26085 #include <asm/uaccess.h>
26086 #include <asm/io.h>
26087 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26088 do_exit(SIGSEGV);
26089 }
26090
26091 - tss = &per_cpu(init_tss, get_cpu());
26092 + tss = init_tss + get_cpu();
26093 current->thread.sp0 = current->thread.saved_sp0;
26094 current->thread.sysenter_cs = __KERNEL_CS;
26095 load_sp0(tss, &current->thread);
26096 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26097
26098 if (tsk->thread.saved_sp0)
26099 return -EPERM;
26100 +
26101 +#ifdef CONFIG_GRKERNSEC_VM86
26102 + if (!capable(CAP_SYS_RAWIO)) {
26103 + gr_handle_vm86();
26104 + return -EPERM;
26105 + }
26106 +#endif
26107 +
26108 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26109 offsetof(struct kernel_vm86_struct, vm86plus) -
26110 sizeof(info.regs));
26111 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26112 int tmp;
26113 struct vm86plus_struct __user *v86;
26114
26115 +#ifdef CONFIG_GRKERNSEC_VM86
26116 + if (!capable(CAP_SYS_RAWIO)) {
26117 + gr_handle_vm86();
26118 + return -EPERM;
26119 + }
26120 +#endif
26121 +
26122 tsk = current;
26123 switch (cmd) {
26124 case VM86_REQUEST_IRQ:
26125 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26126 tsk->thread.saved_fs = info->regs32->fs;
26127 tsk->thread.saved_gs = get_user_gs(info->regs32);
26128
26129 - tss = &per_cpu(init_tss, get_cpu());
26130 + tss = init_tss + get_cpu();
26131 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26132 if (cpu_has_sep)
26133 tsk->thread.sysenter_cs = 0;
26134 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26135 goto cannot_handle;
26136 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26137 goto cannot_handle;
26138 - intr_ptr = (unsigned long __user *) (i << 2);
26139 + intr_ptr = (__force unsigned long __user *) (i << 2);
26140 if (get_user(segoffs, intr_ptr))
26141 goto cannot_handle;
26142 if ((segoffs >> 16) == BIOSSEG)
26143 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26144 index 10c4f30..65408b9 100644
26145 --- a/arch/x86/kernel/vmlinux.lds.S
26146 +++ b/arch/x86/kernel/vmlinux.lds.S
26147 @@ -26,6 +26,13 @@
26148 #include <asm/page_types.h>
26149 #include <asm/cache.h>
26150 #include <asm/boot.h>
26151 +#include <asm/segment.h>
26152 +
26153 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26154 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26155 +#else
26156 +#define __KERNEL_TEXT_OFFSET 0
26157 +#endif
26158
26159 #undef i386 /* in case the preprocessor is a 32bit one */
26160
26161 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26162
26163 PHDRS {
26164 text PT_LOAD FLAGS(5); /* R_E */
26165 +#ifdef CONFIG_X86_32
26166 + module PT_LOAD FLAGS(5); /* R_E */
26167 +#endif
26168 +#ifdef CONFIG_XEN
26169 + rodata PT_LOAD FLAGS(5); /* R_E */
26170 +#else
26171 + rodata PT_LOAD FLAGS(4); /* R__ */
26172 +#endif
26173 data PT_LOAD FLAGS(6); /* RW_ */
26174 -#ifdef CONFIG_X86_64
26175 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26176 #ifdef CONFIG_SMP
26177 percpu PT_LOAD FLAGS(6); /* RW_ */
26178 #endif
26179 + text.init PT_LOAD FLAGS(5); /* R_E */
26180 + text.exit PT_LOAD FLAGS(5); /* R_E */
26181 init PT_LOAD FLAGS(7); /* RWE */
26182 -#endif
26183 note PT_NOTE FLAGS(0); /* ___ */
26184 }
26185
26186 SECTIONS
26187 {
26188 #ifdef CONFIG_X86_32
26189 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26190 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26191 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26192 #else
26193 - . = __START_KERNEL;
26194 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26195 + . = __START_KERNEL;
26196 #endif
26197
26198 /* Text and read-only data */
26199 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26200 - _text = .;
26201 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26202 /* bootstrapping code */
26203 +#ifdef CONFIG_X86_32
26204 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26205 +#else
26206 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26207 +#endif
26208 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26209 + _text = .;
26210 HEAD_TEXT
26211 . = ALIGN(8);
26212 _stext = .;
26213 @@ -104,13 +124,47 @@ SECTIONS
26214 IRQENTRY_TEXT
26215 *(.fixup)
26216 *(.gnu.warning)
26217 - /* End of text section */
26218 - _etext = .;
26219 } :text = 0x9090
26220
26221 - NOTES :text :note
26222 + . += __KERNEL_TEXT_OFFSET;
26223
26224 - EXCEPTION_TABLE(16) :text = 0x9090
26225 +#ifdef CONFIG_X86_32
26226 + . = ALIGN(PAGE_SIZE);
26227 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
26228 +
26229 +#ifdef CONFIG_PAX_KERNEXEC
26230 + MODULES_EXEC_VADDR = .;
26231 + BYTE(0)
26232 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
26233 + . = ALIGN(HPAGE_SIZE) - 1;
26234 + MODULES_EXEC_END = .;
26235 +#endif
26236 +
26237 + } :module
26238 +#endif
26239 +
26240 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
26241 + /* End of text section */
26242 + BYTE(0)
26243 + _etext = . - __KERNEL_TEXT_OFFSET;
26244 + }
26245 +
26246 +#ifdef CONFIG_X86_32
26247 + . = ALIGN(PAGE_SIZE);
26248 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
26249 + . = ALIGN(PAGE_SIZE);
26250 + *(.empty_zero_page)
26251 + *(.initial_pg_fixmap)
26252 + *(.initial_pg_pmd)
26253 + *(.initial_page_table)
26254 + *(.swapper_pg_dir)
26255 + } :rodata
26256 +#endif
26257 +
26258 + . = ALIGN(PAGE_SIZE);
26259 + NOTES :rodata :note
26260 +
26261 + EXCEPTION_TABLE(16) :rodata
26262
26263 #if defined(CONFIG_DEBUG_RODATA)
26264 /* .text should occupy whole number of pages */
26265 @@ -122,16 +176,20 @@ SECTIONS
26266
26267 /* Data */
26268 .data : AT(ADDR(.data) - LOAD_OFFSET) {
26269 +
26270 +#ifdef CONFIG_PAX_KERNEXEC
26271 + . = ALIGN(HPAGE_SIZE);
26272 +#else
26273 + . = ALIGN(PAGE_SIZE);
26274 +#endif
26275 +
26276 /* Start of data section */
26277 _sdata = .;
26278
26279 /* init_task */
26280 INIT_TASK_DATA(THREAD_SIZE)
26281
26282 -#ifdef CONFIG_X86_32
26283 - /* 32 bit has nosave before _edata */
26284 NOSAVE_DATA
26285 -#endif
26286
26287 PAGE_ALIGNED_DATA(PAGE_SIZE)
26288
26289 @@ -172,12 +230,19 @@ SECTIONS
26290 #endif /* CONFIG_X86_64 */
26291
26292 /* Init code and data - will be freed after init */
26293 - . = ALIGN(PAGE_SIZE);
26294 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
26295 + BYTE(0)
26296 +
26297 +#ifdef CONFIG_PAX_KERNEXEC
26298 + . = ALIGN(HPAGE_SIZE);
26299 +#else
26300 + . = ALIGN(PAGE_SIZE);
26301 +#endif
26302 +
26303 __init_begin = .; /* paired with __init_end */
26304 - }
26305 + } :init.begin
26306
26307 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
26308 +#ifdef CONFIG_SMP
26309 /*
26310 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
26311 * output PHDR, so the next output section - .init.text - should
26312 @@ -186,12 +251,27 @@ SECTIONS
26313 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
26314 #endif
26315
26316 - INIT_TEXT_SECTION(PAGE_SIZE)
26317 -#ifdef CONFIG_X86_64
26318 - :init
26319 -#endif
26320 + . = ALIGN(PAGE_SIZE);
26321 + init_begin = .;
26322 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
26323 + VMLINUX_SYMBOL(_sinittext) = .;
26324 + INIT_TEXT
26325 + VMLINUX_SYMBOL(_einittext) = .;
26326 + . = ALIGN(PAGE_SIZE);
26327 + } :text.init
26328
26329 - INIT_DATA_SECTION(16)
26330 + /*
26331 + * .exit.text is discard at runtime, not link time, to deal with
26332 + * references from .altinstructions and .eh_frame
26333 + */
26334 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26335 + EXIT_TEXT
26336 + . = ALIGN(16);
26337 + } :text.exit
26338 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
26339 +
26340 + . = ALIGN(PAGE_SIZE);
26341 + INIT_DATA_SECTION(16) :init
26342
26343 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
26344 __x86_cpu_dev_start = .;
26345 @@ -253,19 +333,12 @@ SECTIONS
26346 }
26347
26348 . = ALIGN(8);
26349 - /*
26350 - * .exit.text is discard at runtime, not link time, to deal with
26351 - * references from .altinstructions and .eh_frame
26352 - */
26353 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
26354 - EXIT_TEXT
26355 - }
26356
26357 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
26358 EXIT_DATA
26359 }
26360
26361 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
26362 +#ifndef CONFIG_SMP
26363 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
26364 #endif
26365
26366 @@ -284,16 +357,10 @@ SECTIONS
26367 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
26368 __smp_locks = .;
26369 *(.smp_locks)
26370 - . = ALIGN(PAGE_SIZE);
26371 __smp_locks_end = .;
26372 + . = ALIGN(PAGE_SIZE);
26373 }
26374
26375 -#ifdef CONFIG_X86_64
26376 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
26377 - NOSAVE_DATA
26378 - }
26379 -#endif
26380 -
26381 /* BSS */
26382 . = ALIGN(PAGE_SIZE);
26383 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
26384 @@ -309,6 +376,7 @@ SECTIONS
26385 __brk_base = .;
26386 . += 64 * 1024; /* 64k alignment slop space */
26387 *(.brk_reservation) /* areas brk users have reserved */
26388 + . = ALIGN(HPAGE_SIZE);
26389 __brk_limit = .;
26390 }
26391
26392 @@ -335,13 +403,12 @@ SECTIONS
26393 * for the boot processor.
26394 */
26395 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
26396 -INIT_PER_CPU(gdt_page);
26397 INIT_PER_CPU(irq_stack_union);
26398
26399 /*
26400 * Build-time check on the image size:
26401 */
26402 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
26403 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
26404 "kernel image bigger than KERNEL_IMAGE_SIZE");
26405
26406 #ifdef CONFIG_SMP
26407 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
26408 index 1f96f93..d5c8f7a 100644
26409 --- a/arch/x86/kernel/vsyscall_64.c
26410 +++ b/arch/x86/kernel/vsyscall_64.c
26411 @@ -56,15 +56,13 @@
26412 DEFINE_VVAR(int, vgetcpu_mode);
26413 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
26414
26415 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
26416 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
26417
26418 static int __init vsyscall_setup(char *str)
26419 {
26420 if (str) {
26421 if (!strcmp("emulate", str))
26422 vsyscall_mode = EMULATE;
26423 - else if (!strcmp("native", str))
26424 - vsyscall_mode = NATIVE;
26425 else if (!strcmp("none", str))
26426 vsyscall_mode = NONE;
26427 else
26428 @@ -323,8 +321,7 @@ do_ret:
26429 return true;
26430
26431 sigsegv:
26432 - force_sig(SIGSEGV, current);
26433 - return true;
26434 + do_group_exit(SIGKILL);
26435 }
26436
26437 /*
26438 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
26439 extern char __vvar_page;
26440 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
26441
26442 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
26443 - vsyscall_mode == NATIVE
26444 - ? PAGE_KERNEL_VSYSCALL
26445 - : PAGE_KERNEL_VVAR);
26446 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
26447 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
26448 (unsigned long)VSYSCALL_START);
26449
26450 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
26451 index b014d94..e775258 100644
26452 --- a/arch/x86/kernel/x8664_ksyms_64.c
26453 +++ b/arch/x86/kernel/x8664_ksyms_64.c
26454 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
26455 EXPORT_SYMBOL(copy_user_generic_unrolled);
26456 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
26457 EXPORT_SYMBOL(__copy_user_nocache);
26458 -EXPORT_SYMBOL(_copy_from_user);
26459 -EXPORT_SYMBOL(_copy_to_user);
26460
26461 EXPORT_SYMBOL(copy_page);
26462 EXPORT_SYMBOL(clear_page);
26463 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
26464 #ifndef CONFIG_PARAVIRT
26465 EXPORT_SYMBOL(native_load_gs_index);
26466 #endif
26467 +
26468 +#ifdef CONFIG_PAX_PER_CPU_PGD
26469 +EXPORT_SYMBOL(cpu_pgd);
26470 +#endif
26471 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
26472 index 5f24c71..1dadf09 100644
26473 --- a/arch/x86/kernel/x86_init.c
26474 +++ b/arch/x86/kernel/x86_init.c
26475 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
26476 static void default_nmi_init(void) { };
26477 static int default_i8042_detect(void) { return 1; };
26478
26479 -struct x86_platform_ops x86_platform = {
26480 +struct x86_platform_ops x86_platform __read_only = {
26481 .calibrate_tsc = native_calibrate_tsc,
26482 .get_wallclock = mach_get_cmos_time,
26483 .set_wallclock = mach_set_rtc_mmss,
26484 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
26485 };
26486
26487 EXPORT_SYMBOL_GPL(x86_platform);
26488 -struct x86_msi_ops x86_msi = {
26489 +struct x86_msi_ops x86_msi __read_only = {
26490 .setup_msi_irqs = native_setup_msi_irqs,
26491 .compose_msi_msg = native_compose_msi_msg,
26492 .teardown_msi_irq = native_teardown_msi_irq,
26493 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
26494 .setup_hpet_msi = default_setup_hpet_msi,
26495 };
26496
26497 -struct x86_io_apic_ops x86_io_apic_ops = {
26498 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
26499 .init = native_io_apic_init_mappings,
26500 .read = native_io_apic_read,
26501 .write = native_io_apic_write,
26502 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
26503 index 422fd82..c3687ca 100644
26504 --- a/arch/x86/kernel/xsave.c
26505 +++ b/arch/x86/kernel/xsave.c
26506 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
26507 {
26508 int err;
26509
26510 + buf = (struct xsave_struct __user *)____m(buf);
26511 if (use_xsave())
26512 err = xsave_user(buf);
26513 else if (use_fxsr())
26514 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
26515 */
26516 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
26517 {
26518 + buf = (void __user *)____m(buf);
26519 if (use_xsave()) {
26520 if ((unsigned long)buf % 64 || fx_only) {
26521 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
26522 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
26523 index a20ecb5..d0e2194 100644
26524 --- a/arch/x86/kvm/cpuid.c
26525 +++ b/arch/x86/kvm/cpuid.c
26526 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
26527 struct kvm_cpuid2 *cpuid,
26528 struct kvm_cpuid_entry2 __user *entries)
26529 {
26530 - int r;
26531 + int r, i;
26532
26533 r = -E2BIG;
26534 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
26535 goto out;
26536 r = -EFAULT;
26537 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
26538 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26539 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
26540 goto out;
26541 + for (i = 0; i < cpuid->nent; ++i) {
26542 + struct kvm_cpuid_entry2 cpuid_entry;
26543 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
26544 + goto out;
26545 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
26546 + }
26547 vcpu->arch.cpuid_nent = cpuid->nent;
26548 kvm_apic_set_version(vcpu);
26549 kvm_x86_ops->cpuid_update(vcpu);
26550 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
26551 struct kvm_cpuid2 *cpuid,
26552 struct kvm_cpuid_entry2 __user *entries)
26553 {
26554 - int r;
26555 + int r, i;
26556
26557 r = -E2BIG;
26558 if (cpuid->nent < vcpu->arch.cpuid_nent)
26559 goto out;
26560 r = -EFAULT;
26561 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
26562 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26563 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
26564 goto out;
26565 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
26566 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
26567 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
26568 + goto out;
26569 + }
26570 return 0;
26571
26572 out:
26573 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
26574 index afc1124..3e431f2 100644
26575 --- a/arch/x86/kvm/lapic.c
26576 +++ b/arch/x86/kvm/lapic.c
26577 @@ -55,7 +55,7 @@
26578 #define APIC_BUS_CYCLE_NS 1
26579
26580 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
26581 -#define apic_debug(fmt, arg...)
26582 +#define apic_debug(fmt, arg...) do {} while (0)
26583
26584 #define APIC_LVT_NUM 6
26585 /* 14 is the version for Xeon and Pentium 8.4.8*/
26586 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
26587 index 7769699..c8aca4a7f 100644
26588 --- a/arch/x86/kvm/paging_tmpl.h
26589 +++ b/arch/x86/kvm/paging_tmpl.h
26590 @@ -208,7 +208,7 @@ retry_walk:
26591 if (unlikely(kvm_is_error_hva(host_addr)))
26592 goto error;
26593
26594 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
26595 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
26596 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
26597 goto error;
26598 walker->ptep_user[walker->level - 1] = ptep_user;
26599 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
26600 index c0bc803..6837a50 100644
26601 --- a/arch/x86/kvm/svm.c
26602 +++ b/arch/x86/kvm/svm.c
26603 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
26604 int cpu = raw_smp_processor_id();
26605
26606 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
26607 +
26608 + pax_open_kernel();
26609 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
26610 + pax_close_kernel();
26611 +
26612 load_TR_desc();
26613 }
26614
26615 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
26616 #endif
26617 #endif
26618
26619 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26620 + __set_fs(current_thread_info()->addr_limit);
26621 +#endif
26622 +
26623 reload_tss(vcpu);
26624
26625 local_irq_disable();
26626 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
26627 index 064d0be..f5f758e 100644
26628 --- a/arch/x86/kvm/vmx.c
26629 +++ b/arch/x86/kvm/vmx.c
26630 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
26631 #endif
26632 }
26633
26634 -static void vmcs_clear_bits(unsigned long field, u32 mask)
26635 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
26636 {
26637 vmcs_writel(field, vmcs_readl(field) & ~mask);
26638 }
26639
26640 -static void vmcs_set_bits(unsigned long field, u32 mask)
26641 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
26642 {
26643 vmcs_writel(field, vmcs_readl(field) | mask);
26644 }
26645 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
26646 struct desc_struct *descs;
26647
26648 descs = (void *)gdt->address;
26649 +
26650 + pax_open_kernel();
26651 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
26652 + pax_close_kernel();
26653 +
26654 load_TR_desc();
26655 }
26656
26657 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
26658 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
26659 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
26660
26661 +#ifdef CONFIG_PAX_PER_CPU_PGD
26662 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26663 +#endif
26664 +
26665 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
26666 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
26667 vmx->loaded_vmcs->cpu = cpu;
26668 @@ -2940,8 +2948,11 @@ static __init int hardware_setup(void)
26669 if (!cpu_has_vmx_flexpriority())
26670 flexpriority_enabled = 0;
26671
26672 - if (!cpu_has_vmx_tpr_shadow())
26673 - kvm_x86_ops->update_cr8_intercept = NULL;
26674 + if (!cpu_has_vmx_tpr_shadow()) {
26675 + pax_open_kernel();
26676 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26677 + pax_close_kernel();
26678 + }
26679
26680 if (enable_ept && !cpu_has_vmx_ept_2m_page())
26681 kvm_disable_largepages();
26682 @@ -2952,13 +2963,15 @@ static __init int hardware_setup(void)
26683 if (!cpu_has_vmx_apicv())
26684 enable_apicv = 0;
26685
26686 + pax_open_kernel();
26687 if (enable_apicv)
26688 - kvm_x86_ops->update_cr8_intercept = NULL;
26689 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
26690 else {
26691 - kvm_x86_ops->hwapic_irr_update = NULL;
26692 - kvm_x86_ops->deliver_posted_interrupt = NULL;
26693 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26694 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
26695 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
26696 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
26697 }
26698 + pax_close_kernel();
26699
26700 if (nested)
26701 nested_vmx_setup_ctls_msrs();
26702 @@ -4081,7 +4094,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26703
26704 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
26705 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
26706 +
26707 +#ifndef CONFIG_PAX_PER_CPU_PGD
26708 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
26709 +#endif
26710
26711 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
26712 #ifdef CONFIG_X86_64
26713 @@ -4103,7 +4119,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
26714 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
26715 vmx->host_idt_base = dt.address;
26716
26717 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
26718 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
26719
26720 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
26721 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
26722 @@ -7039,6 +7055,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26723 "jmp 2f \n\t"
26724 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
26725 "2: "
26726 +
26727 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26728 + "ljmp %[cs],$3f\n\t"
26729 + "3: "
26730 +#endif
26731 +
26732 /* Save guest registers, load host registers, keep flags */
26733 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
26734 "pop %0 \n\t"
26735 @@ -7091,6 +7113,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26736 #endif
26737 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
26738 [wordsize]"i"(sizeof(ulong))
26739 +
26740 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26741 + ,[cs]"i"(__KERNEL_CS)
26742 +#endif
26743 +
26744 : "cc", "memory"
26745 #ifdef CONFIG_X86_64
26746 , "rax", "rbx", "rdi", "rsi"
26747 @@ -7104,7 +7131,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26748 if (debugctlmsr)
26749 update_debugctlmsr(debugctlmsr);
26750
26751 -#ifndef CONFIG_X86_64
26752 +#ifdef CONFIG_X86_32
26753 /*
26754 * The sysexit path does not restore ds/es, so we must set them to
26755 * a reasonable value ourselves.
26756 @@ -7113,8 +7140,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
26757 * may be executed in interrupt context, which saves and restore segments
26758 * around it, nullifying its effect.
26759 */
26760 - loadsegment(ds, __USER_DS);
26761 - loadsegment(es, __USER_DS);
26762 + loadsegment(ds, __KERNEL_DS);
26763 + loadsegment(es, __KERNEL_DS);
26764 + loadsegment(ss, __KERNEL_DS);
26765 +
26766 +#ifdef CONFIG_PAX_KERNEXEC
26767 + loadsegment(fs, __KERNEL_PERCPU);
26768 +#endif
26769 +
26770 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26771 + __set_fs(current_thread_info()->addr_limit);
26772 +#endif
26773 +
26774 #endif
26775
26776 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
26777 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
26778 index d21bce5..fdae9f1 100644
26779 --- a/arch/x86/kvm/x86.c
26780 +++ b/arch/x86/kvm/x86.c
26781 @@ -1766,8 +1766,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
26782 {
26783 struct kvm *kvm = vcpu->kvm;
26784 int lm = is_long_mode(vcpu);
26785 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26786 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26787 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
26788 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
26789 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
26790 : kvm->arch.xen_hvm_config.blob_size_32;
26791 u32 page_num = data & ~PAGE_MASK;
26792 @@ -2650,6 +2650,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
26793 if (n < msr_list.nmsrs)
26794 goto out;
26795 r = -EFAULT;
26796 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
26797 + goto out;
26798 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
26799 num_msrs_to_save * sizeof(u32)))
26800 goto out;
26801 @@ -5344,7 +5346,7 @@ static struct notifier_block pvclock_gtod_notifier = {
26802 };
26803 #endif
26804
26805 -int kvm_arch_init(void *opaque)
26806 +int kvm_arch_init(const void *opaque)
26807 {
26808 int r;
26809 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
26810 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
26811 index 6a22c19..1763f04 100644
26812 --- a/arch/x86/lguest/boot.c
26813 +++ b/arch/x86/lguest/boot.c
26814 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
26815 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
26816 * Launcher to reboot us.
26817 */
26818 -static void lguest_restart(char *reason)
26819 +static __noreturn void lguest_restart(char *reason)
26820 {
26821 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
26822 + BUG();
26823 }
26824
26825 /*G:050
26826 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
26827 index 00933d5..3a64af9 100644
26828 --- a/arch/x86/lib/atomic64_386_32.S
26829 +++ b/arch/x86/lib/atomic64_386_32.S
26830 @@ -48,6 +48,10 @@ BEGIN(read)
26831 movl (v), %eax
26832 movl 4(v), %edx
26833 RET_ENDP
26834 +BEGIN(read_unchecked)
26835 + movl (v), %eax
26836 + movl 4(v), %edx
26837 +RET_ENDP
26838 #undef v
26839
26840 #define v %esi
26841 @@ -55,6 +59,10 @@ BEGIN(set)
26842 movl %ebx, (v)
26843 movl %ecx, 4(v)
26844 RET_ENDP
26845 +BEGIN(set_unchecked)
26846 + movl %ebx, (v)
26847 + movl %ecx, 4(v)
26848 +RET_ENDP
26849 #undef v
26850
26851 #define v %esi
26852 @@ -70,6 +78,20 @@ RET_ENDP
26853 BEGIN(add)
26854 addl %eax, (v)
26855 adcl %edx, 4(v)
26856 +
26857 +#ifdef CONFIG_PAX_REFCOUNT
26858 + jno 0f
26859 + subl %eax, (v)
26860 + sbbl %edx, 4(v)
26861 + int $4
26862 +0:
26863 + _ASM_EXTABLE(0b, 0b)
26864 +#endif
26865 +
26866 +RET_ENDP
26867 +BEGIN(add_unchecked)
26868 + addl %eax, (v)
26869 + adcl %edx, 4(v)
26870 RET_ENDP
26871 #undef v
26872
26873 @@ -77,6 +99,24 @@ RET_ENDP
26874 BEGIN(add_return)
26875 addl (v), %eax
26876 adcl 4(v), %edx
26877 +
26878 +#ifdef CONFIG_PAX_REFCOUNT
26879 + into
26880 +1234:
26881 + _ASM_EXTABLE(1234b, 2f)
26882 +#endif
26883 +
26884 + movl %eax, (v)
26885 + movl %edx, 4(v)
26886 +
26887 +#ifdef CONFIG_PAX_REFCOUNT
26888 +2:
26889 +#endif
26890 +
26891 +RET_ENDP
26892 +BEGIN(add_return_unchecked)
26893 + addl (v), %eax
26894 + adcl 4(v), %edx
26895 movl %eax, (v)
26896 movl %edx, 4(v)
26897 RET_ENDP
26898 @@ -86,6 +126,20 @@ RET_ENDP
26899 BEGIN(sub)
26900 subl %eax, (v)
26901 sbbl %edx, 4(v)
26902 +
26903 +#ifdef CONFIG_PAX_REFCOUNT
26904 + jno 0f
26905 + addl %eax, (v)
26906 + adcl %edx, 4(v)
26907 + int $4
26908 +0:
26909 + _ASM_EXTABLE(0b, 0b)
26910 +#endif
26911 +
26912 +RET_ENDP
26913 +BEGIN(sub_unchecked)
26914 + subl %eax, (v)
26915 + sbbl %edx, 4(v)
26916 RET_ENDP
26917 #undef v
26918
26919 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26920 sbbl $0, %edx
26921 addl (v), %eax
26922 adcl 4(v), %edx
26923 +
26924 +#ifdef CONFIG_PAX_REFCOUNT
26925 + into
26926 +1234:
26927 + _ASM_EXTABLE(1234b, 2f)
26928 +#endif
26929 +
26930 + movl %eax, (v)
26931 + movl %edx, 4(v)
26932 +
26933 +#ifdef CONFIG_PAX_REFCOUNT
26934 +2:
26935 +#endif
26936 +
26937 +RET_ENDP
26938 +BEGIN(sub_return_unchecked)
26939 + negl %edx
26940 + negl %eax
26941 + sbbl $0, %edx
26942 + addl (v), %eax
26943 + adcl 4(v), %edx
26944 movl %eax, (v)
26945 movl %edx, 4(v)
26946 RET_ENDP
26947 @@ -105,6 +180,20 @@ RET_ENDP
26948 BEGIN(inc)
26949 addl $1, (v)
26950 adcl $0, 4(v)
26951 +
26952 +#ifdef CONFIG_PAX_REFCOUNT
26953 + jno 0f
26954 + subl $1, (v)
26955 + sbbl $0, 4(v)
26956 + int $4
26957 +0:
26958 + _ASM_EXTABLE(0b, 0b)
26959 +#endif
26960 +
26961 +RET_ENDP
26962 +BEGIN(inc_unchecked)
26963 + addl $1, (v)
26964 + adcl $0, 4(v)
26965 RET_ENDP
26966 #undef v
26967
26968 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26969 movl 4(v), %edx
26970 addl $1, %eax
26971 adcl $0, %edx
26972 +
26973 +#ifdef CONFIG_PAX_REFCOUNT
26974 + into
26975 +1234:
26976 + _ASM_EXTABLE(1234b, 2f)
26977 +#endif
26978 +
26979 + movl %eax, (v)
26980 + movl %edx, 4(v)
26981 +
26982 +#ifdef CONFIG_PAX_REFCOUNT
26983 +2:
26984 +#endif
26985 +
26986 +RET_ENDP
26987 +BEGIN(inc_return_unchecked)
26988 + movl (v), %eax
26989 + movl 4(v), %edx
26990 + addl $1, %eax
26991 + adcl $0, %edx
26992 movl %eax, (v)
26993 movl %edx, 4(v)
26994 RET_ENDP
26995 @@ -123,6 +232,20 @@ RET_ENDP
26996 BEGIN(dec)
26997 subl $1, (v)
26998 sbbl $0, 4(v)
26999 +
27000 +#ifdef CONFIG_PAX_REFCOUNT
27001 + jno 0f
27002 + addl $1, (v)
27003 + adcl $0, 4(v)
27004 + int $4
27005 +0:
27006 + _ASM_EXTABLE(0b, 0b)
27007 +#endif
27008 +
27009 +RET_ENDP
27010 +BEGIN(dec_unchecked)
27011 + subl $1, (v)
27012 + sbbl $0, 4(v)
27013 RET_ENDP
27014 #undef v
27015
27016 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27017 movl 4(v), %edx
27018 subl $1, %eax
27019 sbbl $0, %edx
27020 +
27021 +#ifdef CONFIG_PAX_REFCOUNT
27022 + into
27023 +1234:
27024 + _ASM_EXTABLE(1234b, 2f)
27025 +#endif
27026 +
27027 + movl %eax, (v)
27028 + movl %edx, 4(v)
27029 +
27030 +#ifdef CONFIG_PAX_REFCOUNT
27031 +2:
27032 +#endif
27033 +
27034 +RET_ENDP
27035 +BEGIN(dec_return_unchecked)
27036 + movl (v), %eax
27037 + movl 4(v), %edx
27038 + subl $1, %eax
27039 + sbbl $0, %edx
27040 movl %eax, (v)
27041 movl %edx, 4(v)
27042 RET_ENDP
27043 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27044 adcl %edx, %edi
27045 addl (v), %eax
27046 adcl 4(v), %edx
27047 +
27048 +#ifdef CONFIG_PAX_REFCOUNT
27049 + into
27050 +1234:
27051 + _ASM_EXTABLE(1234b, 2f)
27052 +#endif
27053 +
27054 cmpl %eax, %ecx
27055 je 3f
27056 1:
27057 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27058 1:
27059 addl $1, %eax
27060 adcl $0, %edx
27061 +
27062 +#ifdef CONFIG_PAX_REFCOUNT
27063 + into
27064 +1234:
27065 + _ASM_EXTABLE(1234b, 2f)
27066 +#endif
27067 +
27068 movl %eax, (v)
27069 movl %edx, 4(v)
27070 movl $1, %eax
27071 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27072 movl 4(v), %edx
27073 subl $1, %eax
27074 sbbl $0, %edx
27075 +
27076 +#ifdef CONFIG_PAX_REFCOUNT
27077 + into
27078 +1234:
27079 + _ASM_EXTABLE(1234b, 1f)
27080 +#endif
27081 +
27082 js 1f
27083 movl %eax, (v)
27084 movl %edx, 4(v)
27085 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27086 index f5cc9eb..51fa319 100644
27087 --- a/arch/x86/lib/atomic64_cx8_32.S
27088 +++ b/arch/x86/lib/atomic64_cx8_32.S
27089 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27090 CFI_STARTPROC
27091
27092 read64 %ecx
27093 + pax_force_retaddr
27094 ret
27095 CFI_ENDPROC
27096 ENDPROC(atomic64_read_cx8)
27097
27098 +ENTRY(atomic64_read_unchecked_cx8)
27099 + CFI_STARTPROC
27100 +
27101 + read64 %ecx
27102 + pax_force_retaddr
27103 + ret
27104 + CFI_ENDPROC
27105 +ENDPROC(atomic64_read_unchecked_cx8)
27106 +
27107 ENTRY(atomic64_set_cx8)
27108 CFI_STARTPROC
27109
27110 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27111 cmpxchg8b (%esi)
27112 jne 1b
27113
27114 + pax_force_retaddr
27115 ret
27116 CFI_ENDPROC
27117 ENDPROC(atomic64_set_cx8)
27118
27119 +ENTRY(atomic64_set_unchecked_cx8)
27120 + CFI_STARTPROC
27121 +
27122 +1:
27123 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27124 + * are atomic on 586 and newer */
27125 + cmpxchg8b (%esi)
27126 + jne 1b
27127 +
27128 + pax_force_retaddr
27129 + ret
27130 + CFI_ENDPROC
27131 +ENDPROC(atomic64_set_unchecked_cx8)
27132 +
27133 ENTRY(atomic64_xchg_cx8)
27134 CFI_STARTPROC
27135
27136 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27137 cmpxchg8b (%esi)
27138 jne 1b
27139
27140 + pax_force_retaddr
27141 ret
27142 CFI_ENDPROC
27143 ENDPROC(atomic64_xchg_cx8)
27144
27145 -.macro addsub_return func ins insc
27146 -ENTRY(atomic64_\func\()_return_cx8)
27147 +.macro addsub_return func ins insc unchecked=""
27148 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27149 CFI_STARTPROC
27150 SAVE ebp
27151 SAVE ebx
27152 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27153 movl %edx, %ecx
27154 \ins\()l %esi, %ebx
27155 \insc\()l %edi, %ecx
27156 +
27157 +.ifb \unchecked
27158 +#ifdef CONFIG_PAX_REFCOUNT
27159 + into
27160 +2:
27161 + _ASM_EXTABLE(2b, 3f)
27162 +#endif
27163 +.endif
27164 +
27165 LOCK_PREFIX
27166 cmpxchg8b (%ebp)
27167 jne 1b
27168 -
27169 -10:
27170 movl %ebx, %eax
27171 movl %ecx, %edx
27172 +
27173 +.ifb \unchecked
27174 +#ifdef CONFIG_PAX_REFCOUNT
27175 +3:
27176 +#endif
27177 +.endif
27178 +
27179 RESTORE edi
27180 RESTORE esi
27181 RESTORE ebx
27182 RESTORE ebp
27183 + pax_force_retaddr
27184 ret
27185 CFI_ENDPROC
27186 -ENDPROC(atomic64_\func\()_return_cx8)
27187 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27188 .endm
27189
27190 addsub_return add add adc
27191 addsub_return sub sub sbb
27192 +addsub_return add add adc _unchecked
27193 +addsub_return sub sub sbb _unchecked
27194
27195 -.macro incdec_return func ins insc
27196 -ENTRY(atomic64_\func\()_return_cx8)
27197 +.macro incdec_return func ins insc unchecked=""
27198 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27199 CFI_STARTPROC
27200 SAVE ebx
27201
27202 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27203 movl %edx, %ecx
27204 \ins\()l $1, %ebx
27205 \insc\()l $0, %ecx
27206 +
27207 +.ifb \unchecked
27208 +#ifdef CONFIG_PAX_REFCOUNT
27209 + into
27210 +2:
27211 + _ASM_EXTABLE(2b, 3f)
27212 +#endif
27213 +.endif
27214 +
27215 LOCK_PREFIX
27216 cmpxchg8b (%esi)
27217 jne 1b
27218
27219 -10:
27220 movl %ebx, %eax
27221 movl %ecx, %edx
27222 +
27223 +.ifb \unchecked
27224 +#ifdef CONFIG_PAX_REFCOUNT
27225 +3:
27226 +#endif
27227 +.endif
27228 +
27229 RESTORE ebx
27230 + pax_force_retaddr
27231 ret
27232 CFI_ENDPROC
27233 -ENDPROC(atomic64_\func\()_return_cx8)
27234 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27235 .endm
27236
27237 incdec_return inc add adc
27238 incdec_return dec sub sbb
27239 +incdec_return inc add adc _unchecked
27240 +incdec_return dec sub sbb _unchecked
27241
27242 ENTRY(atomic64_dec_if_positive_cx8)
27243 CFI_STARTPROC
27244 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
27245 movl %edx, %ecx
27246 subl $1, %ebx
27247 sbb $0, %ecx
27248 +
27249 +#ifdef CONFIG_PAX_REFCOUNT
27250 + into
27251 +1234:
27252 + _ASM_EXTABLE(1234b, 2f)
27253 +#endif
27254 +
27255 js 2f
27256 LOCK_PREFIX
27257 cmpxchg8b (%esi)
27258 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
27259 movl %ebx, %eax
27260 movl %ecx, %edx
27261 RESTORE ebx
27262 + pax_force_retaddr
27263 ret
27264 CFI_ENDPROC
27265 ENDPROC(atomic64_dec_if_positive_cx8)
27266 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
27267 movl %edx, %ecx
27268 addl %ebp, %ebx
27269 adcl %edi, %ecx
27270 +
27271 +#ifdef CONFIG_PAX_REFCOUNT
27272 + into
27273 +1234:
27274 + _ASM_EXTABLE(1234b, 3f)
27275 +#endif
27276 +
27277 LOCK_PREFIX
27278 cmpxchg8b (%esi)
27279 jne 1b
27280 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
27281 CFI_ADJUST_CFA_OFFSET -8
27282 RESTORE ebx
27283 RESTORE ebp
27284 + pax_force_retaddr
27285 ret
27286 4:
27287 cmpl %edx, 4(%esp)
27288 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
27289 xorl %ecx, %ecx
27290 addl $1, %ebx
27291 adcl %edx, %ecx
27292 +
27293 +#ifdef CONFIG_PAX_REFCOUNT
27294 + into
27295 +1234:
27296 + _ASM_EXTABLE(1234b, 3f)
27297 +#endif
27298 +
27299 LOCK_PREFIX
27300 cmpxchg8b (%esi)
27301 jne 1b
27302 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
27303 movl $1, %eax
27304 3:
27305 RESTORE ebx
27306 + pax_force_retaddr
27307 ret
27308 CFI_ENDPROC
27309 ENDPROC(atomic64_inc_not_zero_cx8)
27310 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
27311 index e78b8ee..7e173a8 100644
27312 --- a/arch/x86/lib/checksum_32.S
27313 +++ b/arch/x86/lib/checksum_32.S
27314 @@ -29,7 +29,8 @@
27315 #include <asm/dwarf2.h>
27316 #include <asm/errno.h>
27317 #include <asm/asm.h>
27318 -
27319 +#include <asm/segment.h>
27320 +
27321 /*
27322 * computes a partial checksum, e.g. for TCP/UDP fragments
27323 */
27324 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
27325
27326 #define ARGBASE 16
27327 #define FP 12
27328 -
27329 -ENTRY(csum_partial_copy_generic)
27330 +
27331 +ENTRY(csum_partial_copy_generic_to_user)
27332 CFI_STARTPROC
27333 +
27334 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27335 + pushl_cfi %gs
27336 + popl_cfi %es
27337 + jmp csum_partial_copy_generic
27338 +#endif
27339 +
27340 +ENTRY(csum_partial_copy_generic_from_user)
27341 +
27342 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27343 + pushl_cfi %gs
27344 + popl_cfi %ds
27345 +#endif
27346 +
27347 +ENTRY(csum_partial_copy_generic)
27348 subl $4,%esp
27349 CFI_ADJUST_CFA_OFFSET 4
27350 pushl_cfi %edi
27351 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
27352 jmp 4f
27353 SRC(1: movw (%esi), %bx )
27354 addl $2, %esi
27355 -DST( movw %bx, (%edi) )
27356 +DST( movw %bx, %es:(%edi) )
27357 addl $2, %edi
27358 addw %bx, %ax
27359 adcl $0, %eax
27360 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
27361 SRC(1: movl (%esi), %ebx )
27362 SRC( movl 4(%esi), %edx )
27363 adcl %ebx, %eax
27364 -DST( movl %ebx, (%edi) )
27365 +DST( movl %ebx, %es:(%edi) )
27366 adcl %edx, %eax
27367 -DST( movl %edx, 4(%edi) )
27368 +DST( movl %edx, %es:4(%edi) )
27369
27370 SRC( movl 8(%esi), %ebx )
27371 SRC( movl 12(%esi), %edx )
27372 adcl %ebx, %eax
27373 -DST( movl %ebx, 8(%edi) )
27374 +DST( movl %ebx, %es:8(%edi) )
27375 adcl %edx, %eax
27376 -DST( movl %edx, 12(%edi) )
27377 +DST( movl %edx, %es:12(%edi) )
27378
27379 SRC( movl 16(%esi), %ebx )
27380 SRC( movl 20(%esi), %edx )
27381 adcl %ebx, %eax
27382 -DST( movl %ebx, 16(%edi) )
27383 +DST( movl %ebx, %es:16(%edi) )
27384 adcl %edx, %eax
27385 -DST( movl %edx, 20(%edi) )
27386 +DST( movl %edx, %es:20(%edi) )
27387
27388 SRC( movl 24(%esi), %ebx )
27389 SRC( movl 28(%esi), %edx )
27390 adcl %ebx, %eax
27391 -DST( movl %ebx, 24(%edi) )
27392 +DST( movl %ebx, %es:24(%edi) )
27393 adcl %edx, %eax
27394 -DST( movl %edx, 28(%edi) )
27395 +DST( movl %edx, %es:28(%edi) )
27396
27397 lea 32(%esi), %esi
27398 lea 32(%edi), %edi
27399 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
27400 shrl $2, %edx # This clears CF
27401 SRC(3: movl (%esi), %ebx )
27402 adcl %ebx, %eax
27403 -DST( movl %ebx, (%edi) )
27404 +DST( movl %ebx, %es:(%edi) )
27405 lea 4(%esi), %esi
27406 lea 4(%edi), %edi
27407 dec %edx
27408 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
27409 jb 5f
27410 SRC( movw (%esi), %cx )
27411 leal 2(%esi), %esi
27412 -DST( movw %cx, (%edi) )
27413 +DST( movw %cx, %es:(%edi) )
27414 leal 2(%edi), %edi
27415 je 6f
27416 shll $16,%ecx
27417 SRC(5: movb (%esi), %cl )
27418 -DST( movb %cl, (%edi) )
27419 +DST( movb %cl, %es:(%edi) )
27420 6: addl %ecx, %eax
27421 adcl $0, %eax
27422 7:
27423 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
27424
27425 6001:
27426 movl ARGBASE+20(%esp), %ebx # src_err_ptr
27427 - movl $-EFAULT, (%ebx)
27428 + movl $-EFAULT, %ss:(%ebx)
27429
27430 # zero the complete destination - computing the rest
27431 # is too much work
27432 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
27433
27434 6002:
27435 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27436 - movl $-EFAULT,(%ebx)
27437 + movl $-EFAULT,%ss:(%ebx)
27438 jmp 5000b
27439
27440 .previous
27441
27442 + pushl_cfi %ss
27443 + popl_cfi %ds
27444 + pushl_cfi %ss
27445 + popl_cfi %es
27446 popl_cfi %ebx
27447 CFI_RESTORE ebx
27448 popl_cfi %esi
27449 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
27450 popl_cfi %ecx # equivalent to addl $4,%esp
27451 ret
27452 CFI_ENDPROC
27453 -ENDPROC(csum_partial_copy_generic)
27454 +ENDPROC(csum_partial_copy_generic_to_user)
27455
27456 #else
27457
27458 /* Version for PentiumII/PPro */
27459
27460 #define ROUND1(x) \
27461 + nop; nop; nop; \
27462 SRC(movl x(%esi), %ebx ) ; \
27463 addl %ebx, %eax ; \
27464 - DST(movl %ebx, x(%edi) ) ;
27465 + DST(movl %ebx, %es:x(%edi)) ;
27466
27467 #define ROUND(x) \
27468 + nop; nop; nop; \
27469 SRC(movl x(%esi), %ebx ) ; \
27470 adcl %ebx, %eax ; \
27471 - DST(movl %ebx, x(%edi) ) ;
27472 + DST(movl %ebx, %es:x(%edi)) ;
27473
27474 #define ARGBASE 12
27475 -
27476 -ENTRY(csum_partial_copy_generic)
27477 +
27478 +ENTRY(csum_partial_copy_generic_to_user)
27479 CFI_STARTPROC
27480 +
27481 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27482 + pushl_cfi %gs
27483 + popl_cfi %es
27484 + jmp csum_partial_copy_generic
27485 +#endif
27486 +
27487 +ENTRY(csum_partial_copy_generic_from_user)
27488 +
27489 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27490 + pushl_cfi %gs
27491 + popl_cfi %ds
27492 +#endif
27493 +
27494 +ENTRY(csum_partial_copy_generic)
27495 pushl_cfi %ebx
27496 CFI_REL_OFFSET ebx, 0
27497 pushl_cfi %edi
27498 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
27499 subl %ebx, %edi
27500 lea -1(%esi),%edx
27501 andl $-32,%edx
27502 - lea 3f(%ebx,%ebx), %ebx
27503 + lea 3f(%ebx,%ebx,2), %ebx
27504 testl %esi, %esi
27505 jmp *%ebx
27506 1: addl $64,%esi
27507 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
27508 jb 5f
27509 SRC( movw (%esi), %dx )
27510 leal 2(%esi), %esi
27511 -DST( movw %dx, (%edi) )
27512 +DST( movw %dx, %es:(%edi) )
27513 leal 2(%edi), %edi
27514 je 6f
27515 shll $16,%edx
27516 5:
27517 SRC( movb (%esi), %dl )
27518 -DST( movb %dl, (%edi) )
27519 +DST( movb %dl, %es:(%edi) )
27520 6: addl %edx, %eax
27521 adcl $0, %eax
27522 7:
27523 .section .fixup, "ax"
27524 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
27525 - movl $-EFAULT, (%ebx)
27526 + movl $-EFAULT, %ss:(%ebx)
27527 # zero the complete destination (computing the rest is too much work)
27528 movl ARGBASE+8(%esp),%edi # dst
27529 movl ARGBASE+12(%esp),%ecx # len
27530 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
27531 rep; stosb
27532 jmp 7b
27533 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
27534 - movl $-EFAULT, (%ebx)
27535 + movl $-EFAULT, %ss:(%ebx)
27536 jmp 7b
27537 .previous
27538
27539 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27540 + pushl_cfi %ss
27541 + popl_cfi %ds
27542 + pushl_cfi %ss
27543 + popl_cfi %es
27544 +#endif
27545 +
27546 popl_cfi %esi
27547 CFI_RESTORE esi
27548 popl_cfi %edi
27549 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
27550 CFI_RESTORE ebx
27551 ret
27552 CFI_ENDPROC
27553 -ENDPROC(csum_partial_copy_generic)
27554 +ENDPROC(csum_partial_copy_generic_to_user)
27555
27556 #undef ROUND
27557 #undef ROUND1
27558 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
27559 index f2145cf..cea889d 100644
27560 --- a/arch/x86/lib/clear_page_64.S
27561 +++ b/arch/x86/lib/clear_page_64.S
27562 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
27563 movl $4096/8,%ecx
27564 xorl %eax,%eax
27565 rep stosq
27566 + pax_force_retaddr
27567 ret
27568 CFI_ENDPROC
27569 ENDPROC(clear_page_c)
27570 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
27571 movl $4096,%ecx
27572 xorl %eax,%eax
27573 rep stosb
27574 + pax_force_retaddr
27575 ret
27576 CFI_ENDPROC
27577 ENDPROC(clear_page_c_e)
27578 @@ -43,6 +45,7 @@ ENTRY(clear_page)
27579 leaq 64(%rdi),%rdi
27580 jnz .Lloop
27581 nop
27582 + pax_force_retaddr
27583 ret
27584 CFI_ENDPROC
27585 .Lclear_page_end:
27586 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
27587
27588 #include <asm/cpufeature.h>
27589
27590 - .section .altinstr_replacement,"ax"
27591 + .section .altinstr_replacement,"a"
27592 1: .byte 0xeb /* jmp <disp8> */
27593 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
27594 2: .byte 0xeb /* jmp <disp8> */
27595 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
27596 index 1e572c5..2a162cd 100644
27597 --- a/arch/x86/lib/cmpxchg16b_emu.S
27598 +++ b/arch/x86/lib/cmpxchg16b_emu.S
27599 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
27600
27601 popf
27602 mov $1, %al
27603 + pax_force_retaddr
27604 ret
27605
27606 not_same:
27607 popf
27608 xor %al,%al
27609 + pax_force_retaddr
27610 ret
27611
27612 CFI_ENDPROC
27613 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
27614 index 176cca6..1166c50 100644
27615 --- a/arch/x86/lib/copy_page_64.S
27616 +++ b/arch/x86/lib/copy_page_64.S
27617 @@ -9,6 +9,7 @@ copy_page_rep:
27618 CFI_STARTPROC
27619 movl $4096/8, %ecx
27620 rep movsq
27621 + pax_force_retaddr
27622 ret
27623 CFI_ENDPROC
27624 ENDPROC(copy_page_rep)
27625 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
27626
27627 ENTRY(copy_page)
27628 CFI_STARTPROC
27629 - subq $2*8, %rsp
27630 - CFI_ADJUST_CFA_OFFSET 2*8
27631 + subq $3*8, %rsp
27632 + CFI_ADJUST_CFA_OFFSET 3*8
27633 movq %rbx, (%rsp)
27634 CFI_REL_OFFSET rbx, 0
27635 movq %r12, 1*8(%rsp)
27636 CFI_REL_OFFSET r12, 1*8
27637 + movq %r13, 2*8(%rsp)
27638 + CFI_REL_OFFSET r13, 2*8
27639
27640 movl $(4096/64)-5, %ecx
27641 .p2align 4
27642 @@ -36,7 +39,7 @@ ENTRY(copy_page)
27643 movq 0x8*2(%rsi), %rdx
27644 movq 0x8*3(%rsi), %r8
27645 movq 0x8*4(%rsi), %r9
27646 - movq 0x8*5(%rsi), %r10
27647 + movq 0x8*5(%rsi), %r13
27648 movq 0x8*6(%rsi), %r11
27649 movq 0x8*7(%rsi), %r12
27650
27651 @@ -47,7 +50,7 @@ ENTRY(copy_page)
27652 movq %rdx, 0x8*2(%rdi)
27653 movq %r8, 0x8*3(%rdi)
27654 movq %r9, 0x8*4(%rdi)
27655 - movq %r10, 0x8*5(%rdi)
27656 + movq %r13, 0x8*5(%rdi)
27657 movq %r11, 0x8*6(%rdi)
27658 movq %r12, 0x8*7(%rdi)
27659
27660 @@ -66,7 +69,7 @@ ENTRY(copy_page)
27661 movq 0x8*2(%rsi), %rdx
27662 movq 0x8*3(%rsi), %r8
27663 movq 0x8*4(%rsi), %r9
27664 - movq 0x8*5(%rsi), %r10
27665 + movq 0x8*5(%rsi), %r13
27666 movq 0x8*6(%rsi), %r11
27667 movq 0x8*7(%rsi), %r12
27668
27669 @@ -75,7 +78,7 @@ ENTRY(copy_page)
27670 movq %rdx, 0x8*2(%rdi)
27671 movq %r8, 0x8*3(%rdi)
27672 movq %r9, 0x8*4(%rdi)
27673 - movq %r10, 0x8*5(%rdi)
27674 + movq %r13, 0x8*5(%rdi)
27675 movq %r11, 0x8*6(%rdi)
27676 movq %r12, 0x8*7(%rdi)
27677
27678 @@ -87,8 +90,11 @@ ENTRY(copy_page)
27679 CFI_RESTORE rbx
27680 movq 1*8(%rsp), %r12
27681 CFI_RESTORE r12
27682 - addq $2*8, %rsp
27683 - CFI_ADJUST_CFA_OFFSET -2*8
27684 + movq 2*8(%rsp), %r13
27685 + CFI_RESTORE r13
27686 + addq $3*8, %rsp
27687 + CFI_ADJUST_CFA_OFFSET -3*8
27688 + pax_force_retaddr
27689 ret
27690 .Lcopy_page_end:
27691 CFI_ENDPROC
27692 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
27693
27694 #include <asm/cpufeature.h>
27695
27696 - .section .altinstr_replacement,"ax"
27697 + .section .altinstr_replacement,"a"
27698 1: .byte 0xeb /* jmp <disp8> */
27699 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
27700 2:
27701 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
27702 index a30ca15..6b3f4e1 100644
27703 --- a/arch/x86/lib/copy_user_64.S
27704 +++ b/arch/x86/lib/copy_user_64.S
27705 @@ -18,31 +18,7 @@
27706 #include <asm/alternative-asm.h>
27707 #include <asm/asm.h>
27708 #include <asm/smap.h>
27709 -
27710 -/*
27711 - * By placing feature2 after feature1 in altinstructions section, we logically
27712 - * implement:
27713 - * If CPU has feature2, jmp to alt2 is used
27714 - * else if CPU has feature1, jmp to alt1 is used
27715 - * else jmp to orig is used.
27716 - */
27717 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
27718 -0:
27719 - .byte 0xe9 /* 32bit jump */
27720 - .long \orig-1f /* by default jump to orig */
27721 -1:
27722 - .section .altinstr_replacement,"ax"
27723 -2: .byte 0xe9 /* near jump with 32bit immediate */
27724 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
27725 -3: .byte 0xe9 /* near jump with 32bit immediate */
27726 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
27727 - .previous
27728 -
27729 - .section .altinstructions,"a"
27730 - altinstruction_entry 0b,2b,\feature1,5,5
27731 - altinstruction_entry 0b,3b,\feature2,5,5
27732 - .previous
27733 - .endm
27734 +#include <asm/pgtable.h>
27735
27736 .macro ALIGN_DESTINATION
27737 #ifdef FIX_ALIGNMENT
27738 @@ -70,52 +46,6 @@
27739 #endif
27740 .endm
27741
27742 -/* Standard copy_to_user with segment limit checking */
27743 -ENTRY(_copy_to_user)
27744 - CFI_STARTPROC
27745 - GET_THREAD_INFO(%rax)
27746 - movq %rdi,%rcx
27747 - addq %rdx,%rcx
27748 - jc bad_to_user
27749 - cmpq TI_addr_limit(%rax),%rcx
27750 - ja bad_to_user
27751 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27752 - copy_user_generic_unrolled,copy_user_generic_string, \
27753 - copy_user_enhanced_fast_string
27754 - CFI_ENDPROC
27755 -ENDPROC(_copy_to_user)
27756 -
27757 -/* Standard copy_from_user with segment limit checking */
27758 -ENTRY(_copy_from_user)
27759 - CFI_STARTPROC
27760 - GET_THREAD_INFO(%rax)
27761 - movq %rsi,%rcx
27762 - addq %rdx,%rcx
27763 - jc bad_from_user
27764 - cmpq TI_addr_limit(%rax),%rcx
27765 - ja bad_from_user
27766 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
27767 - copy_user_generic_unrolled,copy_user_generic_string, \
27768 - copy_user_enhanced_fast_string
27769 - CFI_ENDPROC
27770 -ENDPROC(_copy_from_user)
27771 -
27772 - .section .fixup,"ax"
27773 - /* must zero dest */
27774 -ENTRY(bad_from_user)
27775 -bad_from_user:
27776 - CFI_STARTPROC
27777 - movl %edx,%ecx
27778 - xorl %eax,%eax
27779 - rep
27780 - stosb
27781 -bad_to_user:
27782 - movl %edx,%eax
27783 - ret
27784 - CFI_ENDPROC
27785 -ENDPROC(bad_from_user)
27786 - .previous
27787 -
27788 /*
27789 * copy_user_generic_unrolled - memory copy with exception handling.
27790 * This version is for CPUs like P4 that don't have efficient micro
27791 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
27792 */
27793 ENTRY(copy_user_generic_unrolled)
27794 CFI_STARTPROC
27795 + ASM_PAX_OPEN_USERLAND
27796 ASM_STAC
27797 cmpl $8,%edx
27798 jb 20f /* less then 8 bytes, go to byte copy loop */
27799 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
27800 jz 17f
27801 1: movq (%rsi),%r8
27802 2: movq 1*8(%rsi),%r9
27803 -3: movq 2*8(%rsi),%r10
27804 +3: movq 2*8(%rsi),%rax
27805 4: movq 3*8(%rsi),%r11
27806 5: movq %r8,(%rdi)
27807 6: movq %r9,1*8(%rdi)
27808 -7: movq %r10,2*8(%rdi)
27809 +7: movq %rax,2*8(%rdi)
27810 8: movq %r11,3*8(%rdi)
27811 9: movq 4*8(%rsi),%r8
27812 10: movq 5*8(%rsi),%r9
27813 -11: movq 6*8(%rsi),%r10
27814 +11: movq 6*8(%rsi),%rax
27815 12: movq 7*8(%rsi),%r11
27816 13: movq %r8,4*8(%rdi)
27817 14: movq %r9,5*8(%rdi)
27818 -15: movq %r10,6*8(%rdi)
27819 +15: movq %rax,6*8(%rdi)
27820 16: movq %r11,7*8(%rdi)
27821 leaq 64(%rsi),%rsi
27822 leaq 64(%rdi),%rdi
27823 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
27824 jnz 21b
27825 23: xor %eax,%eax
27826 ASM_CLAC
27827 + ASM_PAX_CLOSE_USERLAND
27828 + pax_force_retaddr
27829 ret
27830
27831 .section .fixup,"ax"
27832 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
27833 */
27834 ENTRY(copy_user_generic_string)
27835 CFI_STARTPROC
27836 + ASM_PAX_OPEN_USERLAND
27837 ASM_STAC
27838 andl %edx,%edx
27839 jz 4f
27840 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
27841 movsb
27842 4: xorl %eax,%eax
27843 ASM_CLAC
27844 + ASM_PAX_CLOSE_USERLAND
27845 + pax_force_retaddr
27846 ret
27847
27848 .section .fixup,"ax"
27849 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
27850 */
27851 ENTRY(copy_user_enhanced_fast_string)
27852 CFI_STARTPROC
27853 + ASM_PAX_OPEN_USERLAND
27854 ASM_STAC
27855 andl %edx,%edx
27856 jz 2f
27857 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
27858 movsb
27859 2: xorl %eax,%eax
27860 ASM_CLAC
27861 + ASM_PAX_CLOSE_USERLAND
27862 + pax_force_retaddr
27863 ret
27864
27865 .section .fixup,"ax"
27866 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
27867 index 6a4f43c..55d26f2 100644
27868 --- a/arch/x86/lib/copy_user_nocache_64.S
27869 +++ b/arch/x86/lib/copy_user_nocache_64.S
27870 @@ -8,6 +8,7 @@
27871
27872 #include <linux/linkage.h>
27873 #include <asm/dwarf2.h>
27874 +#include <asm/alternative-asm.h>
27875
27876 #define FIX_ALIGNMENT 1
27877
27878 @@ -16,6 +17,7 @@
27879 #include <asm/thread_info.h>
27880 #include <asm/asm.h>
27881 #include <asm/smap.h>
27882 +#include <asm/pgtable.h>
27883
27884 .macro ALIGN_DESTINATION
27885 #ifdef FIX_ALIGNMENT
27886 @@ -49,6 +51,16 @@
27887 */
27888 ENTRY(__copy_user_nocache)
27889 CFI_STARTPROC
27890 +
27891 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27892 + mov pax_user_shadow_base,%rcx
27893 + cmp %rcx,%rsi
27894 + jae 1f
27895 + add %rcx,%rsi
27896 +1:
27897 +#endif
27898 +
27899 + ASM_PAX_OPEN_USERLAND
27900 ASM_STAC
27901 cmpl $8,%edx
27902 jb 20f /* less then 8 bytes, go to byte copy loop */
27903 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
27904 jz 17f
27905 1: movq (%rsi),%r8
27906 2: movq 1*8(%rsi),%r9
27907 -3: movq 2*8(%rsi),%r10
27908 +3: movq 2*8(%rsi),%rax
27909 4: movq 3*8(%rsi),%r11
27910 5: movnti %r8,(%rdi)
27911 6: movnti %r9,1*8(%rdi)
27912 -7: movnti %r10,2*8(%rdi)
27913 +7: movnti %rax,2*8(%rdi)
27914 8: movnti %r11,3*8(%rdi)
27915 9: movq 4*8(%rsi),%r8
27916 10: movq 5*8(%rsi),%r9
27917 -11: movq 6*8(%rsi),%r10
27918 +11: movq 6*8(%rsi),%rax
27919 12: movq 7*8(%rsi),%r11
27920 13: movnti %r8,4*8(%rdi)
27921 14: movnti %r9,5*8(%rdi)
27922 -15: movnti %r10,6*8(%rdi)
27923 +15: movnti %rax,6*8(%rdi)
27924 16: movnti %r11,7*8(%rdi)
27925 leaq 64(%rsi),%rsi
27926 leaq 64(%rdi),%rdi
27927 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27928 jnz 21b
27929 23: xorl %eax,%eax
27930 ASM_CLAC
27931 + ASM_PAX_CLOSE_USERLAND
27932 sfence
27933 + pax_force_retaddr
27934 ret
27935
27936 .section .fixup,"ax"
27937 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27938 index 2419d5f..953ee51 100644
27939 --- a/arch/x86/lib/csum-copy_64.S
27940 +++ b/arch/x86/lib/csum-copy_64.S
27941 @@ -9,6 +9,7 @@
27942 #include <asm/dwarf2.h>
27943 #include <asm/errno.h>
27944 #include <asm/asm.h>
27945 +#include <asm/alternative-asm.h>
27946
27947 /*
27948 * Checksum copy with exception handling.
27949 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27950 CFI_RESTORE rbp
27951 addq $7*8, %rsp
27952 CFI_ADJUST_CFA_OFFSET -7*8
27953 + pax_force_retaddr 0, 1
27954 ret
27955 CFI_RESTORE_STATE
27956
27957 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27958 index 7609e0e..b449b98 100644
27959 --- a/arch/x86/lib/csum-wrappers_64.c
27960 +++ b/arch/x86/lib/csum-wrappers_64.c
27961 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27962 len -= 2;
27963 }
27964 }
27965 + pax_open_userland();
27966 stac();
27967 - isum = csum_partial_copy_generic((__force const void *)src,
27968 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27969 dst, len, isum, errp, NULL);
27970 clac();
27971 + pax_close_userland();
27972 if (unlikely(*errp))
27973 goto out_err;
27974
27975 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27976 }
27977
27978 *errp = 0;
27979 + pax_open_userland();
27980 stac();
27981 - ret = csum_partial_copy_generic(src, (void __force *)dst,
27982 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27983 len, isum, NULL, errp);
27984 clac();
27985 + pax_close_userland();
27986 return ret;
27987 }
27988 EXPORT_SYMBOL(csum_partial_copy_to_user);
27989 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27990 index a451235..1daa956 100644
27991 --- a/arch/x86/lib/getuser.S
27992 +++ b/arch/x86/lib/getuser.S
27993 @@ -33,17 +33,40 @@
27994 #include <asm/thread_info.h>
27995 #include <asm/asm.h>
27996 #include <asm/smap.h>
27997 +#include <asm/segment.h>
27998 +#include <asm/pgtable.h>
27999 +#include <asm/alternative-asm.h>
28000 +
28001 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28002 +#define __copyuser_seg gs;
28003 +#else
28004 +#define __copyuser_seg
28005 +#endif
28006
28007 .text
28008 ENTRY(__get_user_1)
28009 CFI_STARTPROC
28010 +
28011 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28012 GET_THREAD_INFO(%_ASM_DX)
28013 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28014 jae bad_get_user
28015 ASM_STAC
28016 -1: movzbl (%_ASM_AX),%edx
28017 +
28018 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28019 + mov pax_user_shadow_base,%_ASM_DX
28020 + cmp %_ASM_DX,%_ASM_AX
28021 + jae 1234f
28022 + add %_ASM_DX,%_ASM_AX
28023 +1234:
28024 +#endif
28025 +
28026 +#endif
28027 +
28028 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28029 xor %eax,%eax
28030 ASM_CLAC
28031 + pax_force_retaddr
28032 ret
28033 CFI_ENDPROC
28034 ENDPROC(__get_user_1)
28035 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28036 ENTRY(__get_user_2)
28037 CFI_STARTPROC
28038 add $1,%_ASM_AX
28039 +
28040 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28041 jc bad_get_user
28042 GET_THREAD_INFO(%_ASM_DX)
28043 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28044 jae bad_get_user
28045 ASM_STAC
28046 -2: movzwl -1(%_ASM_AX),%edx
28047 +
28048 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28049 + mov pax_user_shadow_base,%_ASM_DX
28050 + cmp %_ASM_DX,%_ASM_AX
28051 + jae 1234f
28052 + add %_ASM_DX,%_ASM_AX
28053 +1234:
28054 +#endif
28055 +
28056 +#endif
28057 +
28058 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28059 xor %eax,%eax
28060 ASM_CLAC
28061 + pax_force_retaddr
28062 ret
28063 CFI_ENDPROC
28064 ENDPROC(__get_user_2)
28065 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28066 ENTRY(__get_user_4)
28067 CFI_STARTPROC
28068 add $3,%_ASM_AX
28069 +
28070 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28071 jc bad_get_user
28072 GET_THREAD_INFO(%_ASM_DX)
28073 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28074 jae bad_get_user
28075 ASM_STAC
28076 -3: movl -3(%_ASM_AX),%edx
28077 +
28078 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28079 + mov pax_user_shadow_base,%_ASM_DX
28080 + cmp %_ASM_DX,%_ASM_AX
28081 + jae 1234f
28082 + add %_ASM_DX,%_ASM_AX
28083 +1234:
28084 +#endif
28085 +
28086 +#endif
28087 +
28088 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28089 xor %eax,%eax
28090 ASM_CLAC
28091 + pax_force_retaddr
28092 ret
28093 CFI_ENDPROC
28094 ENDPROC(__get_user_4)
28095 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28096 GET_THREAD_INFO(%_ASM_DX)
28097 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28098 jae bad_get_user
28099 +
28100 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28101 + mov pax_user_shadow_base,%_ASM_DX
28102 + cmp %_ASM_DX,%_ASM_AX
28103 + jae 1234f
28104 + add %_ASM_DX,%_ASM_AX
28105 +1234:
28106 +#endif
28107 +
28108 ASM_STAC
28109 4: movq -7(%_ASM_AX),%rdx
28110 xor %eax,%eax
28111 ASM_CLAC
28112 + pax_force_retaddr
28113 ret
28114 #else
28115 add $7,%_ASM_AX
28116 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28117 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28118 jae bad_get_user_8
28119 ASM_STAC
28120 -4: movl -7(%_ASM_AX),%edx
28121 -5: movl -3(%_ASM_AX),%ecx
28122 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28123 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28124 xor %eax,%eax
28125 ASM_CLAC
28126 + pax_force_retaddr
28127 ret
28128 #endif
28129 CFI_ENDPROC
28130 @@ -113,6 +175,7 @@ bad_get_user:
28131 xor %edx,%edx
28132 mov $(-EFAULT),%_ASM_AX
28133 ASM_CLAC
28134 + pax_force_retaddr
28135 ret
28136 CFI_ENDPROC
28137 END(bad_get_user)
28138 @@ -124,6 +187,7 @@ bad_get_user_8:
28139 xor %ecx,%ecx
28140 mov $(-EFAULT),%_ASM_AX
28141 ASM_CLAC
28142 + pax_force_retaddr
28143 ret
28144 CFI_ENDPROC
28145 END(bad_get_user_8)
28146 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28147 index 54fcffe..7be149e 100644
28148 --- a/arch/x86/lib/insn.c
28149 +++ b/arch/x86/lib/insn.c
28150 @@ -20,8 +20,10 @@
28151
28152 #ifdef __KERNEL__
28153 #include <linux/string.h>
28154 +#include <asm/pgtable_types.h>
28155 #else
28156 #include <string.h>
28157 +#define ktla_ktva(addr) addr
28158 #endif
28159 #include <asm/inat.h>
28160 #include <asm/insn.h>
28161 @@ -53,8 +55,8 @@
28162 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28163 {
28164 memset(insn, 0, sizeof(*insn));
28165 - insn->kaddr = kaddr;
28166 - insn->next_byte = kaddr;
28167 + insn->kaddr = ktla_ktva(kaddr);
28168 + insn->next_byte = ktla_ktva(kaddr);
28169 insn->x86_64 = x86_64 ? 1 : 0;
28170 insn->opnd_bytes = 4;
28171 if (x86_64)
28172 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28173 index 05a95e7..326f2fa 100644
28174 --- a/arch/x86/lib/iomap_copy_64.S
28175 +++ b/arch/x86/lib/iomap_copy_64.S
28176 @@ -17,6 +17,7 @@
28177
28178 #include <linux/linkage.h>
28179 #include <asm/dwarf2.h>
28180 +#include <asm/alternative-asm.h>
28181
28182 /*
28183 * override generic version in lib/iomap_copy.c
28184 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28185 CFI_STARTPROC
28186 movl %edx,%ecx
28187 rep movsd
28188 + pax_force_retaddr
28189 ret
28190 CFI_ENDPROC
28191 ENDPROC(__iowrite32_copy)
28192 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28193 index 56313a3..9b59269 100644
28194 --- a/arch/x86/lib/memcpy_64.S
28195 +++ b/arch/x86/lib/memcpy_64.S
28196 @@ -24,7 +24,7 @@
28197 * This gets patched over the unrolled variant (below) via the
28198 * alternative instructions framework:
28199 */
28200 - .section .altinstr_replacement, "ax", @progbits
28201 + .section .altinstr_replacement, "a", @progbits
28202 .Lmemcpy_c:
28203 movq %rdi, %rax
28204 movq %rdx, %rcx
28205 @@ -33,6 +33,7 @@
28206 rep movsq
28207 movl %edx, %ecx
28208 rep movsb
28209 + pax_force_retaddr
28210 ret
28211 .Lmemcpy_e:
28212 .previous
28213 @@ -44,11 +45,12 @@
28214 * This gets patched over the unrolled variant (below) via the
28215 * alternative instructions framework:
28216 */
28217 - .section .altinstr_replacement, "ax", @progbits
28218 + .section .altinstr_replacement, "a", @progbits
28219 .Lmemcpy_c_e:
28220 movq %rdi, %rax
28221 movq %rdx, %rcx
28222 rep movsb
28223 + pax_force_retaddr
28224 ret
28225 .Lmemcpy_e_e:
28226 .previous
28227 @@ -76,13 +78,13 @@ ENTRY(memcpy)
28228 */
28229 movq 0*8(%rsi), %r8
28230 movq 1*8(%rsi), %r9
28231 - movq 2*8(%rsi), %r10
28232 + movq 2*8(%rsi), %rcx
28233 movq 3*8(%rsi), %r11
28234 leaq 4*8(%rsi), %rsi
28235
28236 movq %r8, 0*8(%rdi)
28237 movq %r9, 1*8(%rdi)
28238 - movq %r10, 2*8(%rdi)
28239 + movq %rcx, 2*8(%rdi)
28240 movq %r11, 3*8(%rdi)
28241 leaq 4*8(%rdi), %rdi
28242 jae .Lcopy_forward_loop
28243 @@ -105,12 +107,12 @@ ENTRY(memcpy)
28244 subq $0x20, %rdx
28245 movq -1*8(%rsi), %r8
28246 movq -2*8(%rsi), %r9
28247 - movq -3*8(%rsi), %r10
28248 + movq -3*8(%rsi), %rcx
28249 movq -4*8(%rsi), %r11
28250 leaq -4*8(%rsi), %rsi
28251 movq %r8, -1*8(%rdi)
28252 movq %r9, -2*8(%rdi)
28253 - movq %r10, -3*8(%rdi)
28254 + movq %rcx, -3*8(%rdi)
28255 movq %r11, -4*8(%rdi)
28256 leaq -4*8(%rdi), %rdi
28257 jae .Lcopy_backward_loop
28258 @@ -130,12 +132,13 @@ ENTRY(memcpy)
28259 */
28260 movq 0*8(%rsi), %r8
28261 movq 1*8(%rsi), %r9
28262 - movq -2*8(%rsi, %rdx), %r10
28263 + movq -2*8(%rsi, %rdx), %rcx
28264 movq -1*8(%rsi, %rdx), %r11
28265 movq %r8, 0*8(%rdi)
28266 movq %r9, 1*8(%rdi)
28267 - movq %r10, -2*8(%rdi, %rdx)
28268 + movq %rcx, -2*8(%rdi, %rdx)
28269 movq %r11, -1*8(%rdi, %rdx)
28270 + pax_force_retaddr
28271 retq
28272 .p2align 4
28273 .Lless_16bytes:
28274 @@ -148,6 +151,7 @@ ENTRY(memcpy)
28275 movq -1*8(%rsi, %rdx), %r9
28276 movq %r8, 0*8(%rdi)
28277 movq %r9, -1*8(%rdi, %rdx)
28278 + pax_force_retaddr
28279 retq
28280 .p2align 4
28281 .Lless_8bytes:
28282 @@ -161,6 +165,7 @@ ENTRY(memcpy)
28283 movl -4(%rsi, %rdx), %r8d
28284 movl %ecx, (%rdi)
28285 movl %r8d, -4(%rdi, %rdx)
28286 + pax_force_retaddr
28287 retq
28288 .p2align 4
28289 .Lless_3bytes:
28290 @@ -179,6 +184,7 @@ ENTRY(memcpy)
28291 movb %cl, (%rdi)
28292
28293 .Lend:
28294 + pax_force_retaddr
28295 retq
28296 CFI_ENDPROC
28297 ENDPROC(memcpy)
28298 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
28299 index 65268a6..5aa7815 100644
28300 --- a/arch/x86/lib/memmove_64.S
28301 +++ b/arch/x86/lib/memmove_64.S
28302 @@ -61,13 +61,13 @@ ENTRY(memmove)
28303 5:
28304 sub $0x20, %rdx
28305 movq 0*8(%rsi), %r11
28306 - movq 1*8(%rsi), %r10
28307 + movq 1*8(%rsi), %rcx
28308 movq 2*8(%rsi), %r9
28309 movq 3*8(%rsi), %r8
28310 leaq 4*8(%rsi), %rsi
28311
28312 movq %r11, 0*8(%rdi)
28313 - movq %r10, 1*8(%rdi)
28314 + movq %rcx, 1*8(%rdi)
28315 movq %r9, 2*8(%rdi)
28316 movq %r8, 3*8(%rdi)
28317 leaq 4*8(%rdi), %rdi
28318 @@ -81,10 +81,10 @@ ENTRY(memmove)
28319 4:
28320 movq %rdx, %rcx
28321 movq -8(%rsi, %rdx), %r11
28322 - lea -8(%rdi, %rdx), %r10
28323 + lea -8(%rdi, %rdx), %r9
28324 shrq $3, %rcx
28325 rep movsq
28326 - movq %r11, (%r10)
28327 + movq %r11, (%r9)
28328 jmp 13f
28329 .Lmemmove_end_forward:
28330
28331 @@ -95,14 +95,14 @@ ENTRY(memmove)
28332 7:
28333 movq %rdx, %rcx
28334 movq (%rsi), %r11
28335 - movq %rdi, %r10
28336 + movq %rdi, %r9
28337 leaq -8(%rsi, %rdx), %rsi
28338 leaq -8(%rdi, %rdx), %rdi
28339 shrq $3, %rcx
28340 std
28341 rep movsq
28342 cld
28343 - movq %r11, (%r10)
28344 + movq %r11, (%r9)
28345 jmp 13f
28346
28347 /*
28348 @@ -127,13 +127,13 @@ ENTRY(memmove)
28349 8:
28350 subq $0x20, %rdx
28351 movq -1*8(%rsi), %r11
28352 - movq -2*8(%rsi), %r10
28353 + movq -2*8(%rsi), %rcx
28354 movq -3*8(%rsi), %r9
28355 movq -4*8(%rsi), %r8
28356 leaq -4*8(%rsi), %rsi
28357
28358 movq %r11, -1*8(%rdi)
28359 - movq %r10, -2*8(%rdi)
28360 + movq %rcx, -2*8(%rdi)
28361 movq %r9, -3*8(%rdi)
28362 movq %r8, -4*8(%rdi)
28363 leaq -4*8(%rdi), %rdi
28364 @@ -151,11 +151,11 @@ ENTRY(memmove)
28365 * Move data from 16 bytes to 31 bytes.
28366 */
28367 movq 0*8(%rsi), %r11
28368 - movq 1*8(%rsi), %r10
28369 + movq 1*8(%rsi), %rcx
28370 movq -2*8(%rsi, %rdx), %r9
28371 movq -1*8(%rsi, %rdx), %r8
28372 movq %r11, 0*8(%rdi)
28373 - movq %r10, 1*8(%rdi)
28374 + movq %rcx, 1*8(%rdi)
28375 movq %r9, -2*8(%rdi, %rdx)
28376 movq %r8, -1*8(%rdi, %rdx)
28377 jmp 13f
28378 @@ -167,9 +167,9 @@ ENTRY(memmove)
28379 * Move data from 8 bytes to 15 bytes.
28380 */
28381 movq 0*8(%rsi), %r11
28382 - movq -1*8(%rsi, %rdx), %r10
28383 + movq -1*8(%rsi, %rdx), %r9
28384 movq %r11, 0*8(%rdi)
28385 - movq %r10, -1*8(%rdi, %rdx)
28386 + movq %r9, -1*8(%rdi, %rdx)
28387 jmp 13f
28388 10:
28389 cmpq $4, %rdx
28390 @@ -178,9 +178,9 @@ ENTRY(memmove)
28391 * Move data from 4 bytes to 7 bytes.
28392 */
28393 movl (%rsi), %r11d
28394 - movl -4(%rsi, %rdx), %r10d
28395 + movl -4(%rsi, %rdx), %r9d
28396 movl %r11d, (%rdi)
28397 - movl %r10d, -4(%rdi, %rdx)
28398 + movl %r9d, -4(%rdi, %rdx)
28399 jmp 13f
28400 11:
28401 cmp $2, %rdx
28402 @@ -189,9 +189,9 @@ ENTRY(memmove)
28403 * Move data from 2 bytes to 3 bytes.
28404 */
28405 movw (%rsi), %r11w
28406 - movw -2(%rsi, %rdx), %r10w
28407 + movw -2(%rsi, %rdx), %r9w
28408 movw %r11w, (%rdi)
28409 - movw %r10w, -2(%rdi, %rdx)
28410 + movw %r9w, -2(%rdi, %rdx)
28411 jmp 13f
28412 12:
28413 cmp $1, %rdx
28414 @@ -202,14 +202,16 @@ ENTRY(memmove)
28415 movb (%rsi), %r11b
28416 movb %r11b, (%rdi)
28417 13:
28418 + pax_force_retaddr
28419 retq
28420 CFI_ENDPROC
28421
28422 - .section .altinstr_replacement,"ax"
28423 + .section .altinstr_replacement,"a"
28424 .Lmemmove_begin_forward_efs:
28425 /* Forward moving data. */
28426 movq %rdx, %rcx
28427 rep movsb
28428 + pax_force_retaddr
28429 retq
28430 .Lmemmove_end_forward_efs:
28431 .previous
28432 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
28433 index 2dcb380..50a78bc 100644
28434 --- a/arch/x86/lib/memset_64.S
28435 +++ b/arch/x86/lib/memset_64.S
28436 @@ -16,7 +16,7 @@
28437 *
28438 * rax original destination
28439 */
28440 - .section .altinstr_replacement, "ax", @progbits
28441 + .section .altinstr_replacement, "a", @progbits
28442 .Lmemset_c:
28443 movq %rdi,%r9
28444 movq %rdx,%rcx
28445 @@ -30,6 +30,7 @@
28446 movl %edx,%ecx
28447 rep stosb
28448 movq %r9,%rax
28449 + pax_force_retaddr
28450 ret
28451 .Lmemset_e:
28452 .previous
28453 @@ -45,13 +46,14 @@
28454 *
28455 * rax original destination
28456 */
28457 - .section .altinstr_replacement, "ax", @progbits
28458 + .section .altinstr_replacement, "a", @progbits
28459 .Lmemset_c_e:
28460 movq %rdi,%r9
28461 movb %sil,%al
28462 movq %rdx,%rcx
28463 rep stosb
28464 movq %r9,%rax
28465 + pax_force_retaddr
28466 ret
28467 .Lmemset_e_e:
28468 .previous
28469 @@ -59,7 +61,7 @@
28470 ENTRY(memset)
28471 ENTRY(__memset)
28472 CFI_STARTPROC
28473 - movq %rdi,%r10
28474 + movq %rdi,%r11
28475
28476 /* expand byte value */
28477 movzbl %sil,%ecx
28478 @@ -117,7 +119,8 @@ ENTRY(__memset)
28479 jnz .Lloop_1
28480
28481 .Lende:
28482 - movq %r10,%rax
28483 + movq %r11,%rax
28484 + pax_force_retaddr
28485 ret
28486
28487 CFI_RESTORE_STATE
28488 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
28489 index c9f2d9b..e7fd2c0 100644
28490 --- a/arch/x86/lib/mmx_32.c
28491 +++ b/arch/x86/lib/mmx_32.c
28492 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28493 {
28494 void *p;
28495 int i;
28496 + unsigned long cr0;
28497
28498 if (unlikely(in_interrupt()))
28499 return __memcpy(to, from, len);
28500 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
28501 kernel_fpu_begin();
28502
28503 __asm__ __volatile__ (
28504 - "1: prefetch (%0)\n" /* This set is 28 bytes */
28505 - " prefetch 64(%0)\n"
28506 - " prefetch 128(%0)\n"
28507 - " prefetch 192(%0)\n"
28508 - " prefetch 256(%0)\n"
28509 + "1: prefetch (%1)\n" /* This set is 28 bytes */
28510 + " prefetch 64(%1)\n"
28511 + " prefetch 128(%1)\n"
28512 + " prefetch 192(%1)\n"
28513 + " prefetch 256(%1)\n"
28514 "2: \n"
28515 ".section .fixup, \"ax\"\n"
28516 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28517 + "3: \n"
28518 +
28519 +#ifdef CONFIG_PAX_KERNEXEC
28520 + " movl %%cr0, %0\n"
28521 + " movl %0, %%eax\n"
28522 + " andl $0xFFFEFFFF, %%eax\n"
28523 + " movl %%eax, %%cr0\n"
28524 +#endif
28525 +
28526 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28527 +
28528 +#ifdef CONFIG_PAX_KERNEXEC
28529 + " movl %0, %%cr0\n"
28530 +#endif
28531 +
28532 " jmp 2b\n"
28533 ".previous\n"
28534 _ASM_EXTABLE(1b, 3b)
28535 - : : "r" (from));
28536 + : "=&r" (cr0) : "r" (from) : "ax");
28537
28538 for ( ; i > 5; i--) {
28539 __asm__ __volatile__ (
28540 - "1: prefetch 320(%0)\n"
28541 - "2: movq (%0), %%mm0\n"
28542 - " movq 8(%0), %%mm1\n"
28543 - " movq 16(%0), %%mm2\n"
28544 - " movq 24(%0), %%mm3\n"
28545 - " movq %%mm0, (%1)\n"
28546 - " movq %%mm1, 8(%1)\n"
28547 - " movq %%mm2, 16(%1)\n"
28548 - " movq %%mm3, 24(%1)\n"
28549 - " movq 32(%0), %%mm0\n"
28550 - " movq 40(%0), %%mm1\n"
28551 - " movq 48(%0), %%mm2\n"
28552 - " movq 56(%0), %%mm3\n"
28553 - " movq %%mm0, 32(%1)\n"
28554 - " movq %%mm1, 40(%1)\n"
28555 - " movq %%mm2, 48(%1)\n"
28556 - " movq %%mm3, 56(%1)\n"
28557 + "1: prefetch 320(%1)\n"
28558 + "2: movq (%1), %%mm0\n"
28559 + " movq 8(%1), %%mm1\n"
28560 + " movq 16(%1), %%mm2\n"
28561 + " movq 24(%1), %%mm3\n"
28562 + " movq %%mm0, (%2)\n"
28563 + " movq %%mm1, 8(%2)\n"
28564 + " movq %%mm2, 16(%2)\n"
28565 + " movq %%mm3, 24(%2)\n"
28566 + " movq 32(%1), %%mm0\n"
28567 + " movq 40(%1), %%mm1\n"
28568 + " movq 48(%1), %%mm2\n"
28569 + " movq 56(%1), %%mm3\n"
28570 + " movq %%mm0, 32(%2)\n"
28571 + " movq %%mm1, 40(%2)\n"
28572 + " movq %%mm2, 48(%2)\n"
28573 + " movq %%mm3, 56(%2)\n"
28574 ".section .fixup, \"ax\"\n"
28575 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28576 + "3:\n"
28577 +
28578 +#ifdef CONFIG_PAX_KERNEXEC
28579 + " movl %%cr0, %0\n"
28580 + " movl %0, %%eax\n"
28581 + " andl $0xFFFEFFFF, %%eax\n"
28582 + " movl %%eax, %%cr0\n"
28583 +#endif
28584 +
28585 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28586 +
28587 +#ifdef CONFIG_PAX_KERNEXEC
28588 + " movl %0, %%cr0\n"
28589 +#endif
28590 +
28591 " jmp 2b\n"
28592 ".previous\n"
28593 _ASM_EXTABLE(1b, 3b)
28594 - : : "r" (from), "r" (to) : "memory");
28595 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28596
28597 from += 64;
28598 to += 64;
28599 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
28600 static void fast_copy_page(void *to, void *from)
28601 {
28602 int i;
28603 + unsigned long cr0;
28604
28605 kernel_fpu_begin();
28606
28607 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
28608 * but that is for later. -AV
28609 */
28610 __asm__ __volatile__(
28611 - "1: prefetch (%0)\n"
28612 - " prefetch 64(%0)\n"
28613 - " prefetch 128(%0)\n"
28614 - " prefetch 192(%0)\n"
28615 - " prefetch 256(%0)\n"
28616 + "1: prefetch (%1)\n"
28617 + " prefetch 64(%1)\n"
28618 + " prefetch 128(%1)\n"
28619 + " prefetch 192(%1)\n"
28620 + " prefetch 256(%1)\n"
28621 "2: \n"
28622 ".section .fixup, \"ax\"\n"
28623 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28624 + "3: \n"
28625 +
28626 +#ifdef CONFIG_PAX_KERNEXEC
28627 + " movl %%cr0, %0\n"
28628 + " movl %0, %%eax\n"
28629 + " andl $0xFFFEFFFF, %%eax\n"
28630 + " movl %%eax, %%cr0\n"
28631 +#endif
28632 +
28633 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28634 +
28635 +#ifdef CONFIG_PAX_KERNEXEC
28636 + " movl %0, %%cr0\n"
28637 +#endif
28638 +
28639 " jmp 2b\n"
28640 ".previous\n"
28641 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28642 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28643
28644 for (i = 0; i < (4096-320)/64; i++) {
28645 __asm__ __volatile__ (
28646 - "1: prefetch 320(%0)\n"
28647 - "2: movq (%0), %%mm0\n"
28648 - " movntq %%mm0, (%1)\n"
28649 - " movq 8(%0), %%mm1\n"
28650 - " movntq %%mm1, 8(%1)\n"
28651 - " movq 16(%0), %%mm2\n"
28652 - " movntq %%mm2, 16(%1)\n"
28653 - " movq 24(%0), %%mm3\n"
28654 - " movntq %%mm3, 24(%1)\n"
28655 - " movq 32(%0), %%mm4\n"
28656 - " movntq %%mm4, 32(%1)\n"
28657 - " movq 40(%0), %%mm5\n"
28658 - " movntq %%mm5, 40(%1)\n"
28659 - " movq 48(%0), %%mm6\n"
28660 - " movntq %%mm6, 48(%1)\n"
28661 - " movq 56(%0), %%mm7\n"
28662 - " movntq %%mm7, 56(%1)\n"
28663 + "1: prefetch 320(%1)\n"
28664 + "2: movq (%1), %%mm0\n"
28665 + " movntq %%mm0, (%2)\n"
28666 + " movq 8(%1), %%mm1\n"
28667 + " movntq %%mm1, 8(%2)\n"
28668 + " movq 16(%1), %%mm2\n"
28669 + " movntq %%mm2, 16(%2)\n"
28670 + " movq 24(%1), %%mm3\n"
28671 + " movntq %%mm3, 24(%2)\n"
28672 + " movq 32(%1), %%mm4\n"
28673 + " movntq %%mm4, 32(%2)\n"
28674 + " movq 40(%1), %%mm5\n"
28675 + " movntq %%mm5, 40(%2)\n"
28676 + " movq 48(%1), %%mm6\n"
28677 + " movntq %%mm6, 48(%2)\n"
28678 + " movq 56(%1), %%mm7\n"
28679 + " movntq %%mm7, 56(%2)\n"
28680 ".section .fixup, \"ax\"\n"
28681 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28682 + "3:\n"
28683 +
28684 +#ifdef CONFIG_PAX_KERNEXEC
28685 + " movl %%cr0, %0\n"
28686 + " movl %0, %%eax\n"
28687 + " andl $0xFFFEFFFF, %%eax\n"
28688 + " movl %%eax, %%cr0\n"
28689 +#endif
28690 +
28691 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28692 +
28693 +#ifdef CONFIG_PAX_KERNEXEC
28694 + " movl %0, %%cr0\n"
28695 +#endif
28696 +
28697 " jmp 2b\n"
28698 ".previous\n"
28699 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
28700 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28701
28702 from += 64;
28703 to += 64;
28704 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
28705 static void fast_copy_page(void *to, void *from)
28706 {
28707 int i;
28708 + unsigned long cr0;
28709
28710 kernel_fpu_begin();
28711
28712 __asm__ __volatile__ (
28713 - "1: prefetch (%0)\n"
28714 - " prefetch 64(%0)\n"
28715 - " prefetch 128(%0)\n"
28716 - " prefetch 192(%0)\n"
28717 - " prefetch 256(%0)\n"
28718 + "1: prefetch (%1)\n"
28719 + " prefetch 64(%1)\n"
28720 + " prefetch 128(%1)\n"
28721 + " prefetch 192(%1)\n"
28722 + " prefetch 256(%1)\n"
28723 "2: \n"
28724 ".section .fixup, \"ax\"\n"
28725 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28726 + "3: \n"
28727 +
28728 +#ifdef CONFIG_PAX_KERNEXEC
28729 + " movl %%cr0, %0\n"
28730 + " movl %0, %%eax\n"
28731 + " andl $0xFFFEFFFF, %%eax\n"
28732 + " movl %%eax, %%cr0\n"
28733 +#endif
28734 +
28735 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
28736 +
28737 +#ifdef CONFIG_PAX_KERNEXEC
28738 + " movl %0, %%cr0\n"
28739 +#endif
28740 +
28741 " jmp 2b\n"
28742 ".previous\n"
28743 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
28744 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
28745
28746 for (i = 0; i < 4096/64; i++) {
28747 __asm__ __volatile__ (
28748 - "1: prefetch 320(%0)\n"
28749 - "2: movq (%0), %%mm0\n"
28750 - " movq 8(%0), %%mm1\n"
28751 - " movq 16(%0), %%mm2\n"
28752 - " movq 24(%0), %%mm3\n"
28753 - " movq %%mm0, (%1)\n"
28754 - " movq %%mm1, 8(%1)\n"
28755 - " movq %%mm2, 16(%1)\n"
28756 - " movq %%mm3, 24(%1)\n"
28757 - " movq 32(%0), %%mm0\n"
28758 - " movq 40(%0), %%mm1\n"
28759 - " movq 48(%0), %%mm2\n"
28760 - " movq 56(%0), %%mm3\n"
28761 - " movq %%mm0, 32(%1)\n"
28762 - " movq %%mm1, 40(%1)\n"
28763 - " movq %%mm2, 48(%1)\n"
28764 - " movq %%mm3, 56(%1)\n"
28765 + "1: prefetch 320(%1)\n"
28766 + "2: movq (%1), %%mm0\n"
28767 + " movq 8(%1), %%mm1\n"
28768 + " movq 16(%1), %%mm2\n"
28769 + " movq 24(%1), %%mm3\n"
28770 + " movq %%mm0, (%2)\n"
28771 + " movq %%mm1, 8(%2)\n"
28772 + " movq %%mm2, 16(%2)\n"
28773 + " movq %%mm3, 24(%2)\n"
28774 + " movq 32(%1), %%mm0\n"
28775 + " movq 40(%1), %%mm1\n"
28776 + " movq 48(%1), %%mm2\n"
28777 + " movq 56(%1), %%mm3\n"
28778 + " movq %%mm0, 32(%2)\n"
28779 + " movq %%mm1, 40(%2)\n"
28780 + " movq %%mm2, 48(%2)\n"
28781 + " movq %%mm3, 56(%2)\n"
28782 ".section .fixup, \"ax\"\n"
28783 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28784 + "3:\n"
28785 +
28786 +#ifdef CONFIG_PAX_KERNEXEC
28787 + " movl %%cr0, %0\n"
28788 + " movl %0, %%eax\n"
28789 + " andl $0xFFFEFFFF, %%eax\n"
28790 + " movl %%eax, %%cr0\n"
28791 +#endif
28792 +
28793 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
28794 +
28795 +#ifdef CONFIG_PAX_KERNEXEC
28796 + " movl %0, %%cr0\n"
28797 +#endif
28798 +
28799 " jmp 2b\n"
28800 ".previous\n"
28801 _ASM_EXTABLE(1b, 3b)
28802 - : : "r" (from), "r" (to) : "memory");
28803 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
28804
28805 from += 64;
28806 to += 64;
28807 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
28808 index f6d13ee..aca5f0b 100644
28809 --- a/arch/x86/lib/msr-reg.S
28810 +++ b/arch/x86/lib/msr-reg.S
28811 @@ -3,6 +3,7 @@
28812 #include <asm/dwarf2.h>
28813 #include <asm/asm.h>
28814 #include <asm/msr.h>
28815 +#include <asm/alternative-asm.h>
28816
28817 #ifdef CONFIG_X86_64
28818 /*
28819 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
28820 CFI_STARTPROC
28821 pushq_cfi %rbx
28822 pushq_cfi %rbp
28823 - movq %rdi, %r10 /* Save pointer */
28824 + movq %rdi, %r9 /* Save pointer */
28825 xorl %r11d, %r11d /* Return value */
28826 movl (%rdi), %eax
28827 movl 4(%rdi), %ecx
28828 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
28829 movl 28(%rdi), %edi
28830 CFI_REMEMBER_STATE
28831 1: \op
28832 -2: movl %eax, (%r10)
28833 +2: movl %eax, (%r9)
28834 movl %r11d, %eax /* Return value */
28835 - movl %ecx, 4(%r10)
28836 - movl %edx, 8(%r10)
28837 - movl %ebx, 12(%r10)
28838 - movl %ebp, 20(%r10)
28839 - movl %esi, 24(%r10)
28840 - movl %edi, 28(%r10)
28841 + movl %ecx, 4(%r9)
28842 + movl %edx, 8(%r9)
28843 + movl %ebx, 12(%r9)
28844 + movl %ebp, 20(%r9)
28845 + movl %esi, 24(%r9)
28846 + movl %edi, 28(%r9)
28847 popq_cfi %rbp
28848 popq_cfi %rbx
28849 + pax_force_retaddr
28850 ret
28851 3:
28852 CFI_RESTORE_STATE
28853 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
28854 index fc6ba17..d4d989d 100644
28855 --- a/arch/x86/lib/putuser.S
28856 +++ b/arch/x86/lib/putuser.S
28857 @@ -16,7 +16,9 @@
28858 #include <asm/errno.h>
28859 #include <asm/asm.h>
28860 #include <asm/smap.h>
28861 -
28862 +#include <asm/segment.h>
28863 +#include <asm/pgtable.h>
28864 +#include <asm/alternative-asm.h>
28865
28866 /*
28867 * __put_user_X
28868 @@ -30,57 +32,125 @@
28869 * as they get called from within inline assembly.
28870 */
28871
28872 -#define ENTER CFI_STARTPROC ; \
28873 - GET_THREAD_INFO(%_ASM_BX)
28874 -#define EXIT ASM_CLAC ; \
28875 - ret ; \
28876 +#define ENTER CFI_STARTPROC
28877 +#define EXIT ASM_CLAC ; \
28878 + pax_force_retaddr ; \
28879 + ret ; \
28880 CFI_ENDPROC
28881
28882 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28883 +#define _DEST %_ASM_CX,%_ASM_BX
28884 +#else
28885 +#define _DEST %_ASM_CX
28886 +#endif
28887 +
28888 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28889 +#define __copyuser_seg gs;
28890 +#else
28891 +#define __copyuser_seg
28892 +#endif
28893 +
28894 .text
28895 ENTRY(__put_user_1)
28896 ENTER
28897 +
28898 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28899 + GET_THREAD_INFO(%_ASM_BX)
28900 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
28901 jae bad_put_user
28902 ASM_STAC
28903 -1: movb %al,(%_ASM_CX)
28904 +
28905 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28906 + mov pax_user_shadow_base,%_ASM_BX
28907 + cmp %_ASM_BX,%_ASM_CX
28908 + jb 1234f
28909 + xor %ebx,%ebx
28910 +1234:
28911 +#endif
28912 +
28913 +#endif
28914 +
28915 +1: __copyuser_seg movb %al,(_DEST)
28916 xor %eax,%eax
28917 EXIT
28918 ENDPROC(__put_user_1)
28919
28920 ENTRY(__put_user_2)
28921 ENTER
28922 +
28923 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28924 + GET_THREAD_INFO(%_ASM_BX)
28925 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28926 sub $1,%_ASM_BX
28927 cmp %_ASM_BX,%_ASM_CX
28928 jae bad_put_user
28929 ASM_STAC
28930 -2: movw %ax,(%_ASM_CX)
28931 +
28932 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28933 + mov pax_user_shadow_base,%_ASM_BX
28934 + cmp %_ASM_BX,%_ASM_CX
28935 + jb 1234f
28936 + xor %ebx,%ebx
28937 +1234:
28938 +#endif
28939 +
28940 +#endif
28941 +
28942 +2: __copyuser_seg movw %ax,(_DEST)
28943 xor %eax,%eax
28944 EXIT
28945 ENDPROC(__put_user_2)
28946
28947 ENTRY(__put_user_4)
28948 ENTER
28949 +
28950 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28951 + GET_THREAD_INFO(%_ASM_BX)
28952 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28953 sub $3,%_ASM_BX
28954 cmp %_ASM_BX,%_ASM_CX
28955 jae bad_put_user
28956 ASM_STAC
28957 -3: movl %eax,(%_ASM_CX)
28958 +
28959 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28960 + mov pax_user_shadow_base,%_ASM_BX
28961 + cmp %_ASM_BX,%_ASM_CX
28962 + jb 1234f
28963 + xor %ebx,%ebx
28964 +1234:
28965 +#endif
28966 +
28967 +#endif
28968 +
28969 +3: __copyuser_seg movl %eax,(_DEST)
28970 xor %eax,%eax
28971 EXIT
28972 ENDPROC(__put_user_4)
28973
28974 ENTRY(__put_user_8)
28975 ENTER
28976 +
28977 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28978 + GET_THREAD_INFO(%_ASM_BX)
28979 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28980 sub $7,%_ASM_BX
28981 cmp %_ASM_BX,%_ASM_CX
28982 jae bad_put_user
28983 ASM_STAC
28984 -4: mov %_ASM_AX,(%_ASM_CX)
28985 +
28986 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28987 + mov pax_user_shadow_base,%_ASM_BX
28988 + cmp %_ASM_BX,%_ASM_CX
28989 + jb 1234f
28990 + xor %ebx,%ebx
28991 +1234:
28992 +#endif
28993 +
28994 +#endif
28995 +
28996 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28997 #ifdef CONFIG_X86_32
28998 -5: movl %edx,4(%_ASM_CX)
28999 +5: __copyuser_seg movl %edx,4(_DEST)
29000 #endif
29001 xor %eax,%eax
29002 EXIT
29003 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29004 index 1cad221..de671ee 100644
29005 --- a/arch/x86/lib/rwlock.S
29006 +++ b/arch/x86/lib/rwlock.S
29007 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29008 FRAME
29009 0: LOCK_PREFIX
29010 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29011 +
29012 +#ifdef CONFIG_PAX_REFCOUNT
29013 + jno 1234f
29014 + LOCK_PREFIX
29015 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29016 + int $4
29017 +1234:
29018 + _ASM_EXTABLE(1234b, 1234b)
29019 +#endif
29020 +
29021 1: rep; nop
29022 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29023 jne 1b
29024 LOCK_PREFIX
29025 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29026 +
29027 +#ifdef CONFIG_PAX_REFCOUNT
29028 + jno 1234f
29029 + LOCK_PREFIX
29030 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29031 + int $4
29032 +1234:
29033 + _ASM_EXTABLE(1234b, 1234b)
29034 +#endif
29035 +
29036 jnz 0b
29037 ENDFRAME
29038 + pax_force_retaddr
29039 ret
29040 CFI_ENDPROC
29041 END(__write_lock_failed)
29042 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29043 FRAME
29044 0: LOCK_PREFIX
29045 READ_LOCK_SIZE(inc) (%__lock_ptr)
29046 +
29047 +#ifdef CONFIG_PAX_REFCOUNT
29048 + jno 1234f
29049 + LOCK_PREFIX
29050 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29051 + int $4
29052 +1234:
29053 + _ASM_EXTABLE(1234b, 1234b)
29054 +#endif
29055 +
29056 1: rep; nop
29057 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29058 js 1b
29059 LOCK_PREFIX
29060 READ_LOCK_SIZE(dec) (%__lock_ptr)
29061 +
29062 +#ifdef CONFIG_PAX_REFCOUNT
29063 + jno 1234f
29064 + LOCK_PREFIX
29065 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29066 + int $4
29067 +1234:
29068 + _ASM_EXTABLE(1234b, 1234b)
29069 +#endif
29070 +
29071 js 0b
29072 ENDFRAME
29073 + pax_force_retaddr
29074 ret
29075 CFI_ENDPROC
29076 END(__read_lock_failed)
29077 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29078 index 5dff5f0..cadebf4 100644
29079 --- a/arch/x86/lib/rwsem.S
29080 +++ b/arch/x86/lib/rwsem.S
29081 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29082 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29083 CFI_RESTORE __ASM_REG(dx)
29084 restore_common_regs
29085 + pax_force_retaddr
29086 ret
29087 CFI_ENDPROC
29088 ENDPROC(call_rwsem_down_read_failed)
29089 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29090 movq %rax,%rdi
29091 call rwsem_down_write_failed
29092 restore_common_regs
29093 + pax_force_retaddr
29094 ret
29095 CFI_ENDPROC
29096 ENDPROC(call_rwsem_down_write_failed)
29097 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29098 movq %rax,%rdi
29099 call rwsem_wake
29100 restore_common_regs
29101 -1: ret
29102 +1: pax_force_retaddr
29103 + ret
29104 CFI_ENDPROC
29105 ENDPROC(call_rwsem_wake)
29106
29107 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29108 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29109 CFI_RESTORE __ASM_REG(dx)
29110 restore_common_regs
29111 + pax_force_retaddr
29112 ret
29113 CFI_ENDPROC
29114 ENDPROC(call_rwsem_downgrade_wake)
29115 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29116 index a63efd6..ccecad8 100644
29117 --- a/arch/x86/lib/thunk_64.S
29118 +++ b/arch/x86/lib/thunk_64.S
29119 @@ -8,6 +8,7 @@
29120 #include <linux/linkage.h>
29121 #include <asm/dwarf2.h>
29122 #include <asm/calling.h>
29123 +#include <asm/alternative-asm.h>
29124
29125 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29126 .macro THUNK name, func, put_ret_addr_in_rdi=0
29127 @@ -41,5 +42,6 @@
29128 SAVE_ARGS
29129 restore:
29130 RESTORE_ARGS
29131 + pax_force_retaddr
29132 ret
29133 CFI_ENDPROC
29134 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29135 index 3eb18ac..6890bc3 100644
29136 --- a/arch/x86/lib/usercopy_32.c
29137 +++ b/arch/x86/lib/usercopy_32.c
29138 @@ -42,11 +42,13 @@ do { \
29139 int __d0; \
29140 might_fault(); \
29141 __asm__ __volatile__( \
29142 + __COPYUSER_SET_ES \
29143 ASM_STAC "\n" \
29144 "0: rep; stosl\n" \
29145 " movl %2,%0\n" \
29146 "1: rep; stosb\n" \
29147 "2: " ASM_CLAC "\n" \
29148 + __COPYUSER_RESTORE_ES \
29149 ".section .fixup,\"ax\"\n" \
29150 "3: lea 0(%2,%0,4),%0\n" \
29151 " jmp 2b\n" \
29152 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29153
29154 #ifdef CONFIG_X86_INTEL_USERCOPY
29155 static unsigned long
29156 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29157 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29158 {
29159 int d0, d1;
29160 __asm__ __volatile__(
29161 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29162 " .align 2,0x90\n"
29163 "3: movl 0(%4), %%eax\n"
29164 "4: movl 4(%4), %%edx\n"
29165 - "5: movl %%eax, 0(%3)\n"
29166 - "6: movl %%edx, 4(%3)\n"
29167 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29168 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29169 "7: movl 8(%4), %%eax\n"
29170 "8: movl 12(%4),%%edx\n"
29171 - "9: movl %%eax, 8(%3)\n"
29172 - "10: movl %%edx, 12(%3)\n"
29173 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29174 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29175 "11: movl 16(%4), %%eax\n"
29176 "12: movl 20(%4), %%edx\n"
29177 - "13: movl %%eax, 16(%3)\n"
29178 - "14: movl %%edx, 20(%3)\n"
29179 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29180 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29181 "15: movl 24(%4), %%eax\n"
29182 "16: movl 28(%4), %%edx\n"
29183 - "17: movl %%eax, 24(%3)\n"
29184 - "18: movl %%edx, 28(%3)\n"
29185 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29186 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29187 "19: movl 32(%4), %%eax\n"
29188 "20: movl 36(%4), %%edx\n"
29189 - "21: movl %%eax, 32(%3)\n"
29190 - "22: movl %%edx, 36(%3)\n"
29191 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29192 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29193 "23: movl 40(%4), %%eax\n"
29194 "24: movl 44(%4), %%edx\n"
29195 - "25: movl %%eax, 40(%3)\n"
29196 - "26: movl %%edx, 44(%3)\n"
29197 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29198 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29199 "27: movl 48(%4), %%eax\n"
29200 "28: movl 52(%4), %%edx\n"
29201 - "29: movl %%eax, 48(%3)\n"
29202 - "30: movl %%edx, 52(%3)\n"
29203 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29204 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29205 "31: movl 56(%4), %%eax\n"
29206 "32: movl 60(%4), %%edx\n"
29207 - "33: movl %%eax, 56(%3)\n"
29208 - "34: movl %%edx, 60(%3)\n"
29209 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29210 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29211 " addl $-64, %0\n"
29212 " addl $64, %4\n"
29213 " addl $64, %3\n"
29214 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29215 " shrl $2, %0\n"
29216 " andl $3, %%eax\n"
29217 " cld\n"
29218 + __COPYUSER_SET_ES
29219 "99: rep; movsl\n"
29220 "36: movl %%eax, %0\n"
29221 "37: rep; movsb\n"
29222 "100:\n"
29223 + __COPYUSER_RESTORE_ES
29224 ".section .fixup,\"ax\"\n"
29225 "101: lea 0(%%eax,%0,4),%0\n"
29226 " jmp 100b\n"
29227 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29228 }
29229
29230 static unsigned long
29231 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29232 +{
29233 + int d0, d1;
29234 + __asm__ __volatile__(
29235 + " .align 2,0x90\n"
29236 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29237 + " cmpl $67, %0\n"
29238 + " jbe 3f\n"
29239 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29240 + " .align 2,0x90\n"
29241 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29242 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29243 + "5: movl %%eax, 0(%3)\n"
29244 + "6: movl %%edx, 4(%3)\n"
29245 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29246 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29247 + "9: movl %%eax, 8(%3)\n"
29248 + "10: movl %%edx, 12(%3)\n"
29249 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29250 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29251 + "13: movl %%eax, 16(%3)\n"
29252 + "14: movl %%edx, 20(%3)\n"
29253 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29254 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29255 + "17: movl %%eax, 24(%3)\n"
29256 + "18: movl %%edx, 28(%3)\n"
29257 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29258 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29259 + "21: movl %%eax, 32(%3)\n"
29260 + "22: movl %%edx, 36(%3)\n"
29261 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29262 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29263 + "25: movl %%eax, 40(%3)\n"
29264 + "26: movl %%edx, 44(%3)\n"
29265 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29266 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29267 + "29: movl %%eax, 48(%3)\n"
29268 + "30: movl %%edx, 52(%3)\n"
29269 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29270 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29271 + "33: movl %%eax, 56(%3)\n"
29272 + "34: movl %%edx, 60(%3)\n"
29273 + " addl $-64, %0\n"
29274 + " addl $64, %4\n"
29275 + " addl $64, %3\n"
29276 + " cmpl $63, %0\n"
29277 + " ja 1b\n"
29278 + "35: movl %0, %%eax\n"
29279 + " shrl $2, %0\n"
29280 + " andl $3, %%eax\n"
29281 + " cld\n"
29282 + "99: rep; "__copyuser_seg" movsl\n"
29283 + "36: movl %%eax, %0\n"
29284 + "37: rep; "__copyuser_seg" movsb\n"
29285 + "100:\n"
29286 + ".section .fixup,\"ax\"\n"
29287 + "101: lea 0(%%eax,%0,4),%0\n"
29288 + " jmp 100b\n"
29289 + ".previous\n"
29290 + _ASM_EXTABLE(1b,100b)
29291 + _ASM_EXTABLE(2b,100b)
29292 + _ASM_EXTABLE(3b,100b)
29293 + _ASM_EXTABLE(4b,100b)
29294 + _ASM_EXTABLE(5b,100b)
29295 + _ASM_EXTABLE(6b,100b)
29296 + _ASM_EXTABLE(7b,100b)
29297 + _ASM_EXTABLE(8b,100b)
29298 + _ASM_EXTABLE(9b,100b)
29299 + _ASM_EXTABLE(10b,100b)
29300 + _ASM_EXTABLE(11b,100b)
29301 + _ASM_EXTABLE(12b,100b)
29302 + _ASM_EXTABLE(13b,100b)
29303 + _ASM_EXTABLE(14b,100b)
29304 + _ASM_EXTABLE(15b,100b)
29305 + _ASM_EXTABLE(16b,100b)
29306 + _ASM_EXTABLE(17b,100b)
29307 + _ASM_EXTABLE(18b,100b)
29308 + _ASM_EXTABLE(19b,100b)
29309 + _ASM_EXTABLE(20b,100b)
29310 + _ASM_EXTABLE(21b,100b)
29311 + _ASM_EXTABLE(22b,100b)
29312 + _ASM_EXTABLE(23b,100b)
29313 + _ASM_EXTABLE(24b,100b)
29314 + _ASM_EXTABLE(25b,100b)
29315 + _ASM_EXTABLE(26b,100b)
29316 + _ASM_EXTABLE(27b,100b)
29317 + _ASM_EXTABLE(28b,100b)
29318 + _ASM_EXTABLE(29b,100b)
29319 + _ASM_EXTABLE(30b,100b)
29320 + _ASM_EXTABLE(31b,100b)
29321 + _ASM_EXTABLE(32b,100b)
29322 + _ASM_EXTABLE(33b,100b)
29323 + _ASM_EXTABLE(34b,100b)
29324 + _ASM_EXTABLE(35b,100b)
29325 + _ASM_EXTABLE(36b,100b)
29326 + _ASM_EXTABLE(37b,100b)
29327 + _ASM_EXTABLE(99b,101b)
29328 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29329 + : "1"(to), "2"(from), "0"(size)
29330 + : "eax", "edx", "memory");
29331 + return size;
29332 +}
29333 +
29334 +static unsigned long __size_overflow(3)
29335 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29336 {
29337 int d0, d1;
29338 __asm__ __volatile__(
29339 " .align 2,0x90\n"
29340 - "0: movl 32(%4), %%eax\n"
29341 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29342 " cmpl $67, %0\n"
29343 " jbe 2f\n"
29344 - "1: movl 64(%4), %%eax\n"
29345 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29346 " .align 2,0x90\n"
29347 - "2: movl 0(%4), %%eax\n"
29348 - "21: movl 4(%4), %%edx\n"
29349 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29350 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29351 " movl %%eax, 0(%3)\n"
29352 " movl %%edx, 4(%3)\n"
29353 - "3: movl 8(%4), %%eax\n"
29354 - "31: movl 12(%4),%%edx\n"
29355 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29356 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29357 " movl %%eax, 8(%3)\n"
29358 " movl %%edx, 12(%3)\n"
29359 - "4: movl 16(%4), %%eax\n"
29360 - "41: movl 20(%4), %%edx\n"
29361 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29362 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29363 " movl %%eax, 16(%3)\n"
29364 " movl %%edx, 20(%3)\n"
29365 - "10: movl 24(%4), %%eax\n"
29366 - "51: movl 28(%4), %%edx\n"
29367 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29368 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29369 " movl %%eax, 24(%3)\n"
29370 " movl %%edx, 28(%3)\n"
29371 - "11: movl 32(%4), %%eax\n"
29372 - "61: movl 36(%4), %%edx\n"
29373 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29374 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29375 " movl %%eax, 32(%3)\n"
29376 " movl %%edx, 36(%3)\n"
29377 - "12: movl 40(%4), %%eax\n"
29378 - "71: movl 44(%4), %%edx\n"
29379 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29380 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29381 " movl %%eax, 40(%3)\n"
29382 " movl %%edx, 44(%3)\n"
29383 - "13: movl 48(%4), %%eax\n"
29384 - "81: movl 52(%4), %%edx\n"
29385 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29386 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29387 " movl %%eax, 48(%3)\n"
29388 " movl %%edx, 52(%3)\n"
29389 - "14: movl 56(%4), %%eax\n"
29390 - "91: movl 60(%4), %%edx\n"
29391 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29392 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29393 " movl %%eax, 56(%3)\n"
29394 " movl %%edx, 60(%3)\n"
29395 " addl $-64, %0\n"
29396 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29397 " shrl $2, %0\n"
29398 " andl $3, %%eax\n"
29399 " cld\n"
29400 - "6: rep; movsl\n"
29401 + "6: rep; "__copyuser_seg" movsl\n"
29402 " movl %%eax,%0\n"
29403 - "7: rep; movsb\n"
29404 + "7: rep; "__copyuser_seg" movsb\n"
29405 "8:\n"
29406 ".section .fixup,\"ax\"\n"
29407 "9: lea 0(%%eax,%0,4),%0\n"
29408 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29409 * hyoshiok@miraclelinux.com
29410 */
29411
29412 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29413 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
29414 const void __user *from, unsigned long size)
29415 {
29416 int d0, d1;
29417
29418 __asm__ __volatile__(
29419 " .align 2,0x90\n"
29420 - "0: movl 32(%4), %%eax\n"
29421 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29422 " cmpl $67, %0\n"
29423 " jbe 2f\n"
29424 - "1: movl 64(%4), %%eax\n"
29425 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29426 " .align 2,0x90\n"
29427 - "2: movl 0(%4), %%eax\n"
29428 - "21: movl 4(%4), %%edx\n"
29429 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29430 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29431 " movnti %%eax, 0(%3)\n"
29432 " movnti %%edx, 4(%3)\n"
29433 - "3: movl 8(%4), %%eax\n"
29434 - "31: movl 12(%4),%%edx\n"
29435 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29436 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29437 " movnti %%eax, 8(%3)\n"
29438 " movnti %%edx, 12(%3)\n"
29439 - "4: movl 16(%4), %%eax\n"
29440 - "41: movl 20(%4), %%edx\n"
29441 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29442 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29443 " movnti %%eax, 16(%3)\n"
29444 " movnti %%edx, 20(%3)\n"
29445 - "10: movl 24(%4), %%eax\n"
29446 - "51: movl 28(%4), %%edx\n"
29447 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29448 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29449 " movnti %%eax, 24(%3)\n"
29450 " movnti %%edx, 28(%3)\n"
29451 - "11: movl 32(%4), %%eax\n"
29452 - "61: movl 36(%4), %%edx\n"
29453 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29454 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29455 " movnti %%eax, 32(%3)\n"
29456 " movnti %%edx, 36(%3)\n"
29457 - "12: movl 40(%4), %%eax\n"
29458 - "71: movl 44(%4), %%edx\n"
29459 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29460 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29461 " movnti %%eax, 40(%3)\n"
29462 " movnti %%edx, 44(%3)\n"
29463 - "13: movl 48(%4), %%eax\n"
29464 - "81: movl 52(%4), %%edx\n"
29465 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29466 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29467 " movnti %%eax, 48(%3)\n"
29468 " movnti %%edx, 52(%3)\n"
29469 - "14: movl 56(%4), %%eax\n"
29470 - "91: movl 60(%4), %%edx\n"
29471 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29472 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29473 " movnti %%eax, 56(%3)\n"
29474 " movnti %%edx, 60(%3)\n"
29475 " addl $-64, %0\n"
29476 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29477 " shrl $2, %0\n"
29478 " andl $3, %%eax\n"
29479 " cld\n"
29480 - "6: rep; movsl\n"
29481 + "6: rep; "__copyuser_seg" movsl\n"
29482 " movl %%eax,%0\n"
29483 - "7: rep; movsb\n"
29484 + "7: rep; "__copyuser_seg" movsb\n"
29485 "8:\n"
29486 ".section .fixup,\"ax\"\n"
29487 "9: lea 0(%%eax,%0,4),%0\n"
29488 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
29489 return size;
29490 }
29491
29492 -static unsigned long __copy_user_intel_nocache(void *to,
29493 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
29494 const void __user *from, unsigned long size)
29495 {
29496 int d0, d1;
29497
29498 __asm__ __volatile__(
29499 " .align 2,0x90\n"
29500 - "0: movl 32(%4), %%eax\n"
29501 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29502 " cmpl $67, %0\n"
29503 " jbe 2f\n"
29504 - "1: movl 64(%4), %%eax\n"
29505 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29506 " .align 2,0x90\n"
29507 - "2: movl 0(%4), %%eax\n"
29508 - "21: movl 4(%4), %%edx\n"
29509 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29510 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29511 " movnti %%eax, 0(%3)\n"
29512 " movnti %%edx, 4(%3)\n"
29513 - "3: movl 8(%4), %%eax\n"
29514 - "31: movl 12(%4),%%edx\n"
29515 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29516 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29517 " movnti %%eax, 8(%3)\n"
29518 " movnti %%edx, 12(%3)\n"
29519 - "4: movl 16(%4), %%eax\n"
29520 - "41: movl 20(%4), %%edx\n"
29521 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29522 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29523 " movnti %%eax, 16(%3)\n"
29524 " movnti %%edx, 20(%3)\n"
29525 - "10: movl 24(%4), %%eax\n"
29526 - "51: movl 28(%4), %%edx\n"
29527 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29528 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29529 " movnti %%eax, 24(%3)\n"
29530 " movnti %%edx, 28(%3)\n"
29531 - "11: movl 32(%4), %%eax\n"
29532 - "61: movl 36(%4), %%edx\n"
29533 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29534 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29535 " movnti %%eax, 32(%3)\n"
29536 " movnti %%edx, 36(%3)\n"
29537 - "12: movl 40(%4), %%eax\n"
29538 - "71: movl 44(%4), %%edx\n"
29539 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29540 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29541 " movnti %%eax, 40(%3)\n"
29542 " movnti %%edx, 44(%3)\n"
29543 - "13: movl 48(%4), %%eax\n"
29544 - "81: movl 52(%4), %%edx\n"
29545 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29546 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29547 " movnti %%eax, 48(%3)\n"
29548 " movnti %%edx, 52(%3)\n"
29549 - "14: movl 56(%4), %%eax\n"
29550 - "91: movl 60(%4), %%edx\n"
29551 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
29552 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
29553 " movnti %%eax, 56(%3)\n"
29554 " movnti %%edx, 60(%3)\n"
29555 " addl $-64, %0\n"
29556 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
29557 " shrl $2, %0\n"
29558 " andl $3, %%eax\n"
29559 " cld\n"
29560 - "6: rep; movsl\n"
29561 + "6: rep; "__copyuser_seg" movsl\n"
29562 " movl %%eax,%0\n"
29563 - "7: rep; movsb\n"
29564 + "7: rep; "__copyuser_seg" movsb\n"
29565 "8:\n"
29566 ".section .fixup,\"ax\"\n"
29567 "9: lea 0(%%eax,%0,4),%0\n"
29568 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
29569 */
29570 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
29571 unsigned long size);
29572 -unsigned long __copy_user_intel(void __user *to, const void *from,
29573 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
29574 + unsigned long size);
29575 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
29576 unsigned long size);
29577 unsigned long __copy_user_zeroing_intel_nocache(void *to,
29578 const void __user *from, unsigned long size);
29579 #endif /* CONFIG_X86_INTEL_USERCOPY */
29580
29581 /* Generic arbitrary sized copy. */
29582 -#define __copy_user(to, from, size) \
29583 +#define __copy_user(to, from, size, prefix, set, restore) \
29584 do { \
29585 int __d0, __d1, __d2; \
29586 __asm__ __volatile__( \
29587 + set \
29588 " cmp $7,%0\n" \
29589 " jbe 1f\n" \
29590 " movl %1,%0\n" \
29591 " negl %0\n" \
29592 " andl $7,%0\n" \
29593 " subl %0,%3\n" \
29594 - "4: rep; movsb\n" \
29595 + "4: rep; "prefix"movsb\n" \
29596 " movl %3,%0\n" \
29597 " shrl $2,%0\n" \
29598 " andl $3,%3\n" \
29599 " .align 2,0x90\n" \
29600 - "0: rep; movsl\n" \
29601 + "0: rep; "prefix"movsl\n" \
29602 " movl %3,%0\n" \
29603 - "1: rep; movsb\n" \
29604 + "1: rep; "prefix"movsb\n" \
29605 "2:\n" \
29606 + restore \
29607 ".section .fixup,\"ax\"\n" \
29608 "5: addl %3,%0\n" \
29609 " jmp 2b\n" \
29610 @@ -538,14 +650,14 @@ do { \
29611 " negl %0\n" \
29612 " andl $7,%0\n" \
29613 " subl %0,%3\n" \
29614 - "4: rep; movsb\n" \
29615 + "4: rep; "__copyuser_seg"movsb\n" \
29616 " movl %3,%0\n" \
29617 " shrl $2,%0\n" \
29618 " andl $3,%3\n" \
29619 " .align 2,0x90\n" \
29620 - "0: rep; movsl\n" \
29621 + "0: rep; "__copyuser_seg"movsl\n" \
29622 " movl %3,%0\n" \
29623 - "1: rep; movsb\n" \
29624 + "1: rep; "__copyuser_seg"movsb\n" \
29625 "2:\n" \
29626 ".section .fixup,\"ax\"\n" \
29627 "5: addl %3,%0\n" \
29628 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
29629 {
29630 stac();
29631 if (movsl_is_ok(to, from, n))
29632 - __copy_user(to, from, n);
29633 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
29634 else
29635 - n = __copy_user_intel(to, from, n);
29636 + n = __generic_copy_to_user_intel(to, from, n);
29637 clac();
29638 return n;
29639 }
29640 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
29641 {
29642 stac();
29643 if (movsl_is_ok(to, from, n))
29644 - __copy_user(to, from, n);
29645 + __copy_user(to, from, n, __copyuser_seg, "", "");
29646 else
29647 - n = __copy_user_intel((void __user *)to,
29648 - (const void *)from, n);
29649 + n = __generic_copy_from_user_intel(to, from, n);
29650 clac();
29651 return n;
29652 }
29653 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
29654 if (n > 64 && cpu_has_xmm2)
29655 n = __copy_user_intel_nocache(to, from, n);
29656 else
29657 - __copy_user(to, from, n);
29658 + __copy_user(to, from, n, __copyuser_seg, "", "");
29659 #else
29660 - __copy_user(to, from, n);
29661 + __copy_user(to, from, n, __copyuser_seg, "", "");
29662 #endif
29663 clac();
29664 return n;
29665 }
29666 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
29667
29668 -/**
29669 - * copy_to_user: - Copy a block of data into user space.
29670 - * @to: Destination address, in user space.
29671 - * @from: Source address, in kernel space.
29672 - * @n: Number of bytes to copy.
29673 - *
29674 - * Context: User context only. This function may sleep.
29675 - *
29676 - * Copy data from kernel space to user space.
29677 - *
29678 - * Returns number of bytes that could not be copied.
29679 - * On success, this will be zero.
29680 - */
29681 -unsigned long
29682 -copy_to_user(void __user *to, const void *from, unsigned long n)
29683 +#ifdef CONFIG_PAX_MEMORY_UDEREF
29684 +void __set_fs(mm_segment_t x)
29685 {
29686 - if (access_ok(VERIFY_WRITE, to, n))
29687 - n = __copy_to_user(to, from, n);
29688 - return n;
29689 + switch (x.seg) {
29690 + case 0:
29691 + loadsegment(gs, 0);
29692 + break;
29693 + case TASK_SIZE_MAX:
29694 + loadsegment(gs, __USER_DS);
29695 + break;
29696 + case -1UL:
29697 + loadsegment(gs, __KERNEL_DS);
29698 + break;
29699 + default:
29700 + BUG();
29701 + }
29702 }
29703 -EXPORT_SYMBOL(copy_to_user);
29704 +EXPORT_SYMBOL(__set_fs);
29705
29706 -/**
29707 - * copy_from_user: - Copy a block of data from user space.
29708 - * @to: Destination address, in kernel space.
29709 - * @from: Source address, in user space.
29710 - * @n: Number of bytes to copy.
29711 - *
29712 - * Context: User context only. This function may sleep.
29713 - *
29714 - * Copy data from user space to kernel space.
29715 - *
29716 - * Returns number of bytes that could not be copied.
29717 - * On success, this will be zero.
29718 - *
29719 - * If some data could not be copied, this function will pad the copied
29720 - * data to the requested size using zero bytes.
29721 - */
29722 -unsigned long
29723 -_copy_from_user(void *to, const void __user *from, unsigned long n)
29724 +void set_fs(mm_segment_t x)
29725 {
29726 - if (access_ok(VERIFY_READ, from, n))
29727 - n = __copy_from_user(to, from, n);
29728 - else
29729 - memset(to, 0, n);
29730 - return n;
29731 + current_thread_info()->addr_limit = x;
29732 + __set_fs(x);
29733 }
29734 -EXPORT_SYMBOL(_copy_from_user);
29735 +EXPORT_SYMBOL(set_fs);
29736 +#endif
29737 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
29738 index 906fea3..0194a18 100644
29739 --- a/arch/x86/lib/usercopy_64.c
29740 +++ b/arch/x86/lib/usercopy_64.c
29741 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29742 might_fault();
29743 /* no memory constraint because it doesn't change any memory gcc knows
29744 about */
29745 + pax_open_userland();
29746 stac();
29747 asm volatile(
29748 " testq %[size8],%[size8]\n"
29749 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
29750 _ASM_EXTABLE(0b,3b)
29751 _ASM_EXTABLE(1b,2b)
29752 : [size8] "=&c"(size), [dst] "=&D" (__d0)
29753 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
29754 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
29755 [zero] "r" (0UL), [eight] "r" (8UL));
29756 clac();
29757 + pax_close_userland();
29758 return size;
29759 }
29760 EXPORT_SYMBOL(__clear_user);
29761 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
29762 }
29763 EXPORT_SYMBOL(clear_user);
29764
29765 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
29766 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
29767 {
29768 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
29769 - return copy_user_generic((__force void *)to, (__force void *)from, len);
29770 - }
29771 - return len;
29772 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
29773 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
29774 + return len;
29775 }
29776 EXPORT_SYMBOL(copy_in_user);
29777
29778 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
29779 * it is not necessary to optimize tail handling.
29780 */
29781 unsigned long
29782 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29783 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
29784 {
29785 char c;
29786 unsigned zero_len;
29787
29788 + clac();
29789 + pax_close_userland();
29790 for (; len; --len, to++) {
29791 if (__get_user_nocheck(c, from++, sizeof(char)))
29792 break;
29793 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
29794 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
29795 if (__put_user_nocheck(c, to++, sizeof(char)))
29796 break;
29797 - clac();
29798 return len;
29799 }
29800 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
29801 index 23d8e5f..9ccc13a 100644
29802 --- a/arch/x86/mm/Makefile
29803 +++ b/arch/x86/mm/Makefile
29804 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
29805 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
29806
29807 obj-$(CONFIG_MEMTEST) += memtest.o
29808 +
29809 +quote:="
29810 +obj-$(CONFIG_X86_64) += uderef_64.o
29811 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
29812 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
29813 index 903ec1e..c4166b2 100644
29814 --- a/arch/x86/mm/extable.c
29815 +++ b/arch/x86/mm/extable.c
29816 @@ -6,12 +6,24 @@
29817 static inline unsigned long
29818 ex_insn_addr(const struct exception_table_entry *x)
29819 {
29820 - return (unsigned long)&x->insn + x->insn;
29821 + unsigned long reloc = 0;
29822 +
29823 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29824 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29825 +#endif
29826 +
29827 + return (unsigned long)&x->insn + x->insn + reloc;
29828 }
29829 static inline unsigned long
29830 ex_fixup_addr(const struct exception_table_entry *x)
29831 {
29832 - return (unsigned long)&x->fixup + x->fixup;
29833 + unsigned long reloc = 0;
29834 +
29835 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29836 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29837 +#endif
29838 +
29839 + return (unsigned long)&x->fixup + x->fixup + reloc;
29840 }
29841
29842 int fixup_exception(struct pt_regs *regs)
29843 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
29844 unsigned long new_ip;
29845
29846 #ifdef CONFIG_PNPBIOS
29847 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
29848 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
29849 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
29850 extern u32 pnp_bios_is_utter_crap;
29851 pnp_bios_is_utter_crap = 1;
29852 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
29853 i += 4;
29854 p->fixup -= i;
29855 i += 4;
29856 +
29857 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
29858 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
29859 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29860 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
29861 +#endif
29862 +
29863 }
29864 }
29865
29866 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
29867 index 654be4a..a4a3da1 100644
29868 --- a/arch/x86/mm/fault.c
29869 +++ b/arch/x86/mm/fault.c
29870 @@ -14,11 +14,18 @@
29871 #include <linux/hugetlb.h> /* hstate_index_to_shift */
29872 #include <linux/prefetch.h> /* prefetchw */
29873 #include <linux/context_tracking.h> /* exception_enter(), ... */
29874 +#include <linux/unistd.h>
29875 +#include <linux/compiler.h>
29876
29877 #include <asm/traps.h> /* dotraplinkage, ... */
29878 #include <asm/pgalloc.h> /* pgd_*(), ... */
29879 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
29880 #include <asm/fixmap.h> /* VSYSCALL_START */
29881 +#include <asm/tlbflush.h>
29882 +
29883 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29884 +#include <asm/stacktrace.h>
29885 +#endif
29886
29887 /*
29888 * Page fault error code bits:
29889 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
29890 int ret = 0;
29891
29892 /* kprobe_running() needs smp_processor_id() */
29893 - if (kprobes_built_in() && !user_mode_vm(regs)) {
29894 + if (kprobes_built_in() && !user_mode(regs)) {
29895 preempt_disable();
29896 if (kprobe_running() && kprobe_fault_handler(regs, 14))
29897 ret = 1;
29898 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
29899 return !instr_lo || (instr_lo>>1) == 1;
29900 case 0x00:
29901 /* Prefetch instruction is 0x0F0D or 0x0F18 */
29902 - if (probe_kernel_address(instr, opcode))
29903 + if (user_mode(regs)) {
29904 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29905 + return 0;
29906 + } else if (probe_kernel_address(instr, opcode))
29907 return 0;
29908
29909 *prefetch = (instr_lo == 0xF) &&
29910 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29911 while (instr < max_instr) {
29912 unsigned char opcode;
29913
29914 - if (probe_kernel_address(instr, opcode))
29915 + if (user_mode(regs)) {
29916 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29917 + break;
29918 + } else if (probe_kernel_address(instr, opcode))
29919 break;
29920
29921 instr++;
29922 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29923 force_sig_info(si_signo, &info, tsk);
29924 }
29925
29926 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29927 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29928 +#endif
29929 +
29930 +#ifdef CONFIG_PAX_EMUTRAMP
29931 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29932 +#endif
29933 +
29934 +#ifdef CONFIG_PAX_PAGEEXEC
29935 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29936 +{
29937 + pgd_t *pgd;
29938 + pud_t *pud;
29939 + pmd_t *pmd;
29940 +
29941 + pgd = pgd_offset(mm, address);
29942 + if (!pgd_present(*pgd))
29943 + return NULL;
29944 + pud = pud_offset(pgd, address);
29945 + if (!pud_present(*pud))
29946 + return NULL;
29947 + pmd = pmd_offset(pud, address);
29948 + if (!pmd_present(*pmd))
29949 + return NULL;
29950 + return pmd;
29951 +}
29952 +#endif
29953 +
29954 DEFINE_SPINLOCK(pgd_lock);
29955 LIST_HEAD(pgd_list);
29956
29957 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29958 for (address = VMALLOC_START & PMD_MASK;
29959 address >= TASK_SIZE && address < FIXADDR_TOP;
29960 address += PMD_SIZE) {
29961 +
29962 +#ifdef CONFIG_PAX_PER_CPU_PGD
29963 + unsigned long cpu;
29964 +#else
29965 struct page *page;
29966 +#endif
29967
29968 spin_lock(&pgd_lock);
29969 +
29970 +#ifdef CONFIG_PAX_PER_CPU_PGD
29971 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29972 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29973 + pmd_t *ret;
29974 +
29975 + ret = vmalloc_sync_one(pgd, address);
29976 + if (!ret)
29977 + break;
29978 + pgd = get_cpu_pgd(cpu, kernel);
29979 +#else
29980 list_for_each_entry(page, &pgd_list, lru) {
29981 + pgd_t *pgd;
29982 spinlock_t *pgt_lock;
29983 pmd_t *ret;
29984
29985 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29986 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29987
29988 spin_lock(pgt_lock);
29989 - ret = vmalloc_sync_one(page_address(page), address);
29990 + pgd = page_address(page);
29991 +#endif
29992 +
29993 + ret = vmalloc_sync_one(pgd, address);
29994 +
29995 +#ifndef CONFIG_PAX_PER_CPU_PGD
29996 spin_unlock(pgt_lock);
29997 +#endif
29998
29999 if (!ret)
30000 break;
30001 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30002 * an interrupt in the middle of a task switch..
30003 */
30004 pgd_paddr = read_cr3();
30005 +
30006 +#ifdef CONFIG_PAX_PER_CPU_PGD
30007 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30008 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30009 +#endif
30010 +
30011 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30012 if (!pmd_k)
30013 return -1;
30014 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30015 * happen within a race in page table update. In the later
30016 * case just flush:
30017 */
30018 - pgd = pgd_offset(current->active_mm, address);
30019 +
30020 pgd_ref = pgd_offset_k(address);
30021 if (pgd_none(*pgd_ref))
30022 return -1;
30023
30024 +#ifdef CONFIG_PAX_PER_CPU_PGD
30025 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30026 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30027 + if (pgd_none(*pgd)) {
30028 + set_pgd(pgd, *pgd_ref);
30029 + arch_flush_lazy_mmu_mode();
30030 + } else {
30031 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30032 + }
30033 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30034 +#else
30035 + pgd = pgd_offset(current->active_mm, address);
30036 +#endif
30037 +
30038 if (pgd_none(*pgd)) {
30039 set_pgd(pgd, *pgd_ref);
30040 arch_flush_lazy_mmu_mode();
30041 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30042 static int is_errata100(struct pt_regs *regs, unsigned long address)
30043 {
30044 #ifdef CONFIG_X86_64
30045 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30046 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30047 return 1;
30048 #endif
30049 return 0;
30050 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30051 }
30052
30053 static const char nx_warning[] = KERN_CRIT
30054 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30055 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30056
30057 static void
30058 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30059 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30060 if (!oops_may_print())
30061 return;
30062
30063 - if (error_code & PF_INSTR) {
30064 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30065 unsigned int level;
30066
30067 pte_t *pte = lookup_address(address, &level);
30068
30069 if (pte && pte_present(*pte) && !pte_exec(*pte))
30070 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30071 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30072 }
30073
30074 +#ifdef CONFIG_PAX_KERNEXEC
30075 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30076 + if (current->signal->curr_ip)
30077 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30078 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30079 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30080 + else
30081 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30082 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30083 + }
30084 +#endif
30085 +
30086 printk(KERN_ALERT "BUG: unable to handle kernel ");
30087 if (address < PAGE_SIZE)
30088 printk(KERN_CONT "NULL pointer dereference");
30089 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30090 return;
30091 }
30092 #endif
30093 +
30094 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30095 + if (pax_is_fetch_fault(regs, error_code, address)) {
30096 +
30097 +#ifdef CONFIG_PAX_EMUTRAMP
30098 + switch (pax_handle_fetch_fault(regs)) {
30099 + case 2:
30100 + return;
30101 + }
30102 +#endif
30103 +
30104 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30105 + do_group_exit(SIGKILL);
30106 + }
30107 +#endif
30108 +
30109 /* Kernel addresses are always protection faults: */
30110 if (address >= TASK_SIZE)
30111 error_code |= PF_PROT;
30112 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30113 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30114 printk(KERN_ERR
30115 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30116 - tsk->comm, tsk->pid, address);
30117 + tsk->comm, task_pid_nr(tsk), address);
30118 code = BUS_MCEERR_AR;
30119 }
30120 #endif
30121 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30122 return 1;
30123 }
30124
30125 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30126 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30127 +{
30128 + pte_t *pte;
30129 + pmd_t *pmd;
30130 + spinlock_t *ptl;
30131 + unsigned char pte_mask;
30132 +
30133 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30134 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30135 + return 0;
30136 +
30137 + /* PaX: it's our fault, let's handle it if we can */
30138 +
30139 + /* PaX: take a look at read faults before acquiring any locks */
30140 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30141 + /* instruction fetch attempt from a protected page in user mode */
30142 + up_read(&mm->mmap_sem);
30143 +
30144 +#ifdef CONFIG_PAX_EMUTRAMP
30145 + switch (pax_handle_fetch_fault(regs)) {
30146 + case 2:
30147 + return 1;
30148 + }
30149 +#endif
30150 +
30151 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30152 + do_group_exit(SIGKILL);
30153 + }
30154 +
30155 + pmd = pax_get_pmd(mm, address);
30156 + if (unlikely(!pmd))
30157 + return 0;
30158 +
30159 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30160 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30161 + pte_unmap_unlock(pte, ptl);
30162 + return 0;
30163 + }
30164 +
30165 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30166 + /* write attempt to a protected page in user mode */
30167 + pte_unmap_unlock(pte, ptl);
30168 + return 0;
30169 + }
30170 +
30171 +#ifdef CONFIG_SMP
30172 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30173 +#else
30174 + if (likely(address > get_limit(regs->cs)))
30175 +#endif
30176 + {
30177 + set_pte(pte, pte_mkread(*pte));
30178 + __flush_tlb_one(address);
30179 + pte_unmap_unlock(pte, ptl);
30180 + up_read(&mm->mmap_sem);
30181 + return 1;
30182 + }
30183 +
30184 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30185 +
30186 + /*
30187 + * PaX: fill DTLB with user rights and retry
30188 + */
30189 + __asm__ __volatile__ (
30190 + "orb %2,(%1)\n"
30191 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30192 +/*
30193 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30194 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30195 + * page fault when examined during a TLB load attempt. this is true not only
30196 + * for PTEs holding a non-present entry but also present entries that will
30197 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30198 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30199 + * for our target pages since their PTEs are simply not in the TLBs at all.
30200 +
30201 + * the best thing in omitting it is that we gain around 15-20% speed in the
30202 + * fast path of the page fault handler and can get rid of tracing since we
30203 + * can no longer flush unintended entries.
30204 + */
30205 + "invlpg (%0)\n"
30206 +#endif
30207 + __copyuser_seg"testb $0,(%0)\n"
30208 + "xorb %3,(%1)\n"
30209 + :
30210 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30211 + : "memory", "cc");
30212 + pte_unmap_unlock(pte, ptl);
30213 + up_read(&mm->mmap_sem);
30214 + return 1;
30215 +}
30216 +#endif
30217 +
30218 /*
30219 * Handle a spurious fault caused by a stale TLB entry.
30220 *
30221 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
30222 static inline int
30223 access_error(unsigned long error_code, struct vm_area_struct *vma)
30224 {
30225 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30226 + return 1;
30227 +
30228 if (error_code & PF_WRITE) {
30229 /* write, present and write, not present: */
30230 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30231 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30232 if (error_code & PF_USER)
30233 return false;
30234
30235 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30236 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30237 return false;
30238
30239 return true;
30240 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30241 {
30242 struct vm_area_struct *vma;
30243 struct task_struct *tsk;
30244 - unsigned long address;
30245 struct mm_struct *mm;
30246 int fault;
30247 int write = error_code & PF_WRITE;
30248 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
30249 (write ? FAULT_FLAG_WRITE : 0);
30250
30251 - tsk = current;
30252 - mm = tsk->mm;
30253 -
30254 /* Get the faulting address: */
30255 - address = read_cr2();
30256 + unsigned long address = read_cr2();
30257 +
30258 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30259 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30260 + if (!search_exception_tables(regs->ip)) {
30261 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30262 + bad_area_nosemaphore(regs, error_code, address);
30263 + return;
30264 + }
30265 + if (address < pax_user_shadow_base) {
30266 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30267 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30268 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30269 + } else
30270 + address -= pax_user_shadow_base;
30271 + }
30272 +#endif
30273 +
30274 + tsk = current;
30275 + mm = tsk->mm;
30276
30277 /*
30278 * Detect and handle instructions that would cause a page fault for
30279 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30280 * User-mode registers count as a user access even for any
30281 * potential system fault or CPU buglet:
30282 */
30283 - if (user_mode_vm(regs)) {
30284 + if (user_mode(regs)) {
30285 local_irq_enable();
30286 error_code |= PF_USER;
30287 } else {
30288 @@ -1142,6 +1365,11 @@ retry:
30289 might_sleep();
30290 }
30291
30292 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30293 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30294 + return;
30295 +#endif
30296 +
30297 vma = find_vma(mm, address);
30298 if (unlikely(!vma)) {
30299 bad_area(regs, error_code, address);
30300 @@ -1153,18 +1381,24 @@ retry:
30301 bad_area(regs, error_code, address);
30302 return;
30303 }
30304 - if (error_code & PF_USER) {
30305 - /*
30306 - * Accessing the stack below %sp is always a bug.
30307 - * The large cushion allows instructions like enter
30308 - * and pusha to work. ("enter $65535, $31" pushes
30309 - * 32 pointers and then decrements %sp by 65535.)
30310 - */
30311 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30312 - bad_area(regs, error_code, address);
30313 - return;
30314 - }
30315 + /*
30316 + * Accessing the stack below %sp is always a bug.
30317 + * The large cushion allows instructions like enter
30318 + * and pusha to work. ("enter $65535, $31" pushes
30319 + * 32 pointers and then decrements %sp by 65535.)
30320 + */
30321 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30322 + bad_area(regs, error_code, address);
30323 + return;
30324 }
30325 +
30326 +#ifdef CONFIG_PAX_SEGMEXEC
30327 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30328 + bad_area(regs, error_code, address);
30329 + return;
30330 + }
30331 +#endif
30332 +
30333 if (unlikely(expand_stack(vma, address))) {
30334 bad_area(regs, error_code, address);
30335 return;
30336 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30337 __do_page_fault(regs, error_code);
30338 exception_exit(prev_state);
30339 }
30340 +
30341 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30342 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30343 +{
30344 + struct mm_struct *mm = current->mm;
30345 + unsigned long ip = regs->ip;
30346 +
30347 + if (v8086_mode(regs))
30348 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30349 +
30350 +#ifdef CONFIG_PAX_PAGEEXEC
30351 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30352 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30353 + return true;
30354 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30355 + return true;
30356 + return false;
30357 + }
30358 +#endif
30359 +
30360 +#ifdef CONFIG_PAX_SEGMEXEC
30361 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30362 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30363 + return true;
30364 + return false;
30365 + }
30366 +#endif
30367 +
30368 + return false;
30369 +}
30370 +#endif
30371 +
30372 +#ifdef CONFIG_PAX_EMUTRAMP
30373 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30374 +{
30375 + int err;
30376 +
30377 + do { /* PaX: libffi trampoline emulation */
30378 + unsigned char mov, jmp;
30379 + unsigned int addr1, addr2;
30380 +
30381 +#ifdef CONFIG_X86_64
30382 + if ((regs->ip + 9) >> 32)
30383 + break;
30384 +#endif
30385 +
30386 + err = get_user(mov, (unsigned char __user *)regs->ip);
30387 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30388 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30389 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30390 +
30391 + if (err)
30392 + break;
30393 +
30394 + if (mov == 0xB8 && jmp == 0xE9) {
30395 + regs->ax = addr1;
30396 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30397 + return 2;
30398 + }
30399 + } while (0);
30400 +
30401 + do { /* PaX: gcc trampoline emulation #1 */
30402 + unsigned char mov1, mov2;
30403 + unsigned short jmp;
30404 + unsigned int addr1, addr2;
30405 +
30406 +#ifdef CONFIG_X86_64
30407 + if ((regs->ip + 11) >> 32)
30408 + break;
30409 +#endif
30410 +
30411 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30412 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30413 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30414 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30415 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30416 +
30417 + if (err)
30418 + break;
30419 +
30420 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30421 + regs->cx = addr1;
30422 + regs->ax = addr2;
30423 + regs->ip = addr2;
30424 + return 2;
30425 + }
30426 + } while (0);
30427 +
30428 + do { /* PaX: gcc trampoline emulation #2 */
30429 + unsigned char mov, jmp;
30430 + unsigned int addr1, addr2;
30431 +
30432 +#ifdef CONFIG_X86_64
30433 + if ((regs->ip + 9) >> 32)
30434 + break;
30435 +#endif
30436 +
30437 + err = get_user(mov, (unsigned char __user *)regs->ip);
30438 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30439 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30440 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30441 +
30442 + if (err)
30443 + break;
30444 +
30445 + if (mov == 0xB9 && jmp == 0xE9) {
30446 + regs->cx = addr1;
30447 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30448 + return 2;
30449 + }
30450 + } while (0);
30451 +
30452 + return 1; /* PaX in action */
30453 +}
30454 +
30455 +#ifdef CONFIG_X86_64
30456 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
30457 +{
30458 + int err;
30459 +
30460 + do { /* PaX: libffi trampoline emulation */
30461 + unsigned short mov1, mov2, jmp1;
30462 + unsigned char stcclc, jmp2;
30463 + unsigned long addr1, addr2;
30464 +
30465 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30466 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30467 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30468 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30469 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
30470 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
30471 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
30472 +
30473 + if (err)
30474 + break;
30475 +
30476 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30477 + regs->r11 = addr1;
30478 + regs->r10 = addr2;
30479 + if (stcclc == 0xF8)
30480 + regs->flags &= ~X86_EFLAGS_CF;
30481 + else
30482 + regs->flags |= X86_EFLAGS_CF;
30483 + regs->ip = addr1;
30484 + return 2;
30485 + }
30486 + } while (0);
30487 +
30488 + do { /* PaX: gcc trampoline emulation #1 */
30489 + unsigned short mov1, mov2, jmp1;
30490 + unsigned char jmp2;
30491 + unsigned int addr1;
30492 + unsigned long addr2;
30493 +
30494 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30495 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
30496 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
30497 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
30498 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
30499 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
30500 +
30501 + if (err)
30502 + break;
30503 +
30504 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30505 + regs->r11 = addr1;
30506 + regs->r10 = addr2;
30507 + regs->ip = addr1;
30508 + return 2;
30509 + }
30510 + } while (0);
30511 +
30512 + do { /* PaX: gcc trampoline emulation #2 */
30513 + unsigned short mov1, mov2, jmp1;
30514 + unsigned char jmp2;
30515 + unsigned long addr1, addr2;
30516 +
30517 + err = get_user(mov1, (unsigned short __user *)regs->ip);
30518 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
30519 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
30520 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
30521 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
30522 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
30523 +
30524 + if (err)
30525 + break;
30526 +
30527 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
30528 + regs->r11 = addr1;
30529 + regs->r10 = addr2;
30530 + regs->ip = addr1;
30531 + return 2;
30532 + }
30533 + } while (0);
30534 +
30535 + return 1; /* PaX in action */
30536 +}
30537 +#endif
30538 +
30539 +/*
30540 + * PaX: decide what to do with offenders (regs->ip = fault address)
30541 + *
30542 + * returns 1 when task should be killed
30543 + * 2 when gcc trampoline was detected
30544 + */
30545 +static int pax_handle_fetch_fault(struct pt_regs *regs)
30546 +{
30547 + if (v8086_mode(regs))
30548 + return 1;
30549 +
30550 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
30551 + return 1;
30552 +
30553 +#ifdef CONFIG_X86_32
30554 + return pax_handle_fetch_fault_32(regs);
30555 +#else
30556 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
30557 + return pax_handle_fetch_fault_32(regs);
30558 + else
30559 + return pax_handle_fetch_fault_64(regs);
30560 +#endif
30561 +}
30562 +#endif
30563 +
30564 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30565 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
30566 +{
30567 + long i;
30568 +
30569 + printk(KERN_ERR "PAX: bytes at PC: ");
30570 + for (i = 0; i < 20; i++) {
30571 + unsigned char c;
30572 + if (get_user(c, (unsigned char __force_user *)pc+i))
30573 + printk(KERN_CONT "?? ");
30574 + else
30575 + printk(KERN_CONT "%02x ", c);
30576 + }
30577 + printk("\n");
30578 +
30579 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
30580 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
30581 + unsigned long c;
30582 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
30583 +#ifdef CONFIG_X86_32
30584 + printk(KERN_CONT "???????? ");
30585 +#else
30586 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
30587 + printk(KERN_CONT "???????? ???????? ");
30588 + else
30589 + printk(KERN_CONT "???????????????? ");
30590 +#endif
30591 + } else {
30592 +#ifdef CONFIG_X86_64
30593 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
30594 + printk(KERN_CONT "%08x ", (unsigned int)c);
30595 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
30596 + } else
30597 +#endif
30598 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
30599 + }
30600 + }
30601 + printk("\n");
30602 +}
30603 +#endif
30604 +
30605 +/**
30606 + * probe_kernel_write(): safely attempt to write to a location
30607 + * @dst: address to write to
30608 + * @src: pointer to the data that shall be written
30609 + * @size: size of the data chunk
30610 + *
30611 + * Safely write to address @dst from the buffer at @src. If a kernel fault
30612 + * happens, handle that and return -EFAULT.
30613 + */
30614 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
30615 +{
30616 + long ret;
30617 + mm_segment_t old_fs = get_fs();
30618 +
30619 + set_fs(KERNEL_DS);
30620 + pagefault_disable();
30621 + pax_open_kernel();
30622 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
30623 + pax_close_kernel();
30624 + pagefault_enable();
30625 + set_fs(old_fs);
30626 +
30627 + return ret ? -EFAULT : 0;
30628 +}
30629 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
30630 index dd74e46..7d26398 100644
30631 --- a/arch/x86/mm/gup.c
30632 +++ b/arch/x86/mm/gup.c
30633 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
30634 addr = start;
30635 len = (unsigned long) nr_pages << PAGE_SHIFT;
30636 end = start + len;
30637 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30638 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
30639 (void __user *)start, len)))
30640 return 0;
30641
30642 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
30643 index 4500142..53a363c 100644
30644 --- a/arch/x86/mm/highmem_32.c
30645 +++ b/arch/x86/mm/highmem_32.c
30646 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
30647 idx = type + KM_TYPE_NR*smp_processor_id();
30648 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30649 BUG_ON(!pte_none(*(kmap_pte-idx)));
30650 +
30651 + pax_open_kernel();
30652 set_pte(kmap_pte-idx, mk_pte(page, prot));
30653 + pax_close_kernel();
30654 +
30655 arch_flush_lazy_mmu_mode();
30656
30657 return (void *)vaddr;
30658 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
30659 index 7e73e8c..11d3b86 100644
30660 --- a/arch/x86/mm/hugetlbpage.c
30661 +++ b/arch/x86/mm/hugetlbpage.c
30662 @@ -84,23 +84,30 @@ int pud_huge(pud_t pud)
30663 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
30664 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
30665 unsigned long addr, unsigned long len,
30666 - unsigned long pgoff, unsigned long flags)
30667 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30668 {
30669 struct hstate *h = hstate_file(file);
30670 struct vm_unmapped_area_info info;
30671 -
30672 +
30673 info.flags = 0;
30674 info.length = len;
30675 info.low_limit = TASK_UNMAPPED_BASE;
30676 +
30677 +#ifdef CONFIG_PAX_RANDMMAP
30678 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30679 + info.low_limit += current->mm->delta_mmap;
30680 +#endif
30681 +
30682 info.high_limit = TASK_SIZE;
30683 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30684 info.align_offset = 0;
30685 + info.threadstack_offset = offset;
30686 return vm_unmapped_area(&info);
30687 }
30688
30689 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30690 unsigned long addr0, unsigned long len,
30691 - unsigned long pgoff, unsigned long flags)
30692 + unsigned long pgoff, unsigned long flags, unsigned long offset)
30693 {
30694 struct hstate *h = hstate_file(file);
30695 struct vm_unmapped_area_info info;
30696 @@ -112,6 +119,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30697 info.high_limit = current->mm->mmap_base;
30698 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
30699 info.align_offset = 0;
30700 + info.threadstack_offset = offset;
30701 addr = vm_unmapped_area(&info);
30702
30703 /*
30704 @@ -124,6 +132,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
30705 VM_BUG_ON(addr != -ENOMEM);
30706 info.flags = 0;
30707 info.low_limit = TASK_UNMAPPED_BASE;
30708 +
30709 +#ifdef CONFIG_PAX_RANDMMAP
30710 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
30711 + info.low_limit += current->mm->delta_mmap;
30712 +#endif
30713 +
30714 info.high_limit = TASK_SIZE;
30715 addr = vm_unmapped_area(&info);
30716 }
30717 @@ -138,10 +152,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30718 struct hstate *h = hstate_file(file);
30719 struct mm_struct *mm = current->mm;
30720 struct vm_area_struct *vma;
30721 + unsigned long pax_task_size = TASK_SIZE;
30722 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
30723
30724 if (len & ~huge_page_mask(h))
30725 return -EINVAL;
30726 - if (len > TASK_SIZE)
30727 +
30728 +#ifdef CONFIG_PAX_SEGMEXEC
30729 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30730 + pax_task_size = SEGMEXEC_TASK_SIZE;
30731 +#endif
30732 +
30733 + pax_task_size -= PAGE_SIZE;
30734 +
30735 + if (len > pax_task_size)
30736 return -ENOMEM;
30737
30738 if (flags & MAP_FIXED) {
30739 @@ -150,19 +174,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
30740 return addr;
30741 }
30742
30743 +#ifdef CONFIG_PAX_RANDMMAP
30744 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
30745 +#endif
30746 +
30747 if (addr) {
30748 addr = ALIGN(addr, huge_page_size(h));
30749 vma = find_vma(mm, addr);
30750 - if (TASK_SIZE - len >= addr &&
30751 - (!vma || addr + len <= vma->vm_start))
30752 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
30753 return addr;
30754 }
30755 if (mm->get_unmapped_area == arch_get_unmapped_area)
30756 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
30757 - pgoff, flags);
30758 + pgoff, flags, offset);
30759 else
30760 return hugetlb_get_unmapped_area_topdown(file, addr, len,
30761 - pgoff, flags);
30762 + pgoff, flags, offset);
30763 }
30764
30765 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
30766 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
30767 index 04664cd..dae6e5d 100644
30768 --- a/arch/x86/mm/init.c
30769 +++ b/arch/x86/mm/init.c
30770 @@ -4,6 +4,7 @@
30771 #include <linux/swap.h>
30772 #include <linux/memblock.h>
30773 #include <linux/bootmem.h> /* for max_low_pfn */
30774 +#include <linux/tboot.h>
30775
30776 #include <asm/cacheflush.h>
30777 #include <asm/e820.h>
30778 @@ -17,6 +18,8 @@
30779 #include <asm/proto.h>
30780 #include <asm/dma.h> /* for MAX_DMA_PFN */
30781 #include <asm/microcode.h>
30782 +#include <asm/desc.h>
30783 +#include <asm/bios_ebda.h>
30784
30785 #include "mm_internal.h"
30786
30787 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
30788 early_ioremap_page_table_range_init();
30789 #endif
30790
30791 +#ifdef CONFIG_PAX_PER_CPU_PGD
30792 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
30793 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30794 + KERNEL_PGD_PTRS);
30795 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
30796 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
30797 + KERNEL_PGD_PTRS);
30798 + load_cr3(get_cpu_pgd(0, kernel));
30799 +#else
30800 load_cr3(swapper_pg_dir);
30801 +#endif
30802 +
30803 __flush_tlb_all();
30804
30805 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
30806 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
30807 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
30808 * mmio resources as well as potential bios/acpi data regions.
30809 */
30810 +
30811 +#ifdef CONFIG_GRKERNSEC_KMEM
30812 +static unsigned int ebda_start __read_only;
30813 +static unsigned int ebda_end __read_only;
30814 +#endif
30815 +
30816 int devmem_is_allowed(unsigned long pagenr)
30817 {
30818 - if (pagenr < 256)
30819 +#ifdef CONFIG_GRKERNSEC_KMEM
30820 + /* allow BDA */
30821 + if (!pagenr)
30822 return 1;
30823 + /* allow EBDA */
30824 + if (pagenr >= ebda_start && pagenr < ebda_end)
30825 + return 1;
30826 + /* if tboot is in use, allow access to its hardcoded serial log range */
30827 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
30828 + return 1;
30829 +#else
30830 + if (!pagenr)
30831 + return 1;
30832 +#ifdef CONFIG_VM86
30833 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
30834 + return 1;
30835 +#endif
30836 +#endif
30837 +
30838 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
30839 + return 1;
30840 +#ifdef CONFIG_GRKERNSEC_KMEM
30841 + /* throw out everything else below 1MB */
30842 + if (pagenr <= 256)
30843 + return 0;
30844 +#endif
30845 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
30846 return 0;
30847 if (!page_is_ram(pagenr))
30848 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
30849 #endif
30850 }
30851
30852 +#ifdef CONFIG_GRKERNSEC_KMEM
30853 +static inline void gr_init_ebda(void)
30854 +{
30855 + unsigned int ebda_addr;
30856 + unsigned int ebda_size = 0;
30857 +
30858 + ebda_addr = get_bios_ebda();
30859 + if (ebda_addr) {
30860 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
30861 + ebda_size <<= 10;
30862 + }
30863 + if (ebda_addr && ebda_size) {
30864 + ebda_start = ebda_addr >> PAGE_SHIFT;
30865 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
30866 + } else {
30867 + ebda_start = 0x9f000 >> PAGE_SHIFT;
30868 + ebda_end = 0xa0000 >> PAGE_SHIFT;
30869 + }
30870 +}
30871 +#else
30872 +static inline void gr_init_ebda(void) { }
30873 +#endif
30874 +
30875 void free_initmem(void)
30876 {
30877 +#ifdef CONFIG_PAX_KERNEXEC
30878 +#ifdef CONFIG_X86_32
30879 + /* PaX: limit KERNEL_CS to actual size */
30880 + unsigned long addr, limit;
30881 + struct desc_struct d;
30882 + int cpu;
30883 +#else
30884 + pgd_t *pgd;
30885 + pud_t *pud;
30886 + pmd_t *pmd;
30887 + unsigned long addr, end;
30888 +#endif
30889 +#endif
30890 +
30891 + gr_init_ebda();
30892 +
30893 +#ifdef CONFIG_PAX_KERNEXEC
30894 +#ifdef CONFIG_X86_32
30895 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
30896 + limit = (limit - 1UL) >> PAGE_SHIFT;
30897 +
30898 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
30899 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30900 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
30901 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
30902 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
30903 + }
30904 +
30905 + /* PaX: make KERNEL_CS read-only */
30906 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
30907 + if (!paravirt_enabled())
30908 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30909 +/*
30910 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30911 + pgd = pgd_offset_k(addr);
30912 + pud = pud_offset(pgd, addr);
30913 + pmd = pmd_offset(pud, addr);
30914 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30915 + }
30916 +*/
30917 +#ifdef CONFIG_X86_PAE
30918 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30919 +/*
30920 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30921 + pgd = pgd_offset_k(addr);
30922 + pud = pud_offset(pgd, addr);
30923 + pmd = pmd_offset(pud, addr);
30924 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30925 + }
30926 +*/
30927 +#endif
30928 +
30929 +#ifdef CONFIG_MODULES
30930 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30931 +#endif
30932 +
30933 +#else
30934 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30935 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30936 + pgd = pgd_offset_k(addr);
30937 + pud = pud_offset(pgd, addr);
30938 + pmd = pmd_offset(pud, addr);
30939 + if (!pmd_present(*pmd))
30940 + continue;
30941 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30942 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30943 + else
30944 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30945 + }
30946 +
30947 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30948 + end = addr + KERNEL_IMAGE_SIZE;
30949 + for (; addr < end; addr += PMD_SIZE) {
30950 + pgd = pgd_offset_k(addr);
30951 + pud = pud_offset(pgd, addr);
30952 + pmd = pmd_offset(pud, addr);
30953 + if (!pmd_present(*pmd))
30954 + continue;
30955 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30956 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30957 + }
30958 +#endif
30959 +
30960 + flush_tlb_all();
30961 +#endif
30962 +
30963 free_init_pages("unused kernel",
30964 (unsigned long)(&__init_begin),
30965 (unsigned long)(&__init_end));
30966 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30967 index 4287f1f..3b99c71 100644
30968 --- a/arch/x86/mm/init_32.c
30969 +++ b/arch/x86/mm/init_32.c
30970 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30971 bool __read_mostly __vmalloc_start_set = false;
30972
30973 /*
30974 - * Creates a middle page table and puts a pointer to it in the
30975 - * given global directory entry. This only returns the gd entry
30976 - * in non-PAE compilation mode, since the middle layer is folded.
30977 - */
30978 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30979 -{
30980 - pud_t *pud;
30981 - pmd_t *pmd_table;
30982 -
30983 -#ifdef CONFIG_X86_PAE
30984 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30985 - pmd_table = (pmd_t *)alloc_low_page();
30986 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30987 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30988 - pud = pud_offset(pgd, 0);
30989 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30990 -
30991 - return pmd_table;
30992 - }
30993 -#endif
30994 - pud = pud_offset(pgd, 0);
30995 - pmd_table = pmd_offset(pud, 0);
30996 -
30997 - return pmd_table;
30998 -}
30999 -
31000 -/*
31001 * Create a page table and place a pointer to it in a middle page
31002 * directory entry:
31003 */
31004 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
31005 pte_t *page_table = (pte_t *)alloc_low_page();
31006
31007 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31008 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31009 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31010 +#else
31011 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31012 +#endif
31013 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31014 }
31015
31016 return pte_offset_kernel(pmd, 0);
31017 }
31018
31019 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31020 +{
31021 + pud_t *pud;
31022 + pmd_t *pmd_table;
31023 +
31024 + pud = pud_offset(pgd, 0);
31025 + pmd_table = pmd_offset(pud, 0);
31026 +
31027 + return pmd_table;
31028 +}
31029 +
31030 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31031 {
31032 int pgd_idx = pgd_index(vaddr);
31033 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31034 int pgd_idx, pmd_idx;
31035 unsigned long vaddr;
31036 pgd_t *pgd;
31037 + pud_t *pud;
31038 pmd_t *pmd;
31039 pte_t *pte = NULL;
31040 unsigned long count = page_table_range_init_count(start, end);
31041 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31042 pgd = pgd_base + pgd_idx;
31043
31044 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31045 - pmd = one_md_table_init(pgd);
31046 - pmd = pmd + pmd_index(vaddr);
31047 + pud = pud_offset(pgd, vaddr);
31048 + pmd = pmd_offset(pud, vaddr);
31049 +
31050 +#ifdef CONFIG_X86_PAE
31051 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31052 +#endif
31053 +
31054 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31055 pmd++, pmd_idx++) {
31056 pte = page_table_kmap_check(one_page_table_init(pmd),
31057 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31058 }
31059 }
31060
31061 -static inline int is_kernel_text(unsigned long addr)
31062 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31063 {
31064 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31065 - return 1;
31066 - return 0;
31067 + if ((start > ktla_ktva((unsigned long)_etext) ||
31068 + end <= ktla_ktva((unsigned long)_stext)) &&
31069 + (start > ktla_ktva((unsigned long)_einittext) ||
31070 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31071 +
31072 +#ifdef CONFIG_ACPI_SLEEP
31073 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31074 +#endif
31075 +
31076 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31077 + return 0;
31078 + return 1;
31079 }
31080
31081 /*
31082 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31083 unsigned long last_map_addr = end;
31084 unsigned long start_pfn, end_pfn;
31085 pgd_t *pgd_base = swapper_pg_dir;
31086 - int pgd_idx, pmd_idx, pte_ofs;
31087 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31088 unsigned long pfn;
31089 pgd_t *pgd;
31090 + pud_t *pud;
31091 pmd_t *pmd;
31092 pte_t *pte;
31093 unsigned pages_2m, pages_4k;
31094 @@ -291,8 +295,13 @@ repeat:
31095 pfn = start_pfn;
31096 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31097 pgd = pgd_base + pgd_idx;
31098 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31099 - pmd = one_md_table_init(pgd);
31100 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31101 + pud = pud_offset(pgd, 0);
31102 + pmd = pmd_offset(pud, 0);
31103 +
31104 +#ifdef CONFIG_X86_PAE
31105 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31106 +#endif
31107
31108 if (pfn >= end_pfn)
31109 continue;
31110 @@ -304,14 +313,13 @@ repeat:
31111 #endif
31112 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31113 pmd++, pmd_idx++) {
31114 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31115 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31116
31117 /*
31118 * Map with big pages if possible, otherwise
31119 * create normal page tables:
31120 */
31121 if (use_pse) {
31122 - unsigned int addr2;
31123 pgprot_t prot = PAGE_KERNEL_LARGE;
31124 /*
31125 * first pass will use the same initial
31126 @@ -322,11 +330,7 @@ repeat:
31127 _PAGE_PSE);
31128
31129 pfn &= PMD_MASK >> PAGE_SHIFT;
31130 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31131 - PAGE_OFFSET + PAGE_SIZE-1;
31132 -
31133 - if (is_kernel_text(addr) ||
31134 - is_kernel_text(addr2))
31135 + if (is_kernel_text(address, address + PMD_SIZE))
31136 prot = PAGE_KERNEL_LARGE_EXEC;
31137
31138 pages_2m++;
31139 @@ -343,7 +347,7 @@ repeat:
31140 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31141 pte += pte_ofs;
31142 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31143 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31144 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31145 pgprot_t prot = PAGE_KERNEL;
31146 /*
31147 * first pass will use the same initial
31148 @@ -351,7 +355,7 @@ repeat:
31149 */
31150 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31151
31152 - if (is_kernel_text(addr))
31153 + if (is_kernel_text(address, address + PAGE_SIZE))
31154 prot = PAGE_KERNEL_EXEC;
31155
31156 pages_4k++;
31157 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31158
31159 pud = pud_offset(pgd, va);
31160 pmd = pmd_offset(pud, va);
31161 - if (!pmd_present(*pmd))
31162 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31163 break;
31164
31165 /* should not be large page here */
31166 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31167
31168 static void __init pagetable_init(void)
31169 {
31170 - pgd_t *pgd_base = swapper_pg_dir;
31171 -
31172 - permanent_kmaps_init(pgd_base);
31173 + permanent_kmaps_init(swapper_pg_dir);
31174 }
31175
31176 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31177 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31178 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31179
31180 /* user-defined highmem size */
31181 @@ -787,10 +789,10 @@ void __init mem_init(void)
31182 ((unsigned long)&__init_end -
31183 (unsigned long)&__init_begin) >> 10,
31184
31185 - (unsigned long)&_etext, (unsigned long)&_edata,
31186 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31187 + (unsigned long)&_sdata, (unsigned long)&_edata,
31188 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31189
31190 - (unsigned long)&_text, (unsigned long)&_etext,
31191 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31192 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31193
31194 /*
31195 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31196 if (!kernel_set_to_readonly)
31197 return;
31198
31199 + start = ktla_ktva(start);
31200 pr_debug("Set kernel text: %lx - %lx for read write\n",
31201 start, start+size);
31202
31203 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31204 if (!kernel_set_to_readonly)
31205 return;
31206
31207 + start = ktla_ktva(start);
31208 pr_debug("Set kernel text: %lx - %lx for read only\n",
31209 start, start+size);
31210
31211 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31212 unsigned long start = PFN_ALIGN(_text);
31213 unsigned long size = PFN_ALIGN(_etext) - start;
31214
31215 + start = ktla_ktva(start);
31216 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31217 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31218 size >> 10);
31219 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31220 index 104d56a..62ba13f1 100644
31221 --- a/arch/x86/mm/init_64.c
31222 +++ b/arch/x86/mm/init_64.c
31223 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31224 * around without checking the pgd every time.
31225 */
31226
31227 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31228 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31229 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31230
31231 int force_personality32;
31232 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31233
31234 for (address = start; address <= end; address += PGDIR_SIZE) {
31235 const pgd_t *pgd_ref = pgd_offset_k(address);
31236 +
31237 +#ifdef CONFIG_PAX_PER_CPU_PGD
31238 + unsigned long cpu;
31239 +#else
31240 struct page *page;
31241 +#endif
31242
31243 if (pgd_none(*pgd_ref))
31244 continue;
31245
31246 spin_lock(&pgd_lock);
31247 +
31248 +#ifdef CONFIG_PAX_PER_CPU_PGD
31249 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31250 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31251 +
31252 + if (pgd_none(*pgd))
31253 + set_pgd(pgd, *pgd_ref);
31254 + else
31255 + BUG_ON(pgd_page_vaddr(*pgd)
31256 + != pgd_page_vaddr(*pgd_ref));
31257 + pgd = pgd_offset_cpu(cpu, kernel, address);
31258 +#else
31259 list_for_each_entry(page, &pgd_list, lru) {
31260 pgd_t *pgd;
31261 spinlock_t *pgt_lock;
31262 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31263 /* the pgt_lock only for Xen */
31264 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31265 spin_lock(pgt_lock);
31266 +#endif
31267
31268 if (pgd_none(*pgd))
31269 set_pgd(pgd, *pgd_ref);
31270 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31271 BUG_ON(pgd_page_vaddr(*pgd)
31272 != pgd_page_vaddr(*pgd_ref));
31273
31274 +#ifndef CONFIG_PAX_PER_CPU_PGD
31275 spin_unlock(pgt_lock);
31276 +#endif
31277 +
31278 }
31279 spin_unlock(&pgd_lock);
31280 }
31281 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31282 {
31283 if (pgd_none(*pgd)) {
31284 pud_t *pud = (pud_t *)spp_getpage();
31285 - pgd_populate(&init_mm, pgd, pud);
31286 + pgd_populate_kernel(&init_mm, pgd, pud);
31287 if (pud != pud_offset(pgd, 0))
31288 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31289 pud, pud_offset(pgd, 0));
31290 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31291 {
31292 if (pud_none(*pud)) {
31293 pmd_t *pmd = (pmd_t *) spp_getpage();
31294 - pud_populate(&init_mm, pud, pmd);
31295 + pud_populate_kernel(&init_mm, pud, pmd);
31296 if (pmd != pmd_offset(pud, 0))
31297 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31298 pmd, pmd_offset(pud, 0));
31299 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31300 pmd = fill_pmd(pud, vaddr);
31301 pte = fill_pte(pmd, vaddr);
31302
31303 + pax_open_kernel();
31304 set_pte(pte, new_pte);
31305 + pax_close_kernel();
31306
31307 /*
31308 * It's enough to flush this one mapping.
31309 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31310 pgd = pgd_offset_k((unsigned long)__va(phys));
31311 if (pgd_none(*pgd)) {
31312 pud = (pud_t *) spp_getpage();
31313 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31314 - _PAGE_USER));
31315 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31316 }
31317 pud = pud_offset(pgd, (unsigned long)__va(phys));
31318 if (pud_none(*pud)) {
31319 pmd = (pmd_t *) spp_getpage();
31320 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31321 - _PAGE_USER));
31322 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31323 }
31324 pmd = pmd_offset(pud, phys);
31325 BUG_ON(!pmd_none(*pmd));
31326 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31327 prot);
31328
31329 spin_lock(&init_mm.page_table_lock);
31330 - pud_populate(&init_mm, pud, pmd);
31331 + pud_populate_kernel(&init_mm, pud, pmd);
31332 spin_unlock(&init_mm.page_table_lock);
31333 }
31334 __flush_tlb_all();
31335 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31336 page_size_mask);
31337
31338 spin_lock(&init_mm.page_table_lock);
31339 - pgd_populate(&init_mm, pgd, pud);
31340 + pgd_populate_kernel(&init_mm, pgd, pud);
31341 spin_unlock(&init_mm.page_table_lock);
31342 pgd_changed = true;
31343 }
31344 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31345 static struct vm_area_struct gate_vma = {
31346 .vm_start = VSYSCALL_START,
31347 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31348 - .vm_page_prot = PAGE_READONLY_EXEC,
31349 - .vm_flags = VM_READ | VM_EXEC
31350 + .vm_page_prot = PAGE_READONLY,
31351 + .vm_flags = VM_READ
31352 };
31353
31354 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31355 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31356
31357 const char *arch_vma_name(struct vm_area_struct *vma)
31358 {
31359 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31360 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31361 return "[vdso]";
31362 if (vma == &gate_vma)
31363 return "[vsyscall]";
31364 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31365 index 7b179b4..6bd17777 100644
31366 --- a/arch/x86/mm/iomap_32.c
31367 +++ b/arch/x86/mm/iomap_32.c
31368 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31369 type = kmap_atomic_idx_push();
31370 idx = type + KM_TYPE_NR * smp_processor_id();
31371 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31372 +
31373 + pax_open_kernel();
31374 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31375 + pax_close_kernel();
31376 +
31377 arch_flush_lazy_mmu_mode();
31378
31379 return (void *)vaddr;
31380 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31381 index 0215e2c..1c62dab 100644
31382 --- a/arch/x86/mm/ioremap.c
31383 +++ b/arch/x86/mm/ioremap.c
31384 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31385 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31386 int is_ram = page_is_ram(pfn);
31387
31388 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31389 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31390 return NULL;
31391 WARN_ON_ONCE(is_ram);
31392 }
31393 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31394 *
31395 * Caller must ensure there is only one unmapping for the same pointer.
31396 */
31397 -void iounmap(volatile void __iomem *addr)
31398 +void iounmap(const volatile void __iomem *addr)
31399 {
31400 struct vm_struct *p, *o;
31401
31402 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31403
31404 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31405 if (page_is_ram(start >> PAGE_SHIFT))
31406 +#ifdef CONFIG_HIGHMEM
31407 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31408 +#endif
31409 return __va(phys);
31410
31411 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
31412 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31413 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
31414 {
31415 if (page_is_ram(phys >> PAGE_SHIFT))
31416 +#ifdef CONFIG_HIGHMEM
31417 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
31418 +#endif
31419 return;
31420
31421 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
31422 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
31423 early_param("early_ioremap_debug", early_ioremap_debug_setup);
31424
31425 static __initdata int after_paging_init;
31426 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
31427 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
31428
31429 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
31430 {
31431 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
31432 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
31433
31434 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
31435 - memset(bm_pte, 0, sizeof(bm_pte));
31436 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
31437 + pmd_populate_user(&init_mm, pmd, bm_pte);
31438
31439 /*
31440 * The boot-ioremap range spans multiple pmds, for which
31441 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
31442 index d87dd6d..bf3fa66 100644
31443 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
31444 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
31445 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
31446 * memory (e.g. tracked pages)? For now, we need this to avoid
31447 * invoking kmemcheck for PnP BIOS calls.
31448 */
31449 - if (regs->flags & X86_VM_MASK)
31450 + if (v8086_mode(regs))
31451 return false;
31452 - if (regs->cs != __KERNEL_CS)
31453 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
31454 return false;
31455
31456 pte = kmemcheck_pte_lookup(address);
31457 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
31458 index 25e7e13..1964579 100644
31459 --- a/arch/x86/mm/mmap.c
31460 +++ b/arch/x86/mm/mmap.c
31461 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
31462 * Leave an at least ~128 MB hole with possible stack randomization.
31463 */
31464 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
31465 -#define MAX_GAP (TASK_SIZE/6*5)
31466 +#define MAX_GAP (pax_task_size/6*5)
31467
31468 static int mmap_is_legacy(void)
31469 {
31470 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
31471 return rnd << PAGE_SHIFT;
31472 }
31473
31474 -static unsigned long mmap_base(void)
31475 +static unsigned long mmap_base(struct mm_struct *mm)
31476 {
31477 unsigned long gap = rlimit(RLIMIT_STACK);
31478 + unsigned long pax_task_size = TASK_SIZE;
31479 +
31480 +#ifdef CONFIG_PAX_SEGMEXEC
31481 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31482 + pax_task_size = SEGMEXEC_TASK_SIZE;
31483 +#endif
31484
31485 if (gap < MIN_GAP)
31486 gap = MIN_GAP;
31487 else if (gap > MAX_GAP)
31488 gap = MAX_GAP;
31489
31490 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
31491 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
31492 }
31493
31494 /*
31495 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
31496 * does, but not when emulating X86_32
31497 */
31498 -static unsigned long mmap_legacy_base(void)
31499 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
31500 {
31501 - if (mmap_is_ia32())
31502 + if (mmap_is_ia32()) {
31503 +
31504 +#ifdef CONFIG_PAX_SEGMEXEC
31505 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31506 + return SEGMEXEC_TASK_UNMAPPED_BASE;
31507 + else
31508 +#endif
31509 +
31510 return TASK_UNMAPPED_BASE;
31511 - else
31512 + } else
31513 return TASK_UNMAPPED_BASE + mmap_rnd();
31514 }
31515
31516 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
31517 */
31518 void arch_pick_mmap_layout(struct mm_struct *mm)
31519 {
31520 - mm->mmap_legacy_base = mmap_legacy_base();
31521 - mm->mmap_base = mmap_base();
31522 + mm->mmap_legacy_base = mmap_legacy_base(mm);
31523 + mm->mmap_base = mmap_base(mm);
31524 +
31525 +#ifdef CONFIG_PAX_RANDMMAP
31526 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
31527 + mm->mmap_legacy_base += mm->delta_mmap;
31528 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
31529 + }
31530 +#endif
31531
31532 if (mmap_is_legacy()) {
31533 mm->mmap_base = mm->mmap_legacy_base;
31534 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
31535 index 0057a7a..95c7edd 100644
31536 --- a/arch/x86/mm/mmio-mod.c
31537 +++ b/arch/x86/mm/mmio-mod.c
31538 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
31539 break;
31540 default:
31541 {
31542 - unsigned char *ip = (unsigned char *)instptr;
31543 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
31544 my_trace->opcode = MMIO_UNKNOWN_OP;
31545 my_trace->width = 0;
31546 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
31547 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
31548 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31549 void __iomem *addr)
31550 {
31551 - static atomic_t next_id;
31552 + static atomic_unchecked_t next_id;
31553 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
31554 /* These are page-unaligned. */
31555 struct mmiotrace_map map = {
31556 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
31557 .private = trace
31558 },
31559 .phys = offset,
31560 - .id = atomic_inc_return(&next_id)
31561 + .id = atomic_inc_return_unchecked(&next_id)
31562 };
31563 map.map_id = trace->id;
31564
31565 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
31566 ioremap_trace_core(offset, size, addr);
31567 }
31568
31569 -static void iounmap_trace_core(volatile void __iomem *addr)
31570 +static void iounmap_trace_core(const volatile void __iomem *addr)
31571 {
31572 struct mmiotrace_map map = {
31573 .phys = 0,
31574 @@ -328,7 +328,7 @@ not_enabled:
31575 }
31576 }
31577
31578 -void mmiotrace_iounmap(volatile void __iomem *addr)
31579 +void mmiotrace_iounmap(const volatile void __iomem *addr)
31580 {
31581 might_sleep();
31582 if (is_enabled()) /* recheck and proper locking in *_core() */
31583 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
31584 index 8bf93ba..dbcd670 100644
31585 --- a/arch/x86/mm/numa.c
31586 +++ b/arch/x86/mm/numa.c
31587 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
31588 return true;
31589 }
31590
31591 -static int __init numa_register_memblks(struct numa_meminfo *mi)
31592 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
31593 {
31594 unsigned long uninitialized_var(pfn_align);
31595 int i, nid;
31596 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
31597 index d0b1773..4c3327c 100644
31598 --- a/arch/x86/mm/pageattr-test.c
31599 +++ b/arch/x86/mm/pageattr-test.c
31600 @@ -36,7 +36,7 @@ enum {
31601
31602 static int pte_testbit(pte_t pte)
31603 {
31604 - return pte_flags(pte) & _PAGE_UNUSED1;
31605 + return pte_flags(pte) & _PAGE_CPA_TEST;
31606 }
31607
31608 struct split_state {
31609 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
31610 index bb32480..75f2f5e 100644
31611 --- a/arch/x86/mm/pageattr.c
31612 +++ b/arch/x86/mm/pageattr.c
31613 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31614 */
31615 #ifdef CONFIG_PCI_BIOS
31616 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
31617 - pgprot_val(forbidden) |= _PAGE_NX;
31618 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31619 #endif
31620
31621 /*
31622 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31623 * Does not cover __inittext since that is gone later on. On
31624 * 64bit we do not enforce !NX on the low mapping
31625 */
31626 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
31627 - pgprot_val(forbidden) |= _PAGE_NX;
31628 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
31629 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31630
31631 +#ifdef CONFIG_DEBUG_RODATA
31632 /*
31633 * The .rodata section needs to be read-only. Using the pfn
31634 * catches all aliases.
31635 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31636 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
31637 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
31638 pgprot_val(forbidden) |= _PAGE_RW;
31639 +#endif
31640
31641 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
31642 /*
31643 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
31644 }
31645 #endif
31646
31647 +#ifdef CONFIG_PAX_KERNEXEC
31648 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
31649 + pgprot_val(forbidden) |= _PAGE_RW;
31650 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
31651 + }
31652 +#endif
31653 +
31654 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
31655
31656 return prot;
31657 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
31658 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
31659 {
31660 /* change init_mm */
31661 + pax_open_kernel();
31662 set_pte_atomic(kpte, pte);
31663 +
31664 #ifdef CONFIG_X86_32
31665 if (!SHARED_KERNEL_PMD) {
31666 +
31667 +#ifdef CONFIG_PAX_PER_CPU_PGD
31668 + unsigned long cpu;
31669 +#else
31670 struct page *page;
31671 +#endif
31672
31673 +#ifdef CONFIG_PAX_PER_CPU_PGD
31674 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31675 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
31676 +#else
31677 list_for_each_entry(page, &pgd_list, lru) {
31678 - pgd_t *pgd;
31679 + pgd_t *pgd = (pgd_t *)page_address(page);
31680 +#endif
31681 +
31682 pud_t *pud;
31683 pmd_t *pmd;
31684
31685 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
31686 + pgd += pgd_index(address);
31687 pud = pud_offset(pgd, address);
31688 pmd = pmd_offset(pud, address);
31689 set_pte_atomic((pte_t *)pmd, pte);
31690 }
31691 }
31692 #endif
31693 + pax_close_kernel();
31694 }
31695
31696 static int
31697 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
31698 index 6574388..87e9bef 100644
31699 --- a/arch/x86/mm/pat.c
31700 +++ b/arch/x86/mm/pat.c
31701 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
31702
31703 if (!entry) {
31704 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
31705 - current->comm, current->pid, start, end - 1);
31706 + current->comm, task_pid_nr(current), start, end - 1);
31707 return -EINVAL;
31708 }
31709
31710 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
31711
31712 while (cursor < to) {
31713 if (!devmem_is_allowed(pfn)) {
31714 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
31715 - current->comm, from, to - 1);
31716 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
31717 + current->comm, from, to - 1, cursor);
31718 return 0;
31719 }
31720 cursor += PAGE_SIZE;
31721 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
31722 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
31723 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
31724 "for [mem %#010Lx-%#010Lx]\n",
31725 - current->comm, current->pid,
31726 + current->comm, task_pid_nr(current),
31727 cattr_name(flags),
31728 base, (unsigned long long)(base + size-1));
31729 return -EINVAL;
31730 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31731 flags = lookup_memtype(paddr);
31732 if (want_flags != flags) {
31733 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
31734 - current->comm, current->pid,
31735 + current->comm, task_pid_nr(current),
31736 cattr_name(want_flags),
31737 (unsigned long long)paddr,
31738 (unsigned long long)(paddr + size - 1),
31739 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
31740 free_memtype(paddr, paddr + size);
31741 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
31742 " for [mem %#010Lx-%#010Lx], got %s\n",
31743 - current->comm, current->pid,
31744 + current->comm, task_pid_nr(current),
31745 cattr_name(want_flags),
31746 (unsigned long long)paddr,
31747 (unsigned long long)(paddr + size - 1),
31748 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
31749 index 415f6c4..d319983 100644
31750 --- a/arch/x86/mm/pat_rbtree.c
31751 +++ b/arch/x86/mm/pat_rbtree.c
31752 @@ -160,7 +160,7 @@ success:
31753
31754 failure:
31755 printk(KERN_INFO "%s:%d conflicting memory types "
31756 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
31757 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
31758 end, cattr_name(found_type), cattr_name(match->type));
31759 return -EBUSY;
31760 }
31761 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
31762 index 9f0614d..92ae64a 100644
31763 --- a/arch/x86/mm/pf_in.c
31764 +++ b/arch/x86/mm/pf_in.c
31765 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
31766 int i;
31767 enum reason_type rv = OTHERS;
31768
31769 - p = (unsigned char *)ins_addr;
31770 + p = (unsigned char *)ktla_ktva(ins_addr);
31771 p += skip_prefix(p, &prf);
31772 p += get_opcode(p, &opcode);
31773
31774 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
31775 struct prefix_bits prf;
31776 int i;
31777
31778 - p = (unsigned char *)ins_addr;
31779 + p = (unsigned char *)ktla_ktva(ins_addr);
31780 p += skip_prefix(p, &prf);
31781 p += get_opcode(p, &opcode);
31782
31783 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
31784 struct prefix_bits prf;
31785 int i;
31786
31787 - p = (unsigned char *)ins_addr;
31788 + p = (unsigned char *)ktla_ktva(ins_addr);
31789 p += skip_prefix(p, &prf);
31790 p += get_opcode(p, &opcode);
31791
31792 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
31793 struct prefix_bits prf;
31794 int i;
31795
31796 - p = (unsigned char *)ins_addr;
31797 + p = (unsigned char *)ktla_ktva(ins_addr);
31798 p += skip_prefix(p, &prf);
31799 p += get_opcode(p, &opcode);
31800 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
31801 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
31802 struct prefix_bits prf;
31803 int i;
31804
31805 - p = (unsigned char *)ins_addr;
31806 + p = (unsigned char *)ktla_ktva(ins_addr);
31807 p += skip_prefix(p, &prf);
31808 p += get_opcode(p, &opcode);
31809 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
31810 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
31811 index dfa537a..fd45c64 100644
31812 --- a/arch/x86/mm/pgtable.c
31813 +++ b/arch/x86/mm/pgtable.c
31814 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
31815 list_del(&page->lru);
31816 }
31817
31818 -#define UNSHARED_PTRS_PER_PGD \
31819 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31820 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31821 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
31822
31823 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
31824 +{
31825 + unsigned int count = USER_PGD_PTRS;
31826
31827 + if (!pax_user_shadow_base)
31828 + return;
31829 +
31830 + while (count--)
31831 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
31832 +}
31833 +#endif
31834 +
31835 +#ifdef CONFIG_PAX_PER_CPU_PGD
31836 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
31837 +{
31838 + unsigned int count = USER_PGD_PTRS;
31839 +
31840 + while (count--) {
31841 + pgd_t pgd;
31842 +
31843 +#ifdef CONFIG_X86_64
31844 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
31845 +#else
31846 + pgd = *src++;
31847 +#endif
31848 +
31849 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
31850 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
31851 +#endif
31852 +
31853 + *dst++ = pgd;
31854 + }
31855 +
31856 +}
31857 +#endif
31858 +
31859 +#ifdef CONFIG_X86_64
31860 +#define pxd_t pud_t
31861 +#define pyd_t pgd_t
31862 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
31863 +#define pxd_free(mm, pud) pud_free((mm), (pud))
31864 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
31865 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
31866 +#define PYD_SIZE PGDIR_SIZE
31867 +#else
31868 +#define pxd_t pmd_t
31869 +#define pyd_t pud_t
31870 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
31871 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
31872 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
31873 +#define pyd_offset(mm, address) pud_offset((mm), (address))
31874 +#define PYD_SIZE PUD_SIZE
31875 +#endif
31876 +
31877 +#ifdef CONFIG_PAX_PER_CPU_PGD
31878 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
31879 +static inline void pgd_dtor(pgd_t *pgd) {}
31880 +#else
31881 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
31882 {
31883 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
31884 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
31885 pgd_list_del(pgd);
31886 spin_unlock(&pgd_lock);
31887 }
31888 +#endif
31889
31890 /*
31891 * List of all pgd's needed for non-PAE so it can invalidate entries
31892 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31893 * -- nyc
31894 */
31895
31896 -#ifdef CONFIG_X86_PAE
31897 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31898 /*
31899 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31900 * updating the top-level pagetable entries to guarantee the
31901 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31902 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31903 * and initialize the kernel pmds here.
31904 */
31905 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31906 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31907
31908 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31909 {
31910 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31911 */
31912 flush_tlb_mm(mm);
31913 }
31914 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31915 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31916 #else /* !CONFIG_X86_PAE */
31917
31918 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31919 -#define PREALLOCATED_PMDS 0
31920 +#define PREALLOCATED_PXDS 0
31921
31922 #endif /* CONFIG_X86_PAE */
31923
31924 -static void free_pmds(pmd_t *pmds[])
31925 +static void free_pxds(pxd_t *pxds[])
31926 {
31927 int i;
31928
31929 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31930 - if (pmds[i])
31931 - free_page((unsigned long)pmds[i]);
31932 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31933 + if (pxds[i])
31934 + free_page((unsigned long)pxds[i]);
31935 }
31936
31937 -static int preallocate_pmds(pmd_t *pmds[])
31938 +static int preallocate_pxds(pxd_t *pxds[])
31939 {
31940 int i;
31941 bool failed = false;
31942
31943 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31944 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31945 - if (pmd == NULL)
31946 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31947 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31948 + if (pxd == NULL)
31949 failed = true;
31950 - pmds[i] = pmd;
31951 + pxds[i] = pxd;
31952 }
31953
31954 if (failed) {
31955 - free_pmds(pmds);
31956 + free_pxds(pxds);
31957 return -ENOMEM;
31958 }
31959
31960 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
31961 * preallocate which never got a corresponding vma will need to be
31962 * freed manually.
31963 */
31964 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31965 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31966 {
31967 int i;
31968
31969 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31970 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31971 pgd_t pgd = pgdp[i];
31972
31973 if (pgd_val(pgd) != 0) {
31974 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31975 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31976
31977 - pgdp[i] = native_make_pgd(0);
31978 + set_pgd(pgdp + i, native_make_pgd(0));
31979
31980 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31981 - pmd_free(mm, pmd);
31982 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31983 + pxd_free(mm, pxd);
31984 }
31985 }
31986 }
31987
31988 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31989 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31990 {
31991 - pud_t *pud;
31992 + pyd_t *pyd;
31993 int i;
31994
31995 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31996 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31997 return;
31998
31999 - pud = pud_offset(pgd, 0);
32000 -
32001 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
32002 - pmd_t *pmd = pmds[i];
32003 +#ifdef CONFIG_X86_64
32004 + pyd = pyd_offset(mm, 0L);
32005 +#else
32006 + pyd = pyd_offset(pgd, 0L);
32007 +#endif
32008
32009 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
32010 + pxd_t *pxd = pxds[i];
32011 if (i >= KERNEL_PGD_BOUNDARY)
32012 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32013 - sizeof(pmd_t) * PTRS_PER_PMD);
32014 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32015 + sizeof(pxd_t) * PTRS_PER_PMD);
32016
32017 - pud_populate(mm, pud, pmd);
32018 + pyd_populate(mm, pyd, pxd);
32019 }
32020 }
32021
32022 pgd_t *pgd_alloc(struct mm_struct *mm)
32023 {
32024 pgd_t *pgd;
32025 - pmd_t *pmds[PREALLOCATED_PMDS];
32026 + pxd_t *pxds[PREALLOCATED_PXDS];
32027
32028 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32029
32030 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32031
32032 mm->pgd = pgd;
32033
32034 - if (preallocate_pmds(pmds) != 0)
32035 + if (preallocate_pxds(pxds) != 0)
32036 goto out_free_pgd;
32037
32038 if (paravirt_pgd_alloc(mm) != 0)
32039 - goto out_free_pmds;
32040 + goto out_free_pxds;
32041
32042 /*
32043 * Make sure that pre-populating the pmds is atomic with
32044 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32045 spin_lock(&pgd_lock);
32046
32047 pgd_ctor(mm, pgd);
32048 - pgd_prepopulate_pmd(mm, pgd, pmds);
32049 + pgd_prepopulate_pxd(mm, pgd, pxds);
32050
32051 spin_unlock(&pgd_lock);
32052
32053 return pgd;
32054
32055 -out_free_pmds:
32056 - free_pmds(pmds);
32057 +out_free_pxds:
32058 + free_pxds(pxds);
32059 out_free_pgd:
32060 free_page((unsigned long)pgd);
32061 out:
32062 @@ -300,7 +363,7 @@ out:
32063
32064 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32065 {
32066 - pgd_mop_up_pmds(mm, pgd);
32067 + pgd_mop_up_pxds(mm, pgd);
32068 pgd_dtor(pgd);
32069 paravirt_pgd_free(mm, pgd);
32070 free_page((unsigned long)pgd);
32071 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32072 index a69bcb8..19068ab 100644
32073 --- a/arch/x86/mm/pgtable_32.c
32074 +++ b/arch/x86/mm/pgtable_32.c
32075 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32076 return;
32077 }
32078 pte = pte_offset_kernel(pmd, vaddr);
32079 +
32080 + pax_open_kernel();
32081 if (pte_val(pteval))
32082 set_pte_at(&init_mm, vaddr, pte, pteval);
32083 else
32084 pte_clear(&init_mm, vaddr, pte);
32085 + pax_close_kernel();
32086
32087 /*
32088 * It's enough to flush this one mapping.
32089 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32090 index e666cbb..61788c45 100644
32091 --- a/arch/x86/mm/physaddr.c
32092 +++ b/arch/x86/mm/physaddr.c
32093 @@ -10,7 +10,7 @@
32094 #ifdef CONFIG_X86_64
32095
32096 #ifdef CONFIG_DEBUG_VIRTUAL
32097 -unsigned long __phys_addr(unsigned long x)
32098 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32099 {
32100 unsigned long y = x - __START_KERNEL_map;
32101
32102 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32103 #else
32104
32105 #ifdef CONFIG_DEBUG_VIRTUAL
32106 -unsigned long __phys_addr(unsigned long x)
32107 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32108 {
32109 unsigned long phys_addr = x - PAGE_OFFSET;
32110 /* VMALLOC_* aren't constants */
32111 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32112 index 90555bf..f5f1828 100644
32113 --- a/arch/x86/mm/setup_nx.c
32114 +++ b/arch/x86/mm/setup_nx.c
32115 @@ -5,8 +5,10 @@
32116 #include <asm/pgtable.h>
32117 #include <asm/proto.h>
32118
32119 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32120 static int disable_nx;
32121
32122 +#ifndef CONFIG_PAX_PAGEEXEC
32123 /*
32124 * noexec = on|off
32125 *
32126 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32127 return 0;
32128 }
32129 early_param("noexec", noexec_setup);
32130 +#endif
32131 +
32132 +#endif
32133
32134 void x86_configure_nx(void)
32135 {
32136 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32137 if (cpu_has_nx && !disable_nx)
32138 __supported_pte_mask |= _PAGE_NX;
32139 else
32140 +#endif
32141 __supported_pte_mask &= ~_PAGE_NX;
32142 }
32143
32144 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32145 index 282375f..e03a98f 100644
32146 --- a/arch/x86/mm/tlb.c
32147 +++ b/arch/x86/mm/tlb.c
32148 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32149 BUG();
32150 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32151 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32152 +
32153 +#ifndef CONFIG_PAX_PER_CPU_PGD
32154 load_cr3(swapper_pg_dir);
32155 +#endif
32156 +
32157 }
32158 }
32159 EXPORT_SYMBOL_GPL(leave_mm);
32160 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32161 new file mode 100644
32162 index 0000000..dace51c
32163 --- /dev/null
32164 +++ b/arch/x86/mm/uderef_64.c
32165 @@ -0,0 +1,37 @@
32166 +#include <linux/mm.h>
32167 +#include <asm/pgtable.h>
32168 +#include <asm/uaccess.h>
32169 +
32170 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32171 +/* PaX: due to the special call convention these functions must
32172 + * - remain leaf functions under all configurations,
32173 + * - never be called directly, only dereferenced from the wrappers.
32174 + */
32175 +void __pax_open_userland(void)
32176 +{
32177 + unsigned int cpu;
32178 +
32179 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32180 + return;
32181 +
32182 + cpu = raw_get_cpu();
32183 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32184 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32185 + raw_put_cpu_no_resched();
32186 +}
32187 +EXPORT_SYMBOL(__pax_open_userland);
32188 +
32189 +void __pax_close_userland(void)
32190 +{
32191 + unsigned int cpu;
32192 +
32193 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32194 + return;
32195 +
32196 + cpu = raw_get_cpu();
32197 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32198 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32199 + raw_put_cpu_no_resched();
32200 +}
32201 +EXPORT_SYMBOL(__pax_close_userland);
32202 +#endif
32203 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32204 index 877b9a1..a8ecf42 100644
32205 --- a/arch/x86/net/bpf_jit.S
32206 +++ b/arch/x86/net/bpf_jit.S
32207 @@ -9,6 +9,7 @@
32208 */
32209 #include <linux/linkage.h>
32210 #include <asm/dwarf2.h>
32211 +#include <asm/alternative-asm.h>
32212
32213 /*
32214 * Calling convention :
32215 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32216 jle bpf_slow_path_word
32217 mov (SKBDATA,%rsi),%eax
32218 bswap %eax /* ntohl() */
32219 + pax_force_retaddr
32220 ret
32221
32222 sk_load_half:
32223 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32224 jle bpf_slow_path_half
32225 movzwl (SKBDATA,%rsi),%eax
32226 rol $8,%ax # ntohs()
32227 + pax_force_retaddr
32228 ret
32229
32230 sk_load_byte:
32231 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32232 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32233 jle bpf_slow_path_byte
32234 movzbl (SKBDATA,%rsi),%eax
32235 + pax_force_retaddr
32236 ret
32237
32238 /**
32239 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32240 movzbl (SKBDATA,%rsi),%ebx
32241 and $15,%bl
32242 shl $2,%bl
32243 + pax_force_retaddr
32244 ret
32245
32246 /* rsi contains offset and can be scratched */
32247 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32248 js bpf_error
32249 mov -12(%rbp),%eax
32250 bswap %eax
32251 + pax_force_retaddr
32252 ret
32253
32254 bpf_slow_path_half:
32255 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32256 mov -12(%rbp),%ax
32257 rol $8,%ax
32258 movzwl %ax,%eax
32259 + pax_force_retaddr
32260 ret
32261
32262 bpf_slow_path_byte:
32263 bpf_slow_path_common(1)
32264 js bpf_error
32265 movzbl -12(%rbp),%eax
32266 + pax_force_retaddr
32267 ret
32268
32269 bpf_slow_path_byte_msh:
32270 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32271 and $15,%al
32272 shl $2,%al
32273 xchg %eax,%ebx
32274 + pax_force_retaddr
32275 ret
32276
32277 #define sk_negative_common(SIZE) \
32278 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32279 sk_negative_common(4)
32280 mov (%rax), %eax
32281 bswap %eax
32282 + pax_force_retaddr
32283 ret
32284
32285 bpf_slow_path_half_neg:
32286 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32287 mov (%rax),%ax
32288 rol $8,%ax
32289 movzwl %ax,%eax
32290 + pax_force_retaddr
32291 ret
32292
32293 bpf_slow_path_byte_neg:
32294 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32295 .globl sk_load_byte_negative_offset
32296 sk_negative_common(1)
32297 movzbl (%rax), %eax
32298 + pax_force_retaddr
32299 ret
32300
32301 bpf_slow_path_byte_msh_neg:
32302 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32303 and $15,%al
32304 shl $2,%al
32305 xchg %eax,%ebx
32306 + pax_force_retaddr
32307 ret
32308
32309 bpf_error:
32310 @@ -197,4 +210,5 @@ bpf_error:
32311 xor %eax,%eax
32312 mov -8(%rbp),%rbx
32313 leaveq
32314 + pax_force_retaddr
32315 ret
32316 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32317 index 79c216a..08d39cc 100644
32318 --- a/arch/x86/net/bpf_jit_comp.c
32319 +++ b/arch/x86/net/bpf_jit_comp.c
32320 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32321 return ptr + len;
32322 }
32323
32324 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32325 +#define MAX_INSTR_CODE_SIZE 96
32326 +#else
32327 +#define MAX_INSTR_CODE_SIZE 64
32328 +#endif
32329 +
32330 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32331
32332 #define EMIT1(b1) EMIT(b1, 1)
32333 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32334 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32335 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32336 +
32337 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32338 +/* original constant will appear in ecx */
32339 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32340 +do { \
32341 + /* mov ecx, randkey */ \
32342 + EMIT1(0xb9); \
32343 + EMIT(_key, 4); \
32344 + /* xor ecx, randkey ^ off */ \
32345 + EMIT2(0x81, 0xf1); \
32346 + EMIT((_key) ^ (_off), 4); \
32347 +} while (0)
32348 +
32349 +#define EMIT1_off32(b1, _off) \
32350 +do { \
32351 + switch (b1) { \
32352 + case 0x05: /* add eax, imm32 */ \
32353 + case 0x2d: /* sub eax, imm32 */ \
32354 + case 0x25: /* and eax, imm32 */ \
32355 + case 0x0d: /* or eax, imm32 */ \
32356 + case 0xb8: /* mov eax, imm32 */ \
32357 + case 0x35: /* xor eax, imm32 */ \
32358 + case 0x3d: /* cmp eax, imm32 */ \
32359 + case 0xa9: /* test eax, imm32 */ \
32360 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32361 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32362 + break; \
32363 + case 0xbb: /* mov ebx, imm32 */ \
32364 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32365 + /* mov ebx, ecx */ \
32366 + EMIT2(0x89, 0xcb); \
32367 + break; \
32368 + case 0xbe: /* mov esi, imm32 */ \
32369 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32370 + /* mov esi, ecx */ \
32371 + EMIT2(0x89, 0xce); \
32372 + break; \
32373 + case 0xe8: /* call rel imm32, always to known funcs */ \
32374 + EMIT1(b1); \
32375 + EMIT(_off, 4); \
32376 + break; \
32377 + case 0xe9: /* jmp rel imm32 */ \
32378 + EMIT1(b1); \
32379 + EMIT(_off, 4); \
32380 + /* prevent fall-through, we're not called if off = 0 */ \
32381 + EMIT(0xcccccccc, 4); \
32382 + EMIT(0xcccccccc, 4); \
32383 + break; \
32384 + default: \
32385 + BUILD_BUG(); \
32386 + } \
32387 +} while (0)
32388 +
32389 +#define EMIT2_off32(b1, b2, _off) \
32390 +do { \
32391 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32392 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32393 + EMIT(randkey, 4); \
32394 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32395 + EMIT((_off) - randkey, 4); \
32396 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32397 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32398 + /* imul eax, ecx */ \
32399 + EMIT3(0x0f, 0xaf, 0xc1); \
32400 + } else { \
32401 + BUILD_BUG(); \
32402 + } \
32403 +} while (0)
32404 +#else
32405 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32406 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32407 +#endif
32408
32409 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32410 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32411 @@ -91,6 +168,24 @@ do { \
32412 #define X86_JBE 0x76
32413 #define X86_JA 0x77
32414
32415 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32416 +#define APPEND_FLOW_VERIFY() \
32417 +do { \
32418 + /* mov ecx, randkey */ \
32419 + EMIT1(0xb9); \
32420 + EMIT(randkey, 4); \
32421 + /* cmp ecx, randkey */ \
32422 + EMIT2(0x81, 0xf9); \
32423 + EMIT(randkey, 4); \
32424 + /* jz after 8 int 3s */ \
32425 + EMIT2(0x74, 0x08); \
32426 + EMIT(0xcccccccc, 4); \
32427 + EMIT(0xcccccccc, 4); \
32428 +} while (0)
32429 +#else
32430 +#define APPEND_FLOW_VERIFY() do { } while (0)
32431 +#endif
32432 +
32433 #define EMIT_COND_JMP(op, offset) \
32434 do { \
32435 if (is_near(offset)) \
32436 @@ -98,6 +193,7 @@ do { \
32437 else { \
32438 EMIT2(0x0f, op + 0x10); \
32439 EMIT(offset, 4); /* jxx .+off32 */ \
32440 + APPEND_FLOW_VERIFY(); \
32441 } \
32442 } while (0)
32443
32444 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
32445 return -1;
32446 }
32447
32448 -struct bpf_binary_header {
32449 - unsigned int pages;
32450 - /* Note : for security reasons, bpf code will follow a randomly
32451 - * sized amount of int3 instructions
32452 - */
32453 - u8 image[];
32454 -};
32455 -
32456 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
32457 +/* Note : for security reasons, bpf code will follow a randomly
32458 + * sized amount of int3 instructions
32459 + */
32460 +static u8 *bpf_alloc_binary(unsigned int proglen,
32461 u8 **image_ptr)
32462 {
32463 unsigned int sz, hole;
32464 - struct bpf_binary_header *header;
32465 + u8 *header;
32466
32467 /* Most of BPF filters are really small,
32468 * but if some of them fill a page, allow at least
32469 * 128 extra bytes to insert a random section of int3
32470 */
32471 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
32472 - header = module_alloc(sz);
32473 + sz = round_up(proglen + 128, PAGE_SIZE);
32474 + header = module_alloc_exec(sz);
32475 if (!header)
32476 return NULL;
32477
32478 + pax_open_kernel();
32479 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
32480 + pax_close_kernel();
32481
32482 - header->pages = sz / PAGE_SIZE;
32483 - hole = sz - (proglen + sizeof(*header));
32484 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
32485
32486 /* insert a random number of int3 instructions before BPF code */
32487 - *image_ptr = &header->image[prandom_u32() % hole];
32488 + *image_ptr = &header[prandom_u32() % hole];
32489 return header;
32490 }
32491
32492 void bpf_jit_compile(struct sk_filter *fp)
32493 {
32494 - u8 temp[64];
32495 + u8 temp[MAX_INSTR_CODE_SIZE];
32496 u8 *prog;
32497 unsigned int proglen, oldproglen = 0;
32498 int ilen, i;
32499 int t_offset, f_offset;
32500 u8 t_op, f_op, seen = 0, pass;
32501 u8 *image = NULL;
32502 - struct bpf_binary_header *header = NULL;
32503 + u8 *header = NULL;
32504 u8 *func;
32505 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
32506 unsigned int cleanup_addr; /* epilogue code offset */
32507 unsigned int *addrs;
32508 const struct sock_filter *filter = fp->insns;
32509 int flen = fp->len;
32510 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32511 + unsigned int randkey;
32512 +#endif
32513
32514 if (!bpf_jit_enable)
32515 return;
32516 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
32517 if (addrs == NULL)
32518 return;
32519
32520 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32521 + randkey = get_random_int();
32522 +#endif
32523 +
32524 /* Before first pass, make a rough estimation of addrs[]
32525 - * each bpf instruction is translated to less than 64 bytes
32526 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
32527 */
32528 for (proglen = 0, i = 0; i < flen; i++) {
32529 - proglen += 64;
32530 + proglen += MAX_INSTR_CODE_SIZE;
32531 addrs[i] = proglen;
32532 }
32533 cleanup_addr = proglen; /* epilogue address */
32534 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
32535 case BPF_S_ALU_MUL_K: /* A *= K */
32536 if (is_imm8(K))
32537 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
32538 - else {
32539 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
32540 - EMIT(K, 4);
32541 - }
32542 + else
32543 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
32544 break;
32545 case BPF_S_ALU_DIV_X: /* A /= X; */
32546 seen |= SEEN_XREG;
32547 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
32548 break;
32549 case BPF_S_ALU_MOD_K: /* A %= K; */
32550 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
32551 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32552 + DILUTE_CONST_SEQUENCE(K, randkey);
32553 +#else
32554 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
32555 +#endif
32556 EMIT2(0xf7, 0xf1); /* div %ecx */
32557 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
32558 break;
32559 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
32560 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32561 + DILUTE_CONST_SEQUENCE(K, randkey);
32562 + // imul rax, rcx
32563 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
32564 +#else
32565 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
32566 EMIT(K, 4);
32567 +#endif
32568 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
32569 break;
32570 case BPF_S_ALU_AND_X:
32571 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
32572 if (is_imm8(K)) {
32573 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
32574 } else {
32575 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
32576 - EMIT(K, 4);
32577 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
32578 }
32579 } else {
32580 EMIT2(0x89,0xde); /* mov %ebx,%esi */
32581 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32582 if (unlikely(proglen + ilen > oldproglen)) {
32583 pr_err("bpb_jit_compile fatal error\n");
32584 kfree(addrs);
32585 - module_free(NULL, header);
32586 + module_free_exec(NULL, image);
32587 return;
32588 }
32589 + pax_open_kernel();
32590 memcpy(image + proglen, temp, ilen);
32591 + pax_close_kernel();
32592 }
32593 proglen += ilen;
32594 addrs[i] = proglen;
32595 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
32596
32597 if (image) {
32598 bpf_flush_icache(header, image + proglen);
32599 - set_memory_ro((unsigned long)header, header->pages);
32600 fp->bpf_func = (void *)image;
32601 }
32602 out:
32603 @@ -776,9 +883,7 @@ void bpf_jit_free(struct sk_filter *fp)
32604 {
32605 if (fp->bpf_func != sk_run_filter) {
32606 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
32607 - struct bpf_binary_header *header = (void *)addr;
32608 -
32609 - set_memory_rw(addr, header->pages);
32610 - module_free(NULL, header);
32611 + set_memory_rw(addr, 1);
32612 + module_free_exec(NULL, (void *)addr);
32613 }
32614 }
32615 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
32616 index d6aa6e8..266395a 100644
32617 --- a/arch/x86/oprofile/backtrace.c
32618 +++ b/arch/x86/oprofile/backtrace.c
32619 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
32620 struct stack_frame_ia32 *fp;
32621 unsigned long bytes;
32622
32623 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32624 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32625 if (bytes != sizeof(bufhead))
32626 return NULL;
32627
32628 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
32629 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
32630
32631 oprofile_add_trace(bufhead[0].return_address);
32632
32633 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
32634 struct stack_frame bufhead[2];
32635 unsigned long bytes;
32636
32637 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
32638 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
32639 if (bytes != sizeof(bufhead))
32640 return NULL;
32641
32642 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
32643 {
32644 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
32645
32646 - if (!user_mode_vm(regs)) {
32647 + if (!user_mode(regs)) {
32648 unsigned long stack = kernel_stack_pointer(regs);
32649 if (depth)
32650 dump_trace(NULL, regs, (unsigned long *)stack, 0,
32651 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
32652 index 48768df..ba9143c 100644
32653 --- a/arch/x86/oprofile/nmi_int.c
32654 +++ b/arch/x86/oprofile/nmi_int.c
32655 @@ -23,6 +23,7 @@
32656 #include <asm/nmi.h>
32657 #include <asm/msr.h>
32658 #include <asm/apic.h>
32659 +#include <asm/pgtable.h>
32660
32661 #include "op_counter.h"
32662 #include "op_x86_model.h"
32663 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
32664 if (ret)
32665 return ret;
32666
32667 - if (!model->num_virt_counters)
32668 - model->num_virt_counters = model->num_counters;
32669 + if (!model->num_virt_counters) {
32670 + pax_open_kernel();
32671 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
32672 + pax_close_kernel();
32673 + }
32674
32675 mux_init(ops);
32676
32677 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
32678 index b2b9443..be58856 100644
32679 --- a/arch/x86/oprofile/op_model_amd.c
32680 +++ b/arch/x86/oprofile/op_model_amd.c
32681 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
32682 num_counters = AMD64_NUM_COUNTERS;
32683 }
32684
32685 - op_amd_spec.num_counters = num_counters;
32686 - op_amd_spec.num_controls = num_counters;
32687 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32688 + pax_open_kernel();
32689 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
32690 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
32691 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
32692 + pax_close_kernel();
32693
32694 return 0;
32695 }
32696 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
32697 index d90528e..0127e2b 100644
32698 --- a/arch/x86/oprofile/op_model_ppro.c
32699 +++ b/arch/x86/oprofile/op_model_ppro.c
32700 @@ -19,6 +19,7 @@
32701 #include <asm/msr.h>
32702 #include <asm/apic.h>
32703 #include <asm/nmi.h>
32704 +#include <asm/pgtable.h>
32705
32706 #include "op_x86_model.h"
32707 #include "op_counter.h"
32708 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
32709
32710 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
32711
32712 - op_arch_perfmon_spec.num_counters = num_counters;
32713 - op_arch_perfmon_spec.num_controls = num_counters;
32714 + pax_open_kernel();
32715 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
32716 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
32717 + pax_close_kernel();
32718 }
32719
32720 static int arch_perfmon_init(struct oprofile_operations *ignore)
32721 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
32722 index 71e8a67..6a313bb 100644
32723 --- a/arch/x86/oprofile/op_x86_model.h
32724 +++ b/arch/x86/oprofile/op_x86_model.h
32725 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
32726 void (*switch_ctrl)(struct op_x86_model_spec const *model,
32727 struct op_msrs const * const msrs);
32728 #endif
32729 -};
32730 +} __do_const;
32731
32732 struct op_counter_config;
32733
32734 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
32735 index 372e9b8..e775a6c 100644
32736 --- a/arch/x86/pci/irq.c
32737 +++ b/arch/x86/pci/irq.c
32738 @@ -50,7 +50,7 @@ struct irq_router {
32739 struct irq_router_handler {
32740 u16 vendor;
32741 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
32742 -};
32743 +} __do_const;
32744
32745 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
32746 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
32747 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
32748 return 0;
32749 }
32750
32751 -static __initdata struct irq_router_handler pirq_routers[] = {
32752 +static __initconst const struct irq_router_handler pirq_routers[] = {
32753 { PCI_VENDOR_ID_INTEL, intel_router_probe },
32754 { PCI_VENDOR_ID_AL, ali_router_probe },
32755 { PCI_VENDOR_ID_ITE, ite_router_probe },
32756 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
32757 static void __init pirq_find_router(struct irq_router *r)
32758 {
32759 struct irq_routing_table *rt = pirq_table;
32760 - struct irq_router_handler *h;
32761 + const struct irq_router_handler *h;
32762
32763 #ifdef CONFIG_PCI_BIOS
32764 if (!rt->signature) {
32765 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
32766 return 0;
32767 }
32768
32769 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
32770 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
32771 {
32772 .callback = fix_broken_hp_bios_irq9,
32773 .ident = "HP Pavilion N5400 Series Laptop",
32774 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
32775 index 6eb18c4..20d83de 100644
32776 --- a/arch/x86/pci/mrst.c
32777 +++ b/arch/x86/pci/mrst.c
32778 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
32779 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
32780 pci_mmcfg_late_init();
32781 pcibios_enable_irq = mrst_pci_irq_enable;
32782 - pci_root_ops = pci_mrst_ops;
32783 + pax_open_kernel();
32784 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
32785 + pax_close_kernel();
32786 pci_soc_mode = 1;
32787 /* Continue with standard init */
32788 return 1;
32789 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
32790 index c77b24a..c979855 100644
32791 --- a/arch/x86/pci/pcbios.c
32792 +++ b/arch/x86/pci/pcbios.c
32793 @@ -79,7 +79,7 @@ union bios32 {
32794 static struct {
32795 unsigned long address;
32796 unsigned short segment;
32797 -} bios32_indirect = { 0, __KERNEL_CS };
32798 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
32799
32800 /*
32801 * Returns the entry point for the given service, NULL on error
32802 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
32803 unsigned long length; /* %ecx */
32804 unsigned long entry; /* %edx */
32805 unsigned long flags;
32806 + struct desc_struct d, *gdt;
32807
32808 local_irq_save(flags);
32809 - __asm__("lcall *(%%edi); cld"
32810 +
32811 + gdt = get_cpu_gdt_table(smp_processor_id());
32812 +
32813 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
32814 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32815 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
32816 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32817 +
32818 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
32819 : "=a" (return_code),
32820 "=b" (address),
32821 "=c" (length),
32822 "=d" (entry)
32823 : "0" (service),
32824 "1" (0),
32825 - "D" (&bios32_indirect));
32826 + "D" (&bios32_indirect),
32827 + "r"(__PCIBIOS_DS)
32828 + : "memory");
32829 +
32830 + pax_open_kernel();
32831 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
32832 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
32833 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
32834 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
32835 + pax_close_kernel();
32836 +
32837 local_irq_restore(flags);
32838
32839 switch (return_code) {
32840 - case 0:
32841 - return address + entry;
32842 - case 0x80: /* Not present */
32843 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32844 - return 0;
32845 - default: /* Shouldn't happen */
32846 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32847 - service, return_code);
32848 + case 0: {
32849 + int cpu;
32850 + unsigned char flags;
32851 +
32852 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
32853 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
32854 + printk(KERN_WARNING "bios32_service: not valid\n");
32855 return 0;
32856 + }
32857 + address = address + PAGE_OFFSET;
32858 + length += 16UL; /* some BIOSs underreport this... */
32859 + flags = 4;
32860 + if (length >= 64*1024*1024) {
32861 + length >>= PAGE_SHIFT;
32862 + flags |= 8;
32863 + }
32864 +
32865 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32866 + gdt = get_cpu_gdt_table(cpu);
32867 + pack_descriptor(&d, address, length, 0x9b, flags);
32868 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32869 + pack_descriptor(&d, address, length, 0x93, flags);
32870 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32871 + }
32872 + return entry;
32873 + }
32874 + case 0x80: /* Not present */
32875 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32876 + return 0;
32877 + default: /* Shouldn't happen */
32878 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32879 + service, return_code);
32880 + return 0;
32881 }
32882 }
32883
32884 static struct {
32885 unsigned long address;
32886 unsigned short segment;
32887 -} pci_indirect = { 0, __KERNEL_CS };
32888 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32889
32890 -static int pci_bios_present;
32891 +static int pci_bios_present __read_only;
32892
32893 static int check_pcibios(void)
32894 {
32895 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32896 unsigned long flags, pcibios_entry;
32897
32898 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32899 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32900 + pci_indirect.address = pcibios_entry;
32901
32902 local_irq_save(flags);
32903 - __asm__(
32904 - "lcall *(%%edi); cld\n\t"
32905 + __asm__("movw %w6, %%ds\n\t"
32906 + "lcall *%%ss:(%%edi); cld\n\t"
32907 + "push %%ss\n\t"
32908 + "pop %%ds\n\t"
32909 "jc 1f\n\t"
32910 "xor %%ah, %%ah\n"
32911 "1:"
32912 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32913 "=b" (ebx),
32914 "=c" (ecx)
32915 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32916 - "D" (&pci_indirect)
32917 + "D" (&pci_indirect),
32918 + "r" (__PCIBIOS_DS)
32919 : "memory");
32920 local_irq_restore(flags);
32921
32922 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32923
32924 switch (len) {
32925 case 1:
32926 - __asm__("lcall *(%%esi); cld\n\t"
32927 + __asm__("movw %w6, %%ds\n\t"
32928 + "lcall *%%ss:(%%esi); cld\n\t"
32929 + "push %%ss\n\t"
32930 + "pop %%ds\n\t"
32931 "jc 1f\n\t"
32932 "xor %%ah, %%ah\n"
32933 "1:"
32934 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32935 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32936 "b" (bx),
32937 "D" ((long)reg),
32938 - "S" (&pci_indirect));
32939 + "S" (&pci_indirect),
32940 + "r" (__PCIBIOS_DS));
32941 /*
32942 * Zero-extend the result beyond 8 bits, do not trust the
32943 * BIOS having done it:
32944 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32945 *value &= 0xff;
32946 break;
32947 case 2:
32948 - __asm__("lcall *(%%esi); cld\n\t"
32949 + __asm__("movw %w6, %%ds\n\t"
32950 + "lcall *%%ss:(%%esi); cld\n\t"
32951 + "push %%ss\n\t"
32952 + "pop %%ds\n\t"
32953 "jc 1f\n\t"
32954 "xor %%ah, %%ah\n"
32955 "1:"
32956 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32957 : "1" (PCIBIOS_READ_CONFIG_WORD),
32958 "b" (bx),
32959 "D" ((long)reg),
32960 - "S" (&pci_indirect));
32961 + "S" (&pci_indirect),
32962 + "r" (__PCIBIOS_DS));
32963 /*
32964 * Zero-extend the result beyond 16 bits, do not trust the
32965 * BIOS having done it:
32966 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32967 *value &= 0xffff;
32968 break;
32969 case 4:
32970 - __asm__("lcall *(%%esi); cld\n\t"
32971 + __asm__("movw %w6, %%ds\n\t"
32972 + "lcall *%%ss:(%%esi); cld\n\t"
32973 + "push %%ss\n\t"
32974 + "pop %%ds\n\t"
32975 "jc 1f\n\t"
32976 "xor %%ah, %%ah\n"
32977 "1:"
32978 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32979 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32980 "b" (bx),
32981 "D" ((long)reg),
32982 - "S" (&pci_indirect));
32983 + "S" (&pci_indirect),
32984 + "r" (__PCIBIOS_DS));
32985 break;
32986 }
32987
32988 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32989
32990 switch (len) {
32991 case 1:
32992 - __asm__("lcall *(%%esi); cld\n\t"
32993 + __asm__("movw %w6, %%ds\n\t"
32994 + "lcall *%%ss:(%%esi); cld\n\t"
32995 + "push %%ss\n\t"
32996 + "pop %%ds\n\t"
32997 "jc 1f\n\t"
32998 "xor %%ah, %%ah\n"
32999 "1:"
33000 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33001 "c" (value),
33002 "b" (bx),
33003 "D" ((long)reg),
33004 - "S" (&pci_indirect));
33005 + "S" (&pci_indirect),
33006 + "r" (__PCIBIOS_DS));
33007 break;
33008 case 2:
33009 - __asm__("lcall *(%%esi); cld\n\t"
33010 + __asm__("movw %w6, %%ds\n\t"
33011 + "lcall *%%ss:(%%esi); cld\n\t"
33012 + "push %%ss\n\t"
33013 + "pop %%ds\n\t"
33014 "jc 1f\n\t"
33015 "xor %%ah, %%ah\n"
33016 "1:"
33017 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33018 "c" (value),
33019 "b" (bx),
33020 "D" ((long)reg),
33021 - "S" (&pci_indirect));
33022 + "S" (&pci_indirect),
33023 + "r" (__PCIBIOS_DS));
33024 break;
33025 case 4:
33026 - __asm__("lcall *(%%esi); cld\n\t"
33027 + __asm__("movw %w6, %%ds\n\t"
33028 + "lcall *%%ss:(%%esi); cld\n\t"
33029 + "push %%ss\n\t"
33030 + "pop %%ds\n\t"
33031 "jc 1f\n\t"
33032 "xor %%ah, %%ah\n"
33033 "1:"
33034 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33035 "c" (value),
33036 "b" (bx),
33037 "D" ((long)reg),
33038 - "S" (&pci_indirect));
33039 + "S" (&pci_indirect),
33040 + "r" (__PCIBIOS_DS));
33041 break;
33042 }
33043
33044 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33045
33046 DBG("PCI: Fetching IRQ routing table... ");
33047 __asm__("push %%es\n\t"
33048 + "movw %w8, %%ds\n\t"
33049 "push %%ds\n\t"
33050 "pop %%es\n\t"
33051 - "lcall *(%%esi); cld\n\t"
33052 + "lcall *%%ss:(%%esi); cld\n\t"
33053 "pop %%es\n\t"
33054 + "push %%ss\n\t"
33055 + "pop %%ds\n"
33056 "jc 1f\n\t"
33057 "xor %%ah, %%ah\n"
33058 "1:"
33059 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33060 "1" (0),
33061 "D" ((long) &opt),
33062 "S" (&pci_indirect),
33063 - "m" (opt)
33064 + "m" (opt),
33065 + "r" (__PCIBIOS_DS)
33066 : "memory");
33067 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33068 if (ret & 0xff00)
33069 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33070 {
33071 int ret;
33072
33073 - __asm__("lcall *(%%esi); cld\n\t"
33074 + __asm__("movw %w5, %%ds\n\t"
33075 + "lcall *%%ss:(%%esi); cld\n\t"
33076 + "push %%ss\n\t"
33077 + "pop %%ds\n"
33078 "jc 1f\n\t"
33079 "xor %%ah, %%ah\n"
33080 "1:"
33081 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33082 : "0" (PCIBIOS_SET_PCI_HW_INT),
33083 "b" ((dev->bus->number << 8) | dev->devfn),
33084 "c" ((irq << 8) | (pin + 10)),
33085 - "S" (&pci_indirect));
33086 + "S" (&pci_indirect),
33087 + "r" (__PCIBIOS_DS));
33088 return !(ret & 0xff00);
33089 }
33090 EXPORT_SYMBOL(pcibios_set_irq_routing);
33091 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33092 index 40e4469..d915bf9 100644
33093 --- a/arch/x86/platform/efi/efi_32.c
33094 +++ b/arch/x86/platform/efi/efi_32.c
33095 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33096 {
33097 struct desc_ptr gdt_descr;
33098
33099 +#ifdef CONFIG_PAX_KERNEXEC
33100 + struct desc_struct d;
33101 +#endif
33102 +
33103 local_irq_save(efi_rt_eflags);
33104
33105 load_cr3(initial_page_table);
33106 __flush_tlb_all();
33107
33108 +#ifdef CONFIG_PAX_KERNEXEC
33109 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33110 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33111 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33112 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33113 +#endif
33114 +
33115 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33116 gdt_descr.size = GDT_SIZE - 1;
33117 load_gdt(&gdt_descr);
33118 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33119 {
33120 struct desc_ptr gdt_descr;
33121
33122 +#ifdef CONFIG_PAX_KERNEXEC
33123 + struct desc_struct d;
33124 +
33125 + memset(&d, 0, sizeof d);
33126 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33127 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33128 +#endif
33129 +
33130 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33131 gdt_descr.size = GDT_SIZE - 1;
33132 load_gdt(&gdt_descr);
33133
33134 +#ifdef CONFIG_PAX_PER_CPU_PGD
33135 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33136 +#else
33137 load_cr3(swapper_pg_dir);
33138 +#endif
33139 +
33140 __flush_tlb_all();
33141
33142 local_irq_restore(efi_rt_eflags);
33143 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33144 index 39a0e7f1..872396e 100644
33145 --- a/arch/x86/platform/efi/efi_64.c
33146 +++ b/arch/x86/platform/efi/efi_64.c
33147 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33148 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33149 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33150 }
33151 +
33152 +#ifdef CONFIG_PAX_PER_CPU_PGD
33153 + load_cr3(swapper_pg_dir);
33154 +#endif
33155 +
33156 __flush_tlb_all();
33157 }
33158
33159 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33160 for (pgd = 0; pgd < n_pgds; pgd++)
33161 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33162 kfree(save_pgd);
33163 +
33164 +#ifdef CONFIG_PAX_PER_CPU_PGD
33165 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33166 +#endif
33167 +
33168 __flush_tlb_all();
33169 local_irq_restore(efi_flags);
33170 early_code_mapping_set_exec(0);
33171 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33172 index fbe66e6..eae5e38 100644
33173 --- a/arch/x86/platform/efi/efi_stub_32.S
33174 +++ b/arch/x86/platform/efi/efi_stub_32.S
33175 @@ -6,7 +6,9 @@
33176 */
33177
33178 #include <linux/linkage.h>
33179 +#include <linux/init.h>
33180 #include <asm/page_types.h>
33181 +#include <asm/segment.h>
33182
33183 /*
33184 * efi_call_phys(void *, ...) is a function with variable parameters.
33185 @@ -20,7 +22,7 @@
33186 * service functions will comply with gcc calling convention, too.
33187 */
33188
33189 -.text
33190 +__INIT
33191 ENTRY(efi_call_phys)
33192 /*
33193 * 0. The function can only be called in Linux kernel. So CS has been
33194 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33195 * The mapping of lower virtual memory has been created in prelog and
33196 * epilog.
33197 */
33198 - movl $1f, %edx
33199 - subl $__PAGE_OFFSET, %edx
33200 - jmp *%edx
33201 +#ifdef CONFIG_PAX_KERNEXEC
33202 + movl $(__KERNEXEC_EFI_DS), %edx
33203 + mov %edx, %ds
33204 + mov %edx, %es
33205 + mov %edx, %ss
33206 + addl $2f,(1f)
33207 + ljmp *(1f)
33208 +
33209 +__INITDATA
33210 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33211 +.previous
33212 +
33213 +2:
33214 + subl $2b,(1b)
33215 +#else
33216 + jmp 1f-__PAGE_OFFSET
33217 1:
33218 +#endif
33219
33220 /*
33221 * 2. Now on the top of stack is the return
33222 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33223 * parameter 2, ..., param n. To make things easy, we save the return
33224 * address of efi_call_phys in a global variable.
33225 */
33226 - popl %edx
33227 - movl %edx, saved_return_addr
33228 - /* get the function pointer into ECX*/
33229 - popl %ecx
33230 - movl %ecx, efi_rt_function_ptr
33231 - movl $2f, %edx
33232 - subl $__PAGE_OFFSET, %edx
33233 - pushl %edx
33234 + popl (saved_return_addr)
33235 + popl (efi_rt_function_ptr)
33236
33237 /*
33238 * 3. Clear PG bit in %CR0.
33239 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33240 /*
33241 * 5. Call the physical function.
33242 */
33243 - jmp *%ecx
33244 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33245
33246 -2:
33247 /*
33248 * 6. After EFI runtime service returns, control will return to
33249 * following instruction. We'd better readjust stack pointer first.
33250 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33251 movl %cr0, %edx
33252 orl $0x80000000, %edx
33253 movl %edx, %cr0
33254 - jmp 1f
33255 -1:
33256 +
33257 /*
33258 * 8. Now restore the virtual mode from flat mode by
33259 * adding EIP with PAGE_OFFSET.
33260 */
33261 - movl $1f, %edx
33262 - jmp *%edx
33263 +#ifdef CONFIG_PAX_KERNEXEC
33264 + movl $(__KERNEL_DS), %edx
33265 + mov %edx, %ds
33266 + mov %edx, %es
33267 + mov %edx, %ss
33268 + ljmp $(__KERNEL_CS),$1f
33269 +#else
33270 + jmp 1f+__PAGE_OFFSET
33271 +#endif
33272 1:
33273
33274 /*
33275 * 9. Balance the stack. And because EAX contain the return value,
33276 * we'd better not clobber it.
33277 */
33278 - leal efi_rt_function_ptr, %edx
33279 - movl (%edx), %ecx
33280 - pushl %ecx
33281 + pushl (efi_rt_function_ptr)
33282
33283 /*
33284 - * 10. Push the saved return address onto the stack and return.
33285 + * 10. Return to the saved return address.
33286 */
33287 - leal saved_return_addr, %edx
33288 - movl (%edx), %ecx
33289 - pushl %ecx
33290 - ret
33291 + jmpl *(saved_return_addr)
33292 ENDPROC(efi_call_phys)
33293 .previous
33294
33295 -.data
33296 +__INITDATA
33297 saved_return_addr:
33298 .long 0
33299 efi_rt_function_ptr:
33300 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33301 index 4c07cca..2c8427d 100644
33302 --- a/arch/x86/platform/efi/efi_stub_64.S
33303 +++ b/arch/x86/platform/efi/efi_stub_64.S
33304 @@ -7,6 +7,7 @@
33305 */
33306
33307 #include <linux/linkage.h>
33308 +#include <asm/alternative-asm.h>
33309
33310 #define SAVE_XMM \
33311 mov %rsp, %rax; \
33312 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33313 call *%rdi
33314 addq $32, %rsp
33315 RESTORE_XMM
33316 + pax_force_retaddr 0, 1
33317 ret
33318 ENDPROC(efi_call0)
33319
33320 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33321 call *%rdi
33322 addq $32, %rsp
33323 RESTORE_XMM
33324 + pax_force_retaddr 0, 1
33325 ret
33326 ENDPROC(efi_call1)
33327
33328 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33329 call *%rdi
33330 addq $32, %rsp
33331 RESTORE_XMM
33332 + pax_force_retaddr 0, 1
33333 ret
33334 ENDPROC(efi_call2)
33335
33336 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33337 call *%rdi
33338 addq $32, %rsp
33339 RESTORE_XMM
33340 + pax_force_retaddr 0, 1
33341 ret
33342 ENDPROC(efi_call3)
33343
33344 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33345 call *%rdi
33346 addq $32, %rsp
33347 RESTORE_XMM
33348 + pax_force_retaddr 0, 1
33349 ret
33350 ENDPROC(efi_call4)
33351
33352 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33353 call *%rdi
33354 addq $48, %rsp
33355 RESTORE_XMM
33356 + pax_force_retaddr 0, 1
33357 ret
33358 ENDPROC(efi_call5)
33359
33360 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33361 call *%rdi
33362 addq $48, %rsp
33363 RESTORE_XMM
33364 + pax_force_retaddr 0, 1
33365 ret
33366 ENDPROC(efi_call6)
33367 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33368 index 47fe66f..6206449 100644
33369 --- a/arch/x86/platform/mrst/mrst.c
33370 +++ b/arch/x86/platform/mrst/mrst.c
33371 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33372 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33373 int sfi_mrtc_num;
33374
33375 -static void mrst_power_off(void)
33376 +static __noreturn void mrst_power_off(void)
33377 {
33378 + BUG();
33379 }
33380
33381 -static void mrst_reboot(void)
33382 +static __noreturn void mrst_reboot(void)
33383 {
33384 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33385 + BUG();
33386 }
33387
33388 /* parse all the mtimer info to a static mtimer array */
33389 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33390 index d6ee929..3637cb5 100644
33391 --- a/arch/x86/platform/olpc/olpc_dt.c
33392 +++ b/arch/x86/platform/olpc/olpc_dt.c
33393 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33394 return res;
33395 }
33396
33397 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33398 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33399 .nextprop = olpc_dt_nextprop,
33400 .getproplen = olpc_dt_getproplen,
33401 .getproperty = olpc_dt_getproperty,
33402 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33403 index 1cf5b30..fd45732 100644
33404 --- a/arch/x86/power/cpu.c
33405 +++ b/arch/x86/power/cpu.c
33406 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33407 static void fix_processor_context(void)
33408 {
33409 int cpu = smp_processor_id();
33410 - struct tss_struct *t = &per_cpu(init_tss, cpu);
33411 -#ifdef CONFIG_X86_64
33412 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
33413 - tss_desc tss;
33414 -#endif
33415 + struct tss_struct *t = init_tss + cpu;
33416 +
33417 set_tss_desc(cpu, t); /*
33418 * This just modifies memory; should not be
33419 * necessary. But... This is necessary, because
33420 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
33421 */
33422
33423 #ifdef CONFIG_X86_64
33424 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
33425 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
33426 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
33427 -
33428 syscall_init(); /* This sets MSR_*STAR and related */
33429 #endif
33430 load_TR_desc(); /* This does ltr */
33431 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
33432 index a44f457..9140171 100644
33433 --- a/arch/x86/realmode/init.c
33434 +++ b/arch/x86/realmode/init.c
33435 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
33436 __va(real_mode_header->trampoline_header);
33437
33438 #ifdef CONFIG_X86_32
33439 - trampoline_header->start = __pa_symbol(startup_32_smp);
33440 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
33441 +
33442 +#ifdef CONFIG_PAX_KERNEXEC
33443 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
33444 +#endif
33445 +
33446 + trampoline_header->boot_cs = __BOOT_CS;
33447 trampoline_header->gdt_limit = __BOOT_DS + 7;
33448 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
33449 #else
33450 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
33451 *trampoline_cr4_features = read_cr4();
33452
33453 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
33454 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
33455 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
33456 trampoline_pgd[511] = init_level4_pgt[511].pgd;
33457 #endif
33458 }
33459 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
33460 index 8869287..d577672 100644
33461 --- a/arch/x86/realmode/rm/Makefile
33462 +++ b/arch/x86/realmode/rm/Makefile
33463 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
33464 $(call cc-option, -fno-unit-at-a-time)) \
33465 $(call cc-option, -fno-stack-protector) \
33466 $(call cc-option, -mpreferred-stack-boundary=2)
33467 +ifdef CONSTIFY_PLUGIN
33468 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
33469 +endif
33470 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
33471 GCOV_PROFILE := n
33472 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
33473 index a28221d..93c40f1 100644
33474 --- a/arch/x86/realmode/rm/header.S
33475 +++ b/arch/x86/realmode/rm/header.S
33476 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
33477 #endif
33478 /* APM/BIOS reboot */
33479 .long pa_machine_real_restart_asm
33480 -#ifdef CONFIG_X86_64
33481 +#ifdef CONFIG_X86_32
33482 + .long __KERNEL_CS
33483 +#else
33484 .long __KERNEL32_CS
33485 #endif
33486 END(real_mode_header)
33487 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
33488 index c1b2791..f9e31c7 100644
33489 --- a/arch/x86/realmode/rm/trampoline_32.S
33490 +++ b/arch/x86/realmode/rm/trampoline_32.S
33491 @@ -25,6 +25,12 @@
33492 #include <asm/page_types.h>
33493 #include "realmode.h"
33494
33495 +#ifdef CONFIG_PAX_KERNEXEC
33496 +#define ta(X) (X)
33497 +#else
33498 +#define ta(X) (pa_ ## X)
33499 +#endif
33500 +
33501 .text
33502 .code16
33503
33504 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
33505
33506 cli # We should be safe anyway
33507
33508 - movl tr_start, %eax # where we need to go
33509 -
33510 movl $0xA5A5A5A5, trampoline_status
33511 # write marker for master knows we're running
33512
33513 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
33514 movw $1, %dx # protected mode (PE) bit
33515 lmsw %dx # into protected mode
33516
33517 - ljmpl $__BOOT_CS, $pa_startup_32
33518 + ljmpl *(trampoline_header)
33519
33520 .section ".text32","ax"
33521 .code32
33522 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
33523 .balign 8
33524 GLOBAL(trampoline_header)
33525 tr_start: .space 4
33526 - tr_gdt_pad: .space 2
33527 + tr_boot_cs: .space 2
33528 tr_gdt: .space 6
33529 END(trampoline_header)
33530
33531 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
33532 index bb360dc..d0fd8f8 100644
33533 --- a/arch/x86/realmode/rm/trampoline_64.S
33534 +++ b/arch/x86/realmode/rm/trampoline_64.S
33535 @@ -94,6 +94,7 @@ ENTRY(startup_32)
33536 movl %edx, %gs
33537
33538 movl pa_tr_cr4, %eax
33539 + andl $~X86_CR4_PCIDE, %eax
33540 movl %eax, %cr4 # Enable PAE mode
33541
33542 # Setup trampoline 4 level pagetables
33543 @@ -107,7 +108,7 @@ ENTRY(startup_32)
33544 wrmsr
33545
33546 # Enable paging and in turn activate Long Mode
33547 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
33548 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
33549 movl %eax, %cr0
33550
33551 /*
33552 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
33553 index e812034..c747134 100644
33554 --- a/arch/x86/tools/Makefile
33555 +++ b/arch/x86/tools/Makefile
33556 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
33557
33558 $(obj)/insn_sanity.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/inat.c $(srctree)/arch/x86/include/asm/inat_types.h $(srctree)/arch/x86/include/asm/inat.h $(srctree)/arch/x86/include/asm/insn.h $(objtree)/arch/x86/lib/inat-tables.c
33559
33560 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
33561 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
33562 hostprogs-y += relocs
33563 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
33564 relocs: $(obj)/relocs
33565 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
33566 index f7bab68..b6d9886 100644
33567 --- a/arch/x86/tools/relocs.c
33568 +++ b/arch/x86/tools/relocs.c
33569 @@ -1,5 +1,7 @@
33570 /* This is included from relocs_32/64.c */
33571
33572 +#include "../../../include/generated/autoconf.h"
33573 +
33574 #define ElfW(type) _ElfW(ELF_BITS, type)
33575 #define _ElfW(bits, type) __ElfW(bits, type)
33576 #define __ElfW(bits, type) Elf##bits##_##type
33577 @@ -11,6 +13,7 @@
33578 #define Elf_Sym ElfW(Sym)
33579
33580 static Elf_Ehdr ehdr;
33581 +static Elf_Phdr *phdr;
33582
33583 struct relocs {
33584 uint32_t *offset;
33585 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
33586 }
33587 }
33588
33589 +static void read_phdrs(FILE *fp)
33590 +{
33591 + unsigned int i;
33592 +
33593 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
33594 + if (!phdr) {
33595 + die("Unable to allocate %d program headers\n",
33596 + ehdr.e_phnum);
33597 + }
33598 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
33599 + die("Seek to %d failed: %s\n",
33600 + ehdr.e_phoff, strerror(errno));
33601 + }
33602 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
33603 + die("Cannot read ELF program headers: %s\n",
33604 + strerror(errno));
33605 + }
33606 + for(i = 0; i < ehdr.e_phnum; i++) {
33607 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
33608 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
33609 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
33610 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
33611 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
33612 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
33613 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
33614 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
33615 + }
33616 +
33617 +}
33618 +
33619 static void read_shdrs(FILE *fp)
33620 {
33621 - int i;
33622 + unsigned int i;
33623 Elf_Shdr shdr;
33624
33625 secs = calloc(ehdr.e_shnum, sizeof(struct section));
33626 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
33627
33628 static void read_strtabs(FILE *fp)
33629 {
33630 - int i;
33631 + unsigned int i;
33632 for (i = 0; i < ehdr.e_shnum; i++) {
33633 struct section *sec = &secs[i];
33634 if (sec->shdr.sh_type != SHT_STRTAB) {
33635 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
33636
33637 static void read_symtabs(FILE *fp)
33638 {
33639 - int i,j;
33640 + unsigned int i,j;
33641 for (i = 0; i < ehdr.e_shnum; i++) {
33642 struct section *sec = &secs[i];
33643 if (sec->shdr.sh_type != SHT_SYMTAB) {
33644 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
33645 }
33646
33647
33648 -static void read_relocs(FILE *fp)
33649 +static void read_relocs(FILE *fp, int use_real_mode)
33650 {
33651 - int i,j;
33652 + unsigned int i,j;
33653 + uint32_t base;
33654 +
33655 for (i = 0; i < ehdr.e_shnum; i++) {
33656 struct section *sec = &secs[i];
33657 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33658 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
33659 die("Cannot read symbol table: %s\n",
33660 strerror(errno));
33661 }
33662 + base = 0;
33663 +
33664 +#ifdef CONFIG_X86_32
33665 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
33666 + if (phdr[j].p_type != PT_LOAD )
33667 + continue;
33668 + if (secs[sec->shdr.sh_info].shdr.sh_offset < phdr[j].p_offset || secs[sec->shdr.sh_info].shdr.sh_offset >= phdr[j].p_offset + phdr[j].p_filesz)
33669 + continue;
33670 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
33671 + break;
33672 + }
33673 +#endif
33674 +
33675 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
33676 Elf_Rel *rel = &sec->reltab[j];
33677 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
33678 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
33679 rel->r_info = elf_xword_to_cpu(rel->r_info);
33680 #if (SHT_REL_TYPE == SHT_RELA)
33681 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
33682 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
33683
33684 static void print_absolute_symbols(void)
33685 {
33686 - int i;
33687 + unsigned int i;
33688 const char *format;
33689
33690 if (ELF_BITS == 64)
33691 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
33692 for (i = 0; i < ehdr.e_shnum; i++) {
33693 struct section *sec = &secs[i];
33694 char *sym_strtab;
33695 - int j;
33696 + unsigned int j;
33697
33698 if (sec->shdr.sh_type != SHT_SYMTAB) {
33699 continue;
33700 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
33701
33702 static void print_absolute_relocs(void)
33703 {
33704 - int i, printed = 0;
33705 + unsigned int i, printed = 0;
33706 const char *format;
33707
33708 if (ELF_BITS == 64)
33709 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
33710 struct section *sec_applies, *sec_symtab;
33711 char *sym_strtab;
33712 Elf_Sym *sh_symtab;
33713 - int j;
33714 + unsigned int j;
33715 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33716 continue;
33717 }
33718 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
33719 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
33720 Elf_Sym *sym, const char *symname))
33721 {
33722 - int i;
33723 + unsigned int i;
33724 /* Walk through the relocations */
33725 for (i = 0; i < ehdr.e_shnum; i++) {
33726 char *sym_strtab;
33727 Elf_Sym *sh_symtab;
33728 struct section *sec_applies, *sec_symtab;
33729 - int j;
33730 + unsigned int j;
33731 struct section *sec = &secs[i];
33732
33733 if (sec->shdr.sh_type != SHT_REL_TYPE) {
33734 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33735 {
33736 unsigned r_type = ELF32_R_TYPE(rel->r_info);
33737 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
33738 + char *sym_strtab = sec->link->link->strtab;
33739 +
33740 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
33741 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
33742 + return 0;
33743 +
33744 +#ifdef CONFIG_PAX_KERNEXEC
33745 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
33746 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
33747 + return 0;
33748 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
33749 + return 0;
33750 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
33751 + return 0;
33752 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
33753 + return 0;
33754 +#endif
33755
33756 switch (r_type) {
33757 case R_386_NONE:
33758 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
33759
33760 static void emit_relocs(int as_text, int use_real_mode)
33761 {
33762 - int i;
33763 + unsigned int i;
33764 int (*write_reloc)(uint32_t, FILE *) = write32;
33765 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
33766 const char *symname);
33767 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
33768 {
33769 regex_init(use_real_mode);
33770 read_ehdr(fp);
33771 + read_phdrs(fp);
33772 read_shdrs(fp);
33773 read_strtabs(fp);
33774 read_symtabs(fp);
33775 - read_relocs(fp);
33776 + read_relocs(fp, use_real_mode);
33777 if (ELF_BITS == 64)
33778 percpu_init();
33779 if (show_absolute_syms) {
33780 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
33781 index 80ffa5b..a33bd15 100644
33782 --- a/arch/x86/um/tls_32.c
33783 +++ b/arch/x86/um/tls_32.c
33784 @@ -260,7 +260,7 @@ out:
33785 if (unlikely(task == current &&
33786 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
33787 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
33788 - "without flushed TLS.", current->pid);
33789 + "without flushed TLS.", task_pid_nr(current));
33790 }
33791
33792 return 0;
33793 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
33794 index fd14be1..e3c79c0 100644
33795 --- a/arch/x86/vdso/Makefile
33796 +++ b/arch/x86/vdso/Makefile
33797 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
33798 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
33799 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
33800
33801 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33802 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
33803 GCOV_PROFILE := n
33804
33805 #
33806 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
33807 index d6bfb87..876ee18 100644
33808 --- a/arch/x86/vdso/vdso32-setup.c
33809 +++ b/arch/x86/vdso/vdso32-setup.c
33810 @@ -25,6 +25,7 @@
33811 #include <asm/tlbflush.h>
33812 #include <asm/vdso.h>
33813 #include <asm/proto.h>
33814 +#include <asm/mman.h>
33815
33816 enum {
33817 VDSO_DISABLED = 0,
33818 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
33819 void enable_sep_cpu(void)
33820 {
33821 int cpu = get_cpu();
33822 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
33823 + struct tss_struct *tss = init_tss + cpu;
33824
33825 if (!boot_cpu_has(X86_FEATURE_SEP)) {
33826 put_cpu();
33827 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
33828 gate_vma.vm_start = FIXADDR_USER_START;
33829 gate_vma.vm_end = FIXADDR_USER_END;
33830 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
33831 - gate_vma.vm_page_prot = __P101;
33832 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
33833
33834 return 0;
33835 }
33836 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33837 if (compat)
33838 addr = VDSO_HIGH_BASE;
33839 else {
33840 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
33841 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
33842 if (IS_ERR_VALUE(addr)) {
33843 ret = addr;
33844 goto up_fail;
33845 }
33846 }
33847
33848 - current->mm->context.vdso = (void *)addr;
33849 + current->mm->context.vdso = addr;
33850
33851 if (compat_uses_vma || !compat) {
33852 /*
33853 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33854 }
33855
33856 current_thread_info()->sysenter_return =
33857 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33858 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
33859
33860 up_fail:
33861 if (ret)
33862 - current->mm->context.vdso = NULL;
33863 + current->mm->context.vdso = 0;
33864
33865 up_write(&mm->mmap_sem);
33866
33867 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33868
33869 const char *arch_vma_name(struct vm_area_struct *vma)
33870 {
33871 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33872 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33873 return "[vdso]";
33874 +
33875 +#ifdef CONFIG_PAX_SEGMEXEC
33876 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33877 + return "[vdso]";
33878 +#endif
33879 +
33880 return NULL;
33881 }
33882
33883 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33884 * Check to see if the corresponding task was created in compat vdso
33885 * mode.
33886 */
33887 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33888 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33889 return &gate_vma;
33890 return NULL;
33891 }
33892 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33893 index 431e875..cbb23f3 100644
33894 --- a/arch/x86/vdso/vma.c
33895 +++ b/arch/x86/vdso/vma.c
33896 @@ -16,8 +16,6 @@
33897 #include <asm/vdso.h>
33898 #include <asm/page.h>
33899
33900 -unsigned int __read_mostly vdso_enabled = 1;
33901 -
33902 extern char vdso_start[], vdso_end[];
33903 extern unsigned short vdso_sync_cpuid;
33904
33905 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33906 * unaligned here as a result of stack start randomization.
33907 */
33908 addr = PAGE_ALIGN(addr);
33909 - addr = align_vdso_addr(addr);
33910
33911 return addr;
33912 }
33913 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33914 unsigned size)
33915 {
33916 struct mm_struct *mm = current->mm;
33917 - unsigned long addr;
33918 + unsigned long addr = 0;
33919 int ret;
33920
33921 - if (!vdso_enabled)
33922 - return 0;
33923 -
33924 down_write(&mm->mmap_sem);
33925 +
33926 +#ifdef CONFIG_PAX_RANDMMAP
33927 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33928 +#endif
33929 +
33930 addr = vdso_addr(mm->start_stack, size);
33931 + addr = align_vdso_addr(addr);
33932 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33933 if (IS_ERR_VALUE(addr)) {
33934 ret = addr;
33935 goto up_fail;
33936 }
33937
33938 - current->mm->context.vdso = (void *)addr;
33939 + mm->context.vdso = addr;
33940
33941 ret = install_special_mapping(mm, addr, size,
33942 VM_READ|VM_EXEC|
33943 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33944 pages);
33945 - if (ret) {
33946 - current->mm->context.vdso = NULL;
33947 - goto up_fail;
33948 - }
33949 + if (ret)
33950 + mm->context.vdso = 0;
33951
33952 up_fail:
33953 up_write(&mm->mmap_sem);
33954 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33955 vdsox32_size);
33956 }
33957 #endif
33958 -
33959 -static __init int vdso_setup(char *s)
33960 -{
33961 - vdso_enabled = simple_strtoul(s, NULL, 0);
33962 - return 0;
33963 -}
33964 -__setup("vdso=", vdso_setup);
33965 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33966 index 193097e..7590269 100644
33967 --- a/arch/x86/xen/enlighten.c
33968 +++ b/arch/x86/xen/enlighten.c
33969 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33970
33971 struct shared_info xen_dummy_shared_info;
33972
33973 -void *xen_initial_gdt;
33974 -
33975 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33976 __read_mostly int xen_have_vector_callback;
33977 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33978 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33979 {
33980 unsigned long va = dtr->address;
33981 unsigned int size = dtr->size + 1;
33982 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33983 - unsigned long frames[pages];
33984 + unsigned long frames[65536 / PAGE_SIZE];
33985 int f;
33986
33987 /*
33988 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33989 {
33990 unsigned long va = dtr->address;
33991 unsigned int size = dtr->size + 1;
33992 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33993 - unsigned long frames[pages];
33994 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33995 int f;
33996
33997 /*
33998 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33999 * 8-byte entries, or 16 4k pages..
34000 */
34001
34002 - BUG_ON(size > 65536);
34003 + BUG_ON(size > GDT_SIZE);
34004 BUG_ON(va & ~PAGE_MASK);
34005
34006 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
34007 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34008 return 0;
34009 }
34010
34011 -static void set_xen_basic_apic_ops(void)
34012 +static void __init set_xen_basic_apic_ops(void)
34013 {
34014 apic->read = xen_apic_read;
34015 apic->write = xen_apic_write;
34016 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34017 #endif
34018 };
34019
34020 -static void xen_reboot(int reason)
34021 +static __noreturn void xen_reboot(int reason)
34022 {
34023 struct sched_shutdown r = { .reason = reason };
34024
34025 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34026 - BUG();
34027 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34028 + BUG();
34029 }
34030
34031 -static void xen_restart(char *msg)
34032 +static __noreturn void xen_restart(char *msg)
34033 {
34034 xen_reboot(SHUTDOWN_reboot);
34035 }
34036
34037 -static void xen_emergency_restart(void)
34038 +static __noreturn void xen_emergency_restart(void)
34039 {
34040 xen_reboot(SHUTDOWN_reboot);
34041 }
34042
34043 -static void xen_machine_halt(void)
34044 +static __noreturn void xen_machine_halt(void)
34045 {
34046 xen_reboot(SHUTDOWN_poweroff);
34047 }
34048
34049 -static void xen_machine_power_off(void)
34050 +static __noreturn void xen_machine_power_off(void)
34051 {
34052 if (pm_power_off)
34053 pm_power_off();
34054 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
34055 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34056
34057 /* Work out if we support NX */
34058 - x86_configure_nx();
34059 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34060 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34061 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34062 + unsigned l, h;
34063 +
34064 + __supported_pte_mask |= _PAGE_NX;
34065 + rdmsr(MSR_EFER, l, h);
34066 + l |= EFER_NX;
34067 + wrmsr(MSR_EFER, l, h);
34068 + }
34069 +#endif
34070
34071 xen_setup_features();
34072
34073 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
34074
34075 machine_ops = xen_machine_ops;
34076
34077 - /*
34078 - * The only reliable way to retain the initial address of the
34079 - * percpu gdt_page is to remember it here, so we can go and
34080 - * mark it RW later, when the initial percpu area is freed.
34081 - */
34082 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34083 -
34084 xen_smp_init();
34085
34086 #ifdef CONFIG_ACPI_NUMA
34087 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34088 index fdc3ba2..3daee39 100644
34089 --- a/arch/x86/xen/mmu.c
34090 +++ b/arch/x86/xen/mmu.c
34091 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34092 /* L3_k[510] -> level2_kernel_pgt
34093 * L3_i[511] -> level2_fixmap_pgt */
34094 convert_pfn_mfn(level3_kernel_pgt);
34095 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34096 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34097 + convert_pfn_mfn(level3_vmemmap_pgt);
34098
34099 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34100 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34101 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34102 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34103 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34104 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34105 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34106 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34107 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34108 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34109 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34110 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34111 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34112 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34113
34114 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34115 pv_mmu_ops.set_pud = xen_set_pud;
34116 #if PAGETABLE_LEVELS == 4
34117 pv_mmu_ops.set_pgd = xen_set_pgd;
34118 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34119 #endif
34120
34121 /* This will work as long as patching hasn't happened yet
34122 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34123 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34124 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34125 .set_pgd = xen_set_pgd_hyper,
34126 + .set_pgd_batched = xen_set_pgd_hyper,
34127
34128 .alloc_pud = xen_alloc_pmd_init,
34129 .release_pud = xen_release_pmd_init,
34130 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34131 index b81c88e..2cbe7b8 100644
34132 --- a/arch/x86/xen/smp.c
34133 +++ b/arch/x86/xen/smp.c
34134 @@ -272,11 +272,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
34135 {
34136 BUG_ON(smp_processor_id() != 0);
34137 native_smp_prepare_boot_cpu();
34138 -
34139 - /* We've switched to the "real" per-cpu gdt, so make sure the
34140 - old memory can be recycled */
34141 - make_lowmem_page_readwrite(xen_initial_gdt);
34142 -
34143 xen_filter_cpu_maps();
34144 xen_setup_vcpu_info_placement();
34145 }
34146 @@ -346,7 +341,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34147 ctxt->user_regs.ss = __KERNEL_DS;
34148 #ifdef CONFIG_X86_32
34149 ctxt->user_regs.fs = __KERNEL_PERCPU;
34150 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34151 + savesegment(gs, ctxt->user_regs.gs);
34152 #else
34153 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34154 #endif
34155 @@ -356,8 +351,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34156
34157 {
34158 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34159 - ctxt->user_regs.ds = __USER_DS;
34160 - ctxt->user_regs.es = __USER_DS;
34161 + ctxt->user_regs.ds = __KERNEL_DS;
34162 + ctxt->user_regs.es = __KERNEL_DS;
34163
34164 xen_copy_trap_info(ctxt->trap_ctxt);
34165
34166 @@ -402,13 +397,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34167 int rc;
34168
34169 per_cpu(current_task, cpu) = idle;
34170 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34171 #ifdef CONFIG_X86_32
34172 irq_ctx_init(cpu);
34173 #else
34174 clear_tsk_thread_flag(idle, TIF_FORK);
34175 - per_cpu(kernel_stack, cpu) =
34176 - (unsigned long)task_stack_page(idle) -
34177 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34178 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34179 #endif
34180 xen_setup_runstate_info(cpu);
34181 xen_setup_timer(cpu);
34182 @@ -678,7 +672,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34183
34184 void __init xen_smp_init(void)
34185 {
34186 - smp_ops = xen_smp_ops;
34187 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34188 xen_fill_possible_map();
34189 xen_init_spinlocks();
34190 }
34191 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34192 index 33ca6e4..0ded929 100644
34193 --- a/arch/x86/xen/xen-asm_32.S
34194 +++ b/arch/x86/xen/xen-asm_32.S
34195 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34196 ESP_OFFSET=4 # bytes pushed onto stack
34197
34198 /*
34199 - * Store vcpu_info pointer for easy access. Do it this way to
34200 - * avoid having to reload %fs
34201 + * Store vcpu_info pointer for easy access.
34202 */
34203 #ifdef CONFIG_SMP
34204 - GET_THREAD_INFO(%eax)
34205 - movl %ss:TI_cpu(%eax), %eax
34206 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34207 - mov %ss:xen_vcpu(%eax), %eax
34208 + push %fs
34209 + mov $(__KERNEL_PERCPU), %eax
34210 + mov %eax, %fs
34211 + mov PER_CPU_VAR(xen_vcpu), %eax
34212 + pop %fs
34213 #else
34214 movl %ss:xen_vcpu, %eax
34215 #endif
34216 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34217 index 7faed58..ba4427c 100644
34218 --- a/arch/x86/xen/xen-head.S
34219 +++ b/arch/x86/xen/xen-head.S
34220 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34221 #ifdef CONFIG_X86_32
34222 mov %esi,xen_start_info
34223 mov $init_thread_union+THREAD_SIZE,%esp
34224 +#ifdef CONFIG_SMP
34225 + movl $cpu_gdt_table,%edi
34226 + movl $__per_cpu_load,%eax
34227 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34228 + rorl $16,%eax
34229 + movb %al,__KERNEL_PERCPU + 4(%edi)
34230 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34231 + movl $__per_cpu_end - 1,%eax
34232 + subl $__per_cpu_start,%eax
34233 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34234 +#endif
34235 #else
34236 mov %rsi,xen_start_info
34237 mov $init_thread_union+THREAD_SIZE,%rsp
34238 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34239 index 86782c5..fa272c8 100644
34240 --- a/arch/x86/xen/xen-ops.h
34241 +++ b/arch/x86/xen/xen-ops.h
34242 @@ -10,8 +10,6 @@
34243 extern const char xen_hypervisor_callback[];
34244 extern const char xen_failsafe_callback[];
34245
34246 -extern void *xen_initial_gdt;
34247 -
34248 struct trap_info;
34249 void xen_copy_trap_info(struct trap_info *traps);
34250
34251 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34252 index 525bd3d..ef888b1 100644
34253 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34254 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34255 @@ -119,9 +119,9 @@
34256 ----------------------------------------------------------------------*/
34257
34258 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34259 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34260 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34261 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34262 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34263
34264 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34265 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34266 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34267 index 2f33760..835e50a 100644
34268 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34269 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34270 @@ -11,6 +11,7 @@
34271 #ifndef _XTENSA_CORE_H
34272 #define _XTENSA_CORE_H
34273
34274 +#include <linux/const.h>
34275
34276 /****************************************************************************
34277 Parameters Useful for Any Code, USER or PRIVILEGED
34278 @@ -112,9 +113,9 @@
34279 ----------------------------------------------------------------------*/
34280
34281 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34282 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34283 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34284 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34285 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34286
34287 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34288 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34289 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34290 index af00795..2bb8105 100644
34291 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34292 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34293 @@ -11,6 +11,7 @@
34294 #ifndef _XTENSA_CORE_CONFIGURATION_H
34295 #define _XTENSA_CORE_CONFIGURATION_H
34296
34297 +#include <linux/const.h>
34298
34299 /****************************************************************************
34300 Parameters Useful for Any Code, USER or PRIVILEGED
34301 @@ -118,9 +119,9 @@
34302 ----------------------------------------------------------------------*/
34303
34304 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34305 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34306 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34307 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34308 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34309
34310 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34311 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34312 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34313 index 290792a..416f287 100644
34314 --- a/block/blk-cgroup.c
34315 +++ b/block/blk-cgroup.c
34316 @@ -808,7 +808,7 @@ static void blkcg_css_free(struct cgroup *cgroup)
34317
34318 static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34319 {
34320 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34321 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34322 struct blkcg *blkcg;
34323 struct cgroup *parent = cgroup->parent;
34324
34325 @@ -823,7 +823,7 @@ static struct cgroup_subsys_state *blkcg_css_alloc(struct cgroup *cgroup)
34326
34327 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34328 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34329 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34330 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34331 done:
34332 spin_lock_init(&blkcg->lock);
34333 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34334 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34335 index 4b8d9b54..a7178c0 100644
34336 --- a/block/blk-iopoll.c
34337 +++ b/block/blk-iopoll.c
34338 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34339 }
34340 EXPORT_SYMBOL(blk_iopoll_complete);
34341
34342 -static void blk_iopoll_softirq(struct softirq_action *h)
34343 +static __latent_entropy void blk_iopoll_softirq(void)
34344 {
34345 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34346 int rearm = 0, budget = blk_iopoll_budget;
34347 diff --git a/block/blk-map.c b/block/blk-map.c
34348 index 623e1cd..ca1e109 100644
34349 --- a/block/blk-map.c
34350 +++ b/block/blk-map.c
34351 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34352 if (!len || !kbuf)
34353 return -EINVAL;
34354
34355 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34356 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34357 if (do_copy)
34358 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34359 else
34360 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34361 index ec9e606..3f38839 100644
34362 --- a/block/blk-softirq.c
34363 +++ b/block/blk-softirq.c
34364 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34365 * Softirq action handler - move entries to local list and loop over them
34366 * while passing them to the queue registered handler.
34367 */
34368 -static void blk_done_softirq(struct softirq_action *h)
34369 +static __latent_entropy void blk_done_softirq(void)
34370 {
34371 struct list_head *cpu_list, local_list;
34372
34373 diff --git a/block/bsg.c b/block/bsg.c
34374 index 420a5a9..23834aa 100644
34375 --- a/block/bsg.c
34376 +++ b/block/bsg.c
34377 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34378 struct sg_io_v4 *hdr, struct bsg_device *bd,
34379 fmode_t has_write_perm)
34380 {
34381 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34382 + unsigned char *cmdptr;
34383 +
34384 if (hdr->request_len > BLK_MAX_CDB) {
34385 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34386 if (!rq->cmd)
34387 return -ENOMEM;
34388 - }
34389 + cmdptr = rq->cmd;
34390 + } else
34391 + cmdptr = tmpcmd;
34392
34393 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
34394 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
34395 hdr->request_len))
34396 return -EFAULT;
34397
34398 + if (cmdptr != rq->cmd)
34399 + memcpy(rq->cmd, cmdptr, hdr->request_len);
34400 +
34401 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
34402 if (blk_verify_command(rq->cmd, has_write_perm))
34403 return -EPERM;
34404 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
34405 index 7e5d474..0cf0017 100644
34406 --- a/block/compat_ioctl.c
34407 +++ b/block/compat_ioctl.c
34408 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
34409 err |= __get_user(f->spec1, &uf->spec1);
34410 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
34411 err |= __get_user(name, &uf->name);
34412 - f->name = compat_ptr(name);
34413 + f->name = (void __force_kernel *)compat_ptr(name);
34414 if (err) {
34415 err = -EFAULT;
34416 goto out;
34417 diff --git a/block/genhd.c b/block/genhd.c
34418 index dadf42b..48dc887 100644
34419 --- a/block/genhd.c
34420 +++ b/block/genhd.c
34421 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
34422
34423 /*
34424 * Register device numbers dev..(dev+range-1)
34425 - * range must be nonzero
34426 + * Noop if @range is zero.
34427 * The hash chain is sorted on range, so that subranges can override.
34428 */
34429 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
34430 struct kobject *(*probe)(dev_t, int *, void *),
34431 int (*lock)(dev_t, void *), void *data)
34432 {
34433 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
34434 + if (range)
34435 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
34436 }
34437
34438 EXPORT_SYMBOL(blk_register_region);
34439
34440 +/* undo blk_register_region(), noop if @range is zero */
34441 void blk_unregister_region(dev_t devt, unsigned long range)
34442 {
34443 - kobj_unmap(bdev_map, devt, range);
34444 + if (range)
34445 + kobj_unmap(bdev_map, devt, range);
34446 }
34447
34448 EXPORT_SYMBOL(blk_unregister_region);
34449 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
34450 index c85fc89..51e690b 100644
34451 --- a/block/partitions/efi.c
34452 +++ b/block/partitions/efi.c
34453 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
34454 if (!gpt)
34455 return NULL;
34456
34457 + if (!le32_to_cpu(gpt->num_partition_entries))
34458 + return NULL;
34459 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
34460 + if (!pte)
34461 + return NULL;
34462 +
34463 count = le32_to_cpu(gpt->num_partition_entries) *
34464 le32_to_cpu(gpt->sizeof_partition_entry);
34465 - if (!count)
34466 - return NULL;
34467 - pte = kmalloc(count, GFP_KERNEL);
34468 - if (!pte)
34469 - return NULL;
34470 -
34471 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
34472 (u8 *) pte,
34473 count) < count) {
34474 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
34475 index a5ffcc9..3cedc9c 100644
34476 --- a/block/scsi_ioctl.c
34477 +++ b/block/scsi_ioctl.c
34478 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
34479 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
34480 struct sg_io_hdr *hdr, fmode_t mode)
34481 {
34482 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
34483 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34484 + unsigned char *cmdptr;
34485 +
34486 + if (rq->cmd != rq->__cmd)
34487 + cmdptr = rq->cmd;
34488 + else
34489 + cmdptr = tmpcmd;
34490 +
34491 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
34492 return -EFAULT;
34493 +
34494 + if (cmdptr != rq->cmd)
34495 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
34496 +
34497 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
34498 return -EPERM;
34499
34500 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34501 int err;
34502 unsigned int in_len, out_len, bytes, opcode, cmdlen;
34503 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
34504 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34505 + unsigned char *cmdptr;
34506
34507 if (!sic)
34508 return -EINVAL;
34509 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
34510 */
34511 err = -EFAULT;
34512 rq->cmd_len = cmdlen;
34513 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
34514 +
34515 + if (rq->cmd != rq->__cmd)
34516 + cmdptr = rq->cmd;
34517 + else
34518 + cmdptr = tmpcmd;
34519 +
34520 + if (copy_from_user(cmdptr, sic->data, cmdlen))
34521 goto error;
34522
34523 + if (rq->cmd != cmdptr)
34524 + memcpy(rq->cmd, cmdptr, cmdlen);
34525 +
34526 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
34527 goto error;
34528
34529 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
34530 index 7bdd61b..afec999 100644
34531 --- a/crypto/cryptd.c
34532 +++ b/crypto/cryptd.c
34533 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
34534
34535 struct cryptd_blkcipher_request_ctx {
34536 crypto_completion_t complete;
34537 -};
34538 +} __no_const;
34539
34540 struct cryptd_hash_ctx {
34541 struct crypto_shash *child;
34542 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
34543
34544 struct cryptd_aead_request_ctx {
34545 crypto_completion_t complete;
34546 -};
34547 +} __no_const;
34548
34549 static void cryptd_queue_worker(struct work_struct *work);
34550
34551 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
34552 index f8c920c..ab2cb5a 100644
34553 --- a/crypto/pcrypt.c
34554 +++ b/crypto/pcrypt.c
34555 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
34556 int ret;
34557
34558 pinst->kobj.kset = pcrypt_kset;
34559 - ret = kobject_add(&pinst->kobj, NULL, name);
34560 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
34561 if (!ret)
34562 kobject_uevent(&pinst->kobj, KOBJ_ADD);
34563
34564 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
34565 index f220d64..d359ad6 100644
34566 --- a/drivers/acpi/apei/apei-internal.h
34567 +++ b/drivers/acpi/apei/apei-internal.h
34568 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
34569 struct apei_exec_ins_type {
34570 u32 flags;
34571 apei_exec_ins_func_t run;
34572 -};
34573 +} __do_const;
34574
34575 struct apei_exec_context {
34576 u32 ip;
34577 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
34578 index 33dc6a0..4b24b47 100644
34579 --- a/drivers/acpi/apei/cper.c
34580 +++ b/drivers/acpi/apei/cper.c
34581 @@ -39,12 +39,12 @@
34582 */
34583 u64 cper_next_record_id(void)
34584 {
34585 - static atomic64_t seq;
34586 + static atomic64_unchecked_t seq;
34587
34588 - if (!atomic64_read(&seq))
34589 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
34590 + if (!atomic64_read_unchecked(&seq))
34591 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
34592
34593 - return atomic64_inc_return(&seq);
34594 + return atomic64_inc_return_unchecked(&seq);
34595 }
34596 EXPORT_SYMBOL_GPL(cper_next_record_id);
34597
34598 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
34599 index ec9b57d..9682b3a 100644
34600 --- a/drivers/acpi/apei/ghes.c
34601 +++ b/drivers/acpi/apei/ghes.c
34602 @@ -478,7 +478,7 @@ static void __ghes_print_estatus(const char *pfx,
34603 const struct acpi_hest_generic *generic,
34604 const struct acpi_hest_generic_status *estatus)
34605 {
34606 - static atomic_t seqno;
34607 + static atomic_unchecked_t seqno;
34608 unsigned int curr_seqno;
34609 char pfx_seq[64];
34610
34611 @@ -489,7 +489,7 @@ static void __ghes_print_estatus(const char *pfx,
34612 else
34613 pfx = KERN_ERR;
34614 }
34615 - curr_seqno = atomic_inc_return(&seqno);
34616 + curr_seqno = atomic_inc_return_unchecked(&seqno);
34617 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
34618 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
34619 pfx_seq, generic->header.source_id);
34620 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
34621 index be60399..778b33e8 100644
34622 --- a/drivers/acpi/bgrt.c
34623 +++ b/drivers/acpi/bgrt.c
34624 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
34625 return -ENODEV;
34626
34627 sysfs_bin_attr_init(&image_attr);
34628 - image_attr.private = bgrt_image;
34629 - image_attr.size = bgrt_image_size;
34630 + pax_open_kernel();
34631 + *(void **)&image_attr.private = bgrt_image;
34632 + *(size_t *)&image_attr.size = bgrt_image_size;
34633 + pax_close_kernel();
34634
34635 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
34636 if (!bgrt_kobj)
34637 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
34638 index cb96296..b81293b 100644
34639 --- a/drivers/acpi/blacklist.c
34640 +++ b/drivers/acpi/blacklist.c
34641 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
34642 u32 is_critical_error;
34643 };
34644
34645 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
34646 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
34647
34648 /*
34649 * POLICY: If *anything* doesn't work, put it on the blacklist.
34650 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
34651 return 0;
34652 }
34653
34654 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
34655 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
34656 {
34657 .callback = dmi_disable_osi_vista,
34658 .ident = "Fujitsu Siemens",
34659 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
34660 index f98dd00..7b69865 100644
34661 --- a/drivers/acpi/processor_idle.c
34662 +++ b/drivers/acpi/processor_idle.c
34663 @@ -992,7 +992,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
34664 {
34665 int i, count = CPUIDLE_DRIVER_STATE_START;
34666 struct acpi_processor_cx *cx;
34667 - struct cpuidle_state *state;
34668 + cpuidle_state_no_const *state;
34669 struct cpuidle_driver *drv = &acpi_idle_driver;
34670
34671 if (!pr->flags.power_setup_done)
34672 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
34673 index 05306a5..733d1f0 100644
34674 --- a/drivers/acpi/sysfs.c
34675 +++ b/drivers/acpi/sysfs.c
34676 @@ -423,11 +423,11 @@ static u32 num_counters;
34677 static struct attribute **all_attrs;
34678 static u32 acpi_gpe_count;
34679
34680 -static struct attribute_group interrupt_stats_attr_group = {
34681 +static attribute_group_no_const interrupt_stats_attr_group = {
34682 .name = "interrupts",
34683 };
34684
34685 -static struct kobj_attribute *counter_attrs;
34686 +static kobj_attribute_no_const *counter_attrs;
34687
34688 static void delete_gpe_attr_array(void)
34689 {
34690 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
34691 index acfd0f7..e5acb08 100644
34692 --- a/drivers/ata/libahci.c
34693 +++ b/drivers/ata/libahci.c
34694 @@ -1231,7 +1231,7 @@ int ahci_kick_engine(struct ata_port *ap)
34695 }
34696 EXPORT_SYMBOL_GPL(ahci_kick_engine);
34697
34698 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34699 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
34700 struct ata_taskfile *tf, int is_cmd, u16 flags,
34701 unsigned long timeout_msec)
34702 {
34703 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
34704 index c24354d..335c975 100644
34705 --- a/drivers/ata/libata-core.c
34706 +++ b/drivers/ata/libata-core.c
34707 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
34708 static void ata_dev_xfermask(struct ata_device *dev);
34709 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
34710
34711 -atomic_t ata_print_id = ATOMIC_INIT(0);
34712 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
34713
34714 struct ata_force_param {
34715 const char *name;
34716 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
34717 struct ata_port *ap;
34718 unsigned int tag;
34719
34720 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34721 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34722 ap = qc->ap;
34723
34724 qc->flags = 0;
34725 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
34726 struct ata_port *ap;
34727 struct ata_link *link;
34728
34729 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34730 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
34731 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
34732 ap = qc->ap;
34733 link = qc->dev->link;
34734 @@ -5927,6 +5927,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34735 return;
34736
34737 spin_lock(&lock);
34738 + pax_open_kernel();
34739
34740 for (cur = ops->inherits; cur; cur = cur->inherits) {
34741 void **inherit = (void **)cur;
34742 @@ -5940,8 +5941,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
34743 if (IS_ERR(*pp))
34744 *pp = NULL;
34745
34746 - ops->inherits = NULL;
34747 + *(struct ata_port_operations **)&ops->inherits = NULL;
34748
34749 + pax_close_kernel();
34750 spin_unlock(&lock);
34751 }
34752
34753 @@ -6134,7 +6136,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
34754
34755 /* give ports names and add SCSI hosts */
34756 for (i = 0; i < host->n_ports; i++) {
34757 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
34758 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
34759 host->ports[i]->local_port_no = i + 1;
34760 }
34761
34762 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
34763 index b1e880a..8cf82e1 100644
34764 --- a/drivers/ata/libata-scsi.c
34765 +++ b/drivers/ata/libata-scsi.c
34766 @@ -4104,7 +4104,7 @@ int ata_sas_port_init(struct ata_port *ap)
34767
34768 if (rc)
34769 return rc;
34770 - ap->print_id = atomic_inc_return(&ata_print_id);
34771 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
34772 return 0;
34773 }
34774 EXPORT_SYMBOL_GPL(ata_sas_port_init);
34775 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
34776 index 577d902b..cb4781e 100644
34777 --- a/drivers/ata/libata.h
34778 +++ b/drivers/ata/libata.h
34779 @@ -53,7 +53,7 @@ enum {
34780 ATA_DNXFER_QUIET = (1 << 31),
34781 };
34782
34783 -extern atomic_t ata_print_id;
34784 +extern atomic_unchecked_t ata_print_id;
34785 extern int atapi_passthru16;
34786 extern int libata_fua;
34787 extern int libata_noacpi;
34788 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
34789 index 848ed32..132f39d 100644
34790 --- a/drivers/ata/pata_arasan_cf.c
34791 +++ b/drivers/ata/pata_arasan_cf.c
34792 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
34793 /* Handle platform specific quirks */
34794 if (quirk) {
34795 if (quirk & CF_BROKEN_PIO) {
34796 - ap->ops->set_piomode = NULL;
34797 + pax_open_kernel();
34798 + *(void **)&ap->ops->set_piomode = NULL;
34799 + pax_close_kernel();
34800 ap->pio_mask = 0;
34801 }
34802 if (quirk & CF_BROKEN_MWDMA)
34803 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
34804 index f9b983a..887b9d8 100644
34805 --- a/drivers/atm/adummy.c
34806 +++ b/drivers/atm/adummy.c
34807 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
34808 vcc->pop(vcc, skb);
34809 else
34810 dev_kfree_skb_any(skb);
34811 - atomic_inc(&vcc->stats->tx);
34812 + atomic_inc_unchecked(&vcc->stats->tx);
34813
34814 return 0;
34815 }
34816 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
34817 index 62a7607..cc4be104 100644
34818 --- a/drivers/atm/ambassador.c
34819 +++ b/drivers/atm/ambassador.c
34820 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
34821 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
34822
34823 // VC layer stats
34824 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34825 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34826
34827 // free the descriptor
34828 kfree (tx_descr);
34829 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34830 dump_skb ("<<<", vc, skb);
34831
34832 // VC layer stats
34833 - atomic_inc(&atm_vcc->stats->rx);
34834 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34835 __net_timestamp(skb);
34836 // end of our responsibility
34837 atm_vcc->push (atm_vcc, skb);
34838 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
34839 } else {
34840 PRINTK (KERN_INFO, "dropped over-size frame");
34841 // should we count this?
34842 - atomic_inc(&atm_vcc->stats->rx_drop);
34843 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34844 }
34845
34846 } else {
34847 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
34848 }
34849
34850 if (check_area (skb->data, skb->len)) {
34851 - atomic_inc(&atm_vcc->stats->tx_err);
34852 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
34853 return -ENOMEM; // ?
34854 }
34855
34856 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
34857 index 0e3f8f9..765a7a5 100644
34858 --- a/drivers/atm/atmtcp.c
34859 +++ b/drivers/atm/atmtcp.c
34860 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34861 if (vcc->pop) vcc->pop(vcc,skb);
34862 else dev_kfree_skb(skb);
34863 if (dev_data) return 0;
34864 - atomic_inc(&vcc->stats->tx_err);
34865 + atomic_inc_unchecked(&vcc->stats->tx_err);
34866 return -ENOLINK;
34867 }
34868 size = skb->len+sizeof(struct atmtcp_hdr);
34869 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34870 if (!new_skb) {
34871 if (vcc->pop) vcc->pop(vcc,skb);
34872 else dev_kfree_skb(skb);
34873 - atomic_inc(&vcc->stats->tx_err);
34874 + atomic_inc_unchecked(&vcc->stats->tx_err);
34875 return -ENOBUFS;
34876 }
34877 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34878 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34879 if (vcc->pop) vcc->pop(vcc,skb);
34880 else dev_kfree_skb(skb);
34881 out_vcc->push(out_vcc,new_skb);
34882 - atomic_inc(&vcc->stats->tx);
34883 - atomic_inc(&out_vcc->stats->rx);
34884 + atomic_inc_unchecked(&vcc->stats->tx);
34885 + atomic_inc_unchecked(&out_vcc->stats->rx);
34886 return 0;
34887 }
34888
34889 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34890 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34891 read_unlock(&vcc_sklist_lock);
34892 if (!out_vcc) {
34893 - atomic_inc(&vcc->stats->tx_err);
34894 + atomic_inc_unchecked(&vcc->stats->tx_err);
34895 goto done;
34896 }
34897 skb_pull(skb,sizeof(struct atmtcp_hdr));
34898 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34899 __net_timestamp(new_skb);
34900 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34901 out_vcc->push(out_vcc,new_skb);
34902 - atomic_inc(&vcc->stats->tx);
34903 - atomic_inc(&out_vcc->stats->rx);
34904 + atomic_inc_unchecked(&vcc->stats->tx);
34905 + atomic_inc_unchecked(&out_vcc->stats->rx);
34906 done:
34907 if (vcc->pop) vcc->pop(vcc,skb);
34908 else dev_kfree_skb(skb);
34909 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34910 index b1955ba..b179940 100644
34911 --- a/drivers/atm/eni.c
34912 +++ b/drivers/atm/eni.c
34913 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34914 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34915 vcc->dev->number);
34916 length = 0;
34917 - atomic_inc(&vcc->stats->rx_err);
34918 + atomic_inc_unchecked(&vcc->stats->rx_err);
34919 }
34920 else {
34921 length = ATM_CELL_SIZE-1; /* no HEC */
34922 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34923 size);
34924 }
34925 eff = length = 0;
34926 - atomic_inc(&vcc->stats->rx_err);
34927 + atomic_inc_unchecked(&vcc->stats->rx_err);
34928 }
34929 else {
34930 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34931 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34932 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34933 vcc->dev->number,vcc->vci,length,size << 2,descr);
34934 length = eff = 0;
34935 - atomic_inc(&vcc->stats->rx_err);
34936 + atomic_inc_unchecked(&vcc->stats->rx_err);
34937 }
34938 }
34939 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34940 @@ -767,7 +767,7 @@ rx_dequeued++;
34941 vcc->push(vcc,skb);
34942 pushed++;
34943 }
34944 - atomic_inc(&vcc->stats->rx);
34945 + atomic_inc_unchecked(&vcc->stats->rx);
34946 }
34947 wake_up(&eni_dev->rx_wait);
34948 }
34949 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34950 PCI_DMA_TODEVICE);
34951 if (vcc->pop) vcc->pop(vcc,skb);
34952 else dev_kfree_skb_irq(skb);
34953 - atomic_inc(&vcc->stats->tx);
34954 + atomic_inc_unchecked(&vcc->stats->tx);
34955 wake_up(&eni_dev->tx_wait);
34956 dma_complete++;
34957 }
34958 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34959 index b41c948..a002b17 100644
34960 --- a/drivers/atm/firestream.c
34961 +++ b/drivers/atm/firestream.c
34962 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34963 }
34964 }
34965
34966 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34967 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34968
34969 fs_dprintk (FS_DEBUG_TXMEM, "i");
34970 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34971 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34972 #endif
34973 skb_put (skb, qe->p1 & 0xffff);
34974 ATM_SKB(skb)->vcc = atm_vcc;
34975 - atomic_inc(&atm_vcc->stats->rx);
34976 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34977 __net_timestamp(skb);
34978 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34979 atm_vcc->push (atm_vcc, skb);
34980 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34981 kfree (pe);
34982 }
34983 if (atm_vcc)
34984 - atomic_inc(&atm_vcc->stats->rx_drop);
34985 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34986 break;
34987 case 0x1f: /* Reassembly abort: no buffers. */
34988 /* Silently increment error counter. */
34989 if (atm_vcc)
34990 - atomic_inc(&atm_vcc->stats->rx_drop);
34991 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34992 break;
34993 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34994 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34995 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34996 index 204814e..cede831 100644
34997 --- a/drivers/atm/fore200e.c
34998 +++ b/drivers/atm/fore200e.c
34999 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35000 #endif
35001 /* check error condition */
35002 if (*entry->status & STATUS_ERROR)
35003 - atomic_inc(&vcc->stats->tx_err);
35004 + atomic_inc_unchecked(&vcc->stats->tx_err);
35005 else
35006 - atomic_inc(&vcc->stats->tx);
35007 + atomic_inc_unchecked(&vcc->stats->tx);
35008 }
35009 }
35010
35011 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35012 if (skb == NULL) {
35013 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35014
35015 - atomic_inc(&vcc->stats->rx_drop);
35016 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35017 return -ENOMEM;
35018 }
35019
35020 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35021
35022 dev_kfree_skb_any(skb);
35023
35024 - atomic_inc(&vcc->stats->rx_drop);
35025 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35026 return -ENOMEM;
35027 }
35028
35029 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35030
35031 vcc->push(vcc, skb);
35032 - atomic_inc(&vcc->stats->rx);
35033 + atomic_inc_unchecked(&vcc->stats->rx);
35034
35035 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35036
35037 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35038 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35039 fore200e->atm_dev->number,
35040 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35041 - atomic_inc(&vcc->stats->rx_err);
35042 + atomic_inc_unchecked(&vcc->stats->rx_err);
35043 }
35044 }
35045
35046 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35047 goto retry_here;
35048 }
35049
35050 - atomic_inc(&vcc->stats->tx_err);
35051 + atomic_inc_unchecked(&vcc->stats->tx_err);
35052
35053 fore200e->tx_sat++;
35054 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35055 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35056 index 507362a..a845e57 100644
35057 --- a/drivers/atm/he.c
35058 +++ b/drivers/atm/he.c
35059 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35060
35061 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35062 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35063 - atomic_inc(&vcc->stats->rx_drop);
35064 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35065 goto return_host_buffers;
35066 }
35067
35068 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35069 RBRQ_LEN_ERR(he_dev->rbrq_head)
35070 ? "LEN_ERR" : "",
35071 vcc->vpi, vcc->vci);
35072 - atomic_inc(&vcc->stats->rx_err);
35073 + atomic_inc_unchecked(&vcc->stats->rx_err);
35074 goto return_host_buffers;
35075 }
35076
35077 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35078 vcc->push(vcc, skb);
35079 spin_lock(&he_dev->global_lock);
35080
35081 - atomic_inc(&vcc->stats->rx);
35082 + atomic_inc_unchecked(&vcc->stats->rx);
35083
35084 return_host_buffers:
35085 ++pdus_assembled;
35086 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35087 tpd->vcc->pop(tpd->vcc, tpd->skb);
35088 else
35089 dev_kfree_skb_any(tpd->skb);
35090 - atomic_inc(&tpd->vcc->stats->tx_err);
35091 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35092 }
35093 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35094 return;
35095 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35096 vcc->pop(vcc, skb);
35097 else
35098 dev_kfree_skb_any(skb);
35099 - atomic_inc(&vcc->stats->tx_err);
35100 + atomic_inc_unchecked(&vcc->stats->tx_err);
35101 return -EINVAL;
35102 }
35103
35104 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35105 vcc->pop(vcc, skb);
35106 else
35107 dev_kfree_skb_any(skb);
35108 - atomic_inc(&vcc->stats->tx_err);
35109 + atomic_inc_unchecked(&vcc->stats->tx_err);
35110 return -EINVAL;
35111 }
35112 #endif
35113 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35114 vcc->pop(vcc, skb);
35115 else
35116 dev_kfree_skb_any(skb);
35117 - atomic_inc(&vcc->stats->tx_err);
35118 + atomic_inc_unchecked(&vcc->stats->tx_err);
35119 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35120 return -ENOMEM;
35121 }
35122 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35123 vcc->pop(vcc, skb);
35124 else
35125 dev_kfree_skb_any(skb);
35126 - atomic_inc(&vcc->stats->tx_err);
35127 + atomic_inc_unchecked(&vcc->stats->tx_err);
35128 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35129 return -ENOMEM;
35130 }
35131 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35132 __enqueue_tpd(he_dev, tpd, cid);
35133 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35134
35135 - atomic_inc(&vcc->stats->tx);
35136 + atomic_inc_unchecked(&vcc->stats->tx);
35137
35138 return 0;
35139 }
35140 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35141 index 1dc0519..1aadaf7 100644
35142 --- a/drivers/atm/horizon.c
35143 +++ b/drivers/atm/horizon.c
35144 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35145 {
35146 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35147 // VC layer stats
35148 - atomic_inc(&vcc->stats->rx);
35149 + atomic_inc_unchecked(&vcc->stats->rx);
35150 __net_timestamp(skb);
35151 // end of our responsibility
35152 vcc->push (vcc, skb);
35153 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35154 dev->tx_iovec = NULL;
35155
35156 // VC layer stats
35157 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35158 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35159
35160 // free the skb
35161 hrz_kfree_skb (skb);
35162 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35163 index 272f009..a18ba55 100644
35164 --- a/drivers/atm/idt77252.c
35165 +++ b/drivers/atm/idt77252.c
35166 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35167 else
35168 dev_kfree_skb(skb);
35169
35170 - atomic_inc(&vcc->stats->tx);
35171 + atomic_inc_unchecked(&vcc->stats->tx);
35172 }
35173
35174 atomic_dec(&scq->used);
35175 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35176 if ((sb = dev_alloc_skb(64)) == NULL) {
35177 printk("%s: Can't allocate buffers for aal0.\n",
35178 card->name);
35179 - atomic_add(i, &vcc->stats->rx_drop);
35180 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35181 break;
35182 }
35183 if (!atm_charge(vcc, sb->truesize)) {
35184 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35185 card->name);
35186 - atomic_add(i - 1, &vcc->stats->rx_drop);
35187 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35188 dev_kfree_skb(sb);
35189 break;
35190 }
35191 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35192 ATM_SKB(sb)->vcc = vcc;
35193 __net_timestamp(sb);
35194 vcc->push(vcc, sb);
35195 - atomic_inc(&vcc->stats->rx);
35196 + atomic_inc_unchecked(&vcc->stats->rx);
35197
35198 cell += ATM_CELL_PAYLOAD;
35199 }
35200 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35201 "(CDC: %08x)\n",
35202 card->name, len, rpp->len, readl(SAR_REG_CDC));
35203 recycle_rx_pool_skb(card, rpp);
35204 - atomic_inc(&vcc->stats->rx_err);
35205 + atomic_inc_unchecked(&vcc->stats->rx_err);
35206 return;
35207 }
35208 if (stat & SAR_RSQE_CRC) {
35209 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35210 recycle_rx_pool_skb(card, rpp);
35211 - atomic_inc(&vcc->stats->rx_err);
35212 + atomic_inc_unchecked(&vcc->stats->rx_err);
35213 return;
35214 }
35215 if (skb_queue_len(&rpp->queue) > 1) {
35216 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35217 RXPRINTK("%s: Can't alloc RX skb.\n",
35218 card->name);
35219 recycle_rx_pool_skb(card, rpp);
35220 - atomic_inc(&vcc->stats->rx_err);
35221 + atomic_inc_unchecked(&vcc->stats->rx_err);
35222 return;
35223 }
35224 if (!atm_charge(vcc, skb->truesize)) {
35225 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35226 __net_timestamp(skb);
35227
35228 vcc->push(vcc, skb);
35229 - atomic_inc(&vcc->stats->rx);
35230 + atomic_inc_unchecked(&vcc->stats->rx);
35231
35232 return;
35233 }
35234 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35235 __net_timestamp(skb);
35236
35237 vcc->push(vcc, skb);
35238 - atomic_inc(&vcc->stats->rx);
35239 + atomic_inc_unchecked(&vcc->stats->rx);
35240
35241 if (skb->truesize > SAR_FB_SIZE_3)
35242 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35243 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35244 if (vcc->qos.aal != ATM_AAL0) {
35245 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35246 card->name, vpi, vci);
35247 - atomic_inc(&vcc->stats->rx_drop);
35248 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35249 goto drop;
35250 }
35251
35252 if ((sb = dev_alloc_skb(64)) == NULL) {
35253 printk("%s: Can't allocate buffers for AAL0.\n",
35254 card->name);
35255 - atomic_inc(&vcc->stats->rx_err);
35256 + atomic_inc_unchecked(&vcc->stats->rx_err);
35257 goto drop;
35258 }
35259
35260 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35261 ATM_SKB(sb)->vcc = vcc;
35262 __net_timestamp(sb);
35263 vcc->push(vcc, sb);
35264 - atomic_inc(&vcc->stats->rx);
35265 + atomic_inc_unchecked(&vcc->stats->rx);
35266
35267 drop:
35268 skb_pull(queue, 64);
35269 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35270
35271 if (vc == NULL) {
35272 printk("%s: NULL connection in send().\n", card->name);
35273 - atomic_inc(&vcc->stats->tx_err);
35274 + atomic_inc_unchecked(&vcc->stats->tx_err);
35275 dev_kfree_skb(skb);
35276 return -EINVAL;
35277 }
35278 if (!test_bit(VCF_TX, &vc->flags)) {
35279 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35280 - atomic_inc(&vcc->stats->tx_err);
35281 + atomic_inc_unchecked(&vcc->stats->tx_err);
35282 dev_kfree_skb(skb);
35283 return -EINVAL;
35284 }
35285 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35286 break;
35287 default:
35288 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35289 - atomic_inc(&vcc->stats->tx_err);
35290 + atomic_inc_unchecked(&vcc->stats->tx_err);
35291 dev_kfree_skb(skb);
35292 return -EINVAL;
35293 }
35294
35295 if (skb_shinfo(skb)->nr_frags != 0) {
35296 printk("%s: No scatter-gather yet.\n", card->name);
35297 - atomic_inc(&vcc->stats->tx_err);
35298 + atomic_inc_unchecked(&vcc->stats->tx_err);
35299 dev_kfree_skb(skb);
35300 return -EINVAL;
35301 }
35302 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35303
35304 err = queue_skb(card, vc, skb, oam);
35305 if (err) {
35306 - atomic_inc(&vcc->stats->tx_err);
35307 + atomic_inc_unchecked(&vcc->stats->tx_err);
35308 dev_kfree_skb(skb);
35309 return err;
35310 }
35311 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35312 skb = dev_alloc_skb(64);
35313 if (!skb) {
35314 printk("%s: Out of memory in send_oam().\n", card->name);
35315 - atomic_inc(&vcc->stats->tx_err);
35316 + atomic_inc_unchecked(&vcc->stats->tx_err);
35317 return -ENOMEM;
35318 }
35319 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35320 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35321 index 4217f29..88f547a 100644
35322 --- a/drivers/atm/iphase.c
35323 +++ b/drivers/atm/iphase.c
35324 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35325 status = (u_short) (buf_desc_ptr->desc_mode);
35326 if (status & (RX_CER | RX_PTE | RX_OFL))
35327 {
35328 - atomic_inc(&vcc->stats->rx_err);
35329 + atomic_inc_unchecked(&vcc->stats->rx_err);
35330 IF_ERR(printk("IA: bad packet, dropping it");)
35331 if (status & RX_CER) {
35332 IF_ERR(printk(" cause: packet CRC error\n");)
35333 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35334 len = dma_addr - buf_addr;
35335 if (len > iadev->rx_buf_sz) {
35336 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35337 - atomic_inc(&vcc->stats->rx_err);
35338 + atomic_inc_unchecked(&vcc->stats->rx_err);
35339 goto out_free_desc;
35340 }
35341
35342 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35343 ia_vcc = INPH_IA_VCC(vcc);
35344 if (ia_vcc == NULL)
35345 {
35346 - atomic_inc(&vcc->stats->rx_err);
35347 + atomic_inc_unchecked(&vcc->stats->rx_err);
35348 atm_return(vcc, skb->truesize);
35349 dev_kfree_skb_any(skb);
35350 goto INCR_DLE;
35351 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35352 if ((length > iadev->rx_buf_sz) || (length >
35353 (skb->len - sizeof(struct cpcs_trailer))))
35354 {
35355 - atomic_inc(&vcc->stats->rx_err);
35356 + atomic_inc_unchecked(&vcc->stats->rx_err);
35357 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35358 length, skb->len);)
35359 atm_return(vcc, skb->truesize);
35360 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35361
35362 IF_RX(printk("rx_dle_intr: skb push");)
35363 vcc->push(vcc,skb);
35364 - atomic_inc(&vcc->stats->rx);
35365 + atomic_inc_unchecked(&vcc->stats->rx);
35366 iadev->rx_pkt_cnt++;
35367 }
35368 INCR_DLE:
35369 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
35370 {
35371 struct k_sonet_stats *stats;
35372 stats = &PRIV(_ia_dev[board])->sonet_stats;
35373 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
35374 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
35375 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
35376 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
35377 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
35378 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
35379 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
35380 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
35381 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
35382 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
35383 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
35384 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
35385 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
35386 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
35387 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
35388 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
35389 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
35390 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
35391 }
35392 ia_cmds.status = 0;
35393 break;
35394 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35395 if ((desc == 0) || (desc > iadev->num_tx_desc))
35396 {
35397 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
35398 - atomic_inc(&vcc->stats->tx);
35399 + atomic_inc_unchecked(&vcc->stats->tx);
35400 if (vcc->pop)
35401 vcc->pop(vcc, skb);
35402 else
35403 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
35404 ATM_DESC(skb) = vcc->vci;
35405 skb_queue_tail(&iadev->tx_dma_q, skb);
35406
35407 - atomic_inc(&vcc->stats->tx);
35408 + atomic_inc_unchecked(&vcc->stats->tx);
35409 iadev->tx_pkt_cnt++;
35410 /* Increment transaction counter */
35411 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
35412
35413 #if 0
35414 /* add flow control logic */
35415 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
35416 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
35417 if (iavcc->vc_desc_cnt > 10) {
35418 vcc->tx_quota = vcc->tx_quota * 3 / 4;
35419 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
35420 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
35421 index fa7d701..1e404c7 100644
35422 --- a/drivers/atm/lanai.c
35423 +++ b/drivers/atm/lanai.c
35424 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
35425 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
35426 lanai_endtx(lanai, lvcc);
35427 lanai_free_skb(lvcc->tx.atmvcc, skb);
35428 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
35429 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
35430 }
35431
35432 /* Try to fill the buffer - don't call unless there is backlog */
35433 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
35434 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
35435 __net_timestamp(skb);
35436 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
35437 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
35438 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
35439 out:
35440 lvcc->rx.buf.ptr = end;
35441 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
35442 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35443 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
35444 "vcc %d\n", lanai->number, (unsigned int) s, vci);
35445 lanai->stats.service_rxnotaal5++;
35446 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35447 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35448 return 0;
35449 }
35450 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
35451 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35452 int bytes;
35453 read_unlock(&vcc_sklist_lock);
35454 DPRINTK("got trashed rx pdu on vci %d\n", vci);
35455 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35456 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35457 lvcc->stats.x.aal5.service_trash++;
35458 bytes = (SERVICE_GET_END(s) * 16) -
35459 (((unsigned long) lvcc->rx.buf.ptr) -
35460 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35461 }
35462 if (s & SERVICE_STREAM) {
35463 read_unlock(&vcc_sklist_lock);
35464 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35465 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35466 lvcc->stats.x.aal5.service_stream++;
35467 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
35468 "PDU on VCI %d!\n", lanai->number, vci);
35469 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
35470 return 0;
35471 }
35472 DPRINTK("got rx crc error on vci %d\n", vci);
35473 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
35474 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
35475 lvcc->stats.x.aal5.service_rxcrc++;
35476 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
35477 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
35478 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
35479 index 6587dc2..149833d 100644
35480 --- a/drivers/atm/nicstar.c
35481 +++ b/drivers/atm/nicstar.c
35482 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35483 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
35484 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
35485 card->index);
35486 - atomic_inc(&vcc->stats->tx_err);
35487 + atomic_inc_unchecked(&vcc->stats->tx_err);
35488 dev_kfree_skb_any(skb);
35489 return -EINVAL;
35490 }
35491 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35492 if (!vc->tx) {
35493 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
35494 card->index);
35495 - atomic_inc(&vcc->stats->tx_err);
35496 + atomic_inc_unchecked(&vcc->stats->tx_err);
35497 dev_kfree_skb_any(skb);
35498 return -EINVAL;
35499 }
35500 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35501 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
35502 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
35503 card->index);
35504 - atomic_inc(&vcc->stats->tx_err);
35505 + atomic_inc_unchecked(&vcc->stats->tx_err);
35506 dev_kfree_skb_any(skb);
35507 return -EINVAL;
35508 }
35509
35510 if (skb_shinfo(skb)->nr_frags != 0) {
35511 printk("nicstar%d: No scatter-gather yet.\n", card->index);
35512 - atomic_inc(&vcc->stats->tx_err);
35513 + atomic_inc_unchecked(&vcc->stats->tx_err);
35514 dev_kfree_skb_any(skb);
35515 return -EINVAL;
35516 }
35517 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
35518 }
35519
35520 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
35521 - atomic_inc(&vcc->stats->tx_err);
35522 + atomic_inc_unchecked(&vcc->stats->tx_err);
35523 dev_kfree_skb_any(skb);
35524 return -EIO;
35525 }
35526 - atomic_inc(&vcc->stats->tx);
35527 + atomic_inc_unchecked(&vcc->stats->tx);
35528
35529 return 0;
35530 }
35531 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35532 printk
35533 ("nicstar%d: Can't allocate buffers for aal0.\n",
35534 card->index);
35535 - atomic_add(i, &vcc->stats->rx_drop);
35536 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35537 break;
35538 }
35539 if (!atm_charge(vcc, sb->truesize)) {
35540 RXPRINTK
35541 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
35542 card->index);
35543 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35544 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
35545 dev_kfree_skb_any(sb);
35546 break;
35547 }
35548 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35549 ATM_SKB(sb)->vcc = vcc;
35550 __net_timestamp(sb);
35551 vcc->push(vcc, sb);
35552 - atomic_inc(&vcc->stats->rx);
35553 + atomic_inc_unchecked(&vcc->stats->rx);
35554 cell += ATM_CELL_PAYLOAD;
35555 }
35556
35557 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35558 if (iovb == NULL) {
35559 printk("nicstar%d: Out of iovec buffers.\n",
35560 card->index);
35561 - atomic_inc(&vcc->stats->rx_drop);
35562 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35563 recycle_rx_buf(card, skb);
35564 return;
35565 }
35566 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35567 small or large buffer itself. */
35568 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
35569 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
35570 - atomic_inc(&vcc->stats->rx_err);
35571 + atomic_inc_unchecked(&vcc->stats->rx_err);
35572 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35573 NS_MAX_IOVECS);
35574 NS_PRV_IOVCNT(iovb) = 0;
35575 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35576 ("nicstar%d: Expected a small buffer, and this is not one.\n",
35577 card->index);
35578 which_list(card, skb);
35579 - atomic_inc(&vcc->stats->rx_err);
35580 + atomic_inc_unchecked(&vcc->stats->rx_err);
35581 recycle_rx_buf(card, skb);
35582 vc->rx_iov = NULL;
35583 recycle_iov_buf(card, iovb);
35584 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35585 ("nicstar%d: Expected a large buffer, and this is not one.\n",
35586 card->index);
35587 which_list(card, skb);
35588 - atomic_inc(&vcc->stats->rx_err);
35589 + atomic_inc_unchecked(&vcc->stats->rx_err);
35590 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35591 NS_PRV_IOVCNT(iovb));
35592 vc->rx_iov = NULL;
35593 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35594 printk(" - PDU size mismatch.\n");
35595 else
35596 printk(".\n");
35597 - atomic_inc(&vcc->stats->rx_err);
35598 + atomic_inc_unchecked(&vcc->stats->rx_err);
35599 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
35600 NS_PRV_IOVCNT(iovb));
35601 vc->rx_iov = NULL;
35602 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35603 /* skb points to a small buffer */
35604 if (!atm_charge(vcc, skb->truesize)) {
35605 push_rxbufs(card, skb);
35606 - atomic_inc(&vcc->stats->rx_drop);
35607 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35608 } else {
35609 skb_put(skb, len);
35610 dequeue_sm_buf(card, skb);
35611 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35612 ATM_SKB(skb)->vcc = vcc;
35613 __net_timestamp(skb);
35614 vcc->push(vcc, skb);
35615 - atomic_inc(&vcc->stats->rx);
35616 + atomic_inc_unchecked(&vcc->stats->rx);
35617 }
35618 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
35619 struct sk_buff *sb;
35620 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35621 if (len <= NS_SMBUFSIZE) {
35622 if (!atm_charge(vcc, sb->truesize)) {
35623 push_rxbufs(card, sb);
35624 - atomic_inc(&vcc->stats->rx_drop);
35625 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35626 } else {
35627 skb_put(sb, len);
35628 dequeue_sm_buf(card, sb);
35629 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35630 ATM_SKB(sb)->vcc = vcc;
35631 __net_timestamp(sb);
35632 vcc->push(vcc, sb);
35633 - atomic_inc(&vcc->stats->rx);
35634 + atomic_inc_unchecked(&vcc->stats->rx);
35635 }
35636
35637 push_rxbufs(card, skb);
35638 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35639
35640 if (!atm_charge(vcc, skb->truesize)) {
35641 push_rxbufs(card, skb);
35642 - atomic_inc(&vcc->stats->rx_drop);
35643 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35644 } else {
35645 dequeue_lg_buf(card, skb);
35646 #ifdef NS_USE_DESTRUCTORS
35647 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35648 ATM_SKB(skb)->vcc = vcc;
35649 __net_timestamp(skb);
35650 vcc->push(vcc, skb);
35651 - atomic_inc(&vcc->stats->rx);
35652 + atomic_inc_unchecked(&vcc->stats->rx);
35653 }
35654
35655 push_rxbufs(card, sb);
35656 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35657 printk
35658 ("nicstar%d: Out of huge buffers.\n",
35659 card->index);
35660 - atomic_inc(&vcc->stats->rx_drop);
35661 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35662 recycle_iovec_rx_bufs(card,
35663 (struct iovec *)
35664 iovb->data,
35665 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35666 card->hbpool.count++;
35667 } else
35668 dev_kfree_skb_any(hb);
35669 - atomic_inc(&vcc->stats->rx_drop);
35670 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35671 } else {
35672 /* Copy the small buffer to the huge buffer */
35673 sb = (struct sk_buff *)iov->iov_base;
35674 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
35675 #endif /* NS_USE_DESTRUCTORS */
35676 __net_timestamp(hb);
35677 vcc->push(vcc, hb);
35678 - atomic_inc(&vcc->stats->rx);
35679 + atomic_inc_unchecked(&vcc->stats->rx);
35680 }
35681 }
35682
35683 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
35684 index 32784d1..4a8434a 100644
35685 --- a/drivers/atm/solos-pci.c
35686 +++ b/drivers/atm/solos-pci.c
35687 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
35688 }
35689 atm_charge(vcc, skb->truesize);
35690 vcc->push(vcc, skb);
35691 - atomic_inc(&vcc->stats->rx);
35692 + atomic_inc_unchecked(&vcc->stats->rx);
35693 break;
35694
35695 case PKT_STATUS:
35696 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
35697 vcc = SKB_CB(oldskb)->vcc;
35698
35699 if (vcc) {
35700 - atomic_inc(&vcc->stats->tx);
35701 + atomic_inc_unchecked(&vcc->stats->tx);
35702 solos_pop(vcc, oldskb);
35703 } else {
35704 dev_kfree_skb_irq(oldskb);
35705 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
35706 index 0215934..ce9f5b1 100644
35707 --- a/drivers/atm/suni.c
35708 +++ b/drivers/atm/suni.c
35709 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
35710
35711
35712 #define ADD_LIMITED(s,v) \
35713 - atomic_add((v),&stats->s); \
35714 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
35715 + atomic_add_unchecked((v),&stats->s); \
35716 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
35717
35718
35719 static void suni_hz(unsigned long from_timer)
35720 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
35721 index 5120a96..e2572bd 100644
35722 --- a/drivers/atm/uPD98402.c
35723 +++ b/drivers/atm/uPD98402.c
35724 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
35725 struct sonet_stats tmp;
35726 int error = 0;
35727
35728 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35729 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
35730 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
35731 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
35732 if (zero && !error) {
35733 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
35734
35735
35736 #define ADD_LIMITED(s,v) \
35737 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
35738 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
35739 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35740 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
35741 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
35742 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
35743
35744
35745 static void stat_event(struct atm_dev *dev)
35746 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
35747 if (reason & uPD98402_INT_PFM) stat_event(dev);
35748 if (reason & uPD98402_INT_PCO) {
35749 (void) GET(PCOCR); /* clear interrupt cause */
35750 - atomic_add(GET(HECCT),
35751 + atomic_add_unchecked(GET(HECCT),
35752 &PRIV(dev)->sonet_stats.uncorr_hcs);
35753 }
35754 if ((reason & uPD98402_INT_RFO) &&
35755 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
35756 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
35757 uPD98402_INT_LOS),PIMR); /* enable them */
35758 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
35759 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35760 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
35761 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
35762 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
35763 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
35764 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
35765 return 0;
35766 }
35767
35768 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
35769 index 969c3c2..9b72956 100644
35770 --- a/drivers/atm/zatm.c
35771 +++ b/drivers/atm/zatm.c
35772 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35773 }
35774 if (!size) {
35775 dev_kfree_skb_irq(skb);
35776 - if (vcc) atomic_inc(&vcc->stats->rx_err);
35777 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
35778 continue;
35779 }
35780 if (!atm_charge(vcc,skb->truesize)) {
35781 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
35782 skb->len = size;
35783 ATM_SKB(skb)->vcc = vcc;
35784 vcc->push(vcc,skb);
35785 - atomic_inc(&vcc->stats->rx);
35786 + atomic_inc_unchecked(&vcc->stats->rx);
35787 }
35788 zout(pos & 0xffff,MTA(mbx));
35789 #if 0 /* probably a stupid idea */
35790 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
35791 skb_queue_head(&zatm_vcc->backlog,skb);
35792 break;
35793 }
35794 - atomic_inc(&vcc->stats->tx);
35795 + atomic_inc_unchecked(&vcc->stats->tx);
35796 wake_up(&zatm_vcc->tx_wait);
35797 }
35798
35799 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
35800 index d414331..b4dd4ba 100644
35801 --- a/drivers/base/bus.c
35802 +++ b/drivers/base/bus.c
35803 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
35804 return -EINVAL;
35805
35806 mutex_lock(&subsys->p->mutex);
35807 - list_add_tail(&sif->node, &subsys->p->interfaces);
35808 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
35809 if (sif->add_dev) {
35810 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35811 while ((dev = subsys_dev_iter_next(&iter)))
35812 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
35813 subsys = sif->subsys;
35814
35815 mutex_lock(&subsys->p->mutex);
35816 - list_del_init(&sif->node);
35817 + pax_list_del_init((struct list_head *)&sif->node);
35818 if (sif->remove_dev) {
35819 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
35820 while ((dev = subsys_dev_iter_next(&iter)))
35821 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
35822 index 7413d06..79155fa 100644
35823 --- a/drivers/base/devtmpfs.c
35824 +++ b/drivers/base/devtmpfs.c
35825 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
35826 if (!thread)
35827 return 0;
35828
35829 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
35830 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
35831 if (err)
35832 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
35833 else
35834 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
35835 *err = sys_unshare(CLONE_NEWNS);
35836 if (*err)
35837 goto out;
35838 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
35839 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
35840 if (*err)
35841 goto out;
35842 - sys_chdir("/.."); /* will traverse into overmounted root */
35843 - sys_chroot(".");
35844 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
35845 + sys_chroot((char __force_user *)".");
35846 complete(&setup_done);
35847 while (1) {
35848 spin_lock(&req_lock);
35849 diff --git a/drivers/base/node.c b/drivers/base/node.c
35850 index 7616a77c..8f57f51 100644
35851 --- a/drivers/base/node.c
35852 +++ b/drivers/base/node.c
35853 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35854 struct node_attr {
35855 struct device_attribute attr;
35856 enum node_states state;
35857 -};
35858 +} __do_const;
35859
35860 static ssize_t show_node_state(struct device *dev,
35861 struct device_attribute *attr, char *buf)
35862 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35863 index bfb8955..42c9b9a 100644
35864 --- a/drivers/base/power/domain.c
35865 +++ b/drivers/base/power/domain.c
35866 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35867 {
35868 struct cpuidle_driver *cpuidle_drv;
35869 struct gpd_cpu_data *cpu_data;
35870 - struct cpuidle_state *idle_state;
35871 + cpuidle_state_no_const *idle_state;
35872 int ret = 0;
35873
35874 if (IS_ERR_OR_NULL(genpd) || state < 0)
35875 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35876 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35877 {
35878 struct gpd_cpu_data *cpu_data;
35879 - struct cpuidle_state *idle_state;
35880 + cpuidle_state_no_const *idle_state;
35881 int ret = 0;
35882
35883 if (IS_ERR_OR_NULL(genpd))
35884 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35885 index a53ebd2..8f73eeb 100644
35886 --- a/drivers/base/power/sysfs.c
35887 +++ b/drivers/base/power/sysfs.c
35888 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35889 return -EIO;
35890 }
35891 }
35892 - return sprintf(buf, p);
35893 + return sprintf(buf, "%s", p);
35894 }
35895
35896 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35897 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35898 index 2d56f41..8830f19 100644
35899 --- a/drivers/base/power/wakeup.c
35900 +++ b/drivers/base/power/wakeup.c
35901 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35902 * They need to be modified together atomically, so it's better to use one
35903 * atomic variable to hold them both.
35904 */
35905 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35906 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35907
35908 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35909 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35910
35911 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35912 {
35913 - unsigned int comb = atomic_read(&combined_event_count);
35914 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35915
35916 *cnt = (comb >> IN_PROGRESS_BITS);
35917 *inpr = comb & MAX_IN_PROGRESS;
35918 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35919 ws->start_prevent_time = ws->last_time;
35920
35921 /* Increment the counter of events in progress. */
35922 - cec = atomic_inc_return(&combined_event_count);
35923 + cec = atomic_inc_return_unchecked(&combined_event_count);
35924
35925 trace_wakeup_source_activate(ws->name, cec);
35926 }
35927 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35928 * Increment the counter of registered wakeup events and decrement the
35929 * couter of wakeup events in progress simultaneously.
35930 */
35931 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35932 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35933 trace_wakeup_source_deactivate(ws->name, cec);
35934
35935 split_counters(&cnt, &inpr);
35936 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35937 index e8d11b6..7b1b36f 100644
35938 --- a/drivers/base/syscore.c
35939 +++ b/drivers/base/syscore.c
35940 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35941 void register_syscore_ops(struct syscore_ops *ops)
35942 {
35943 mutex_lock(&syscore_ops_lock);
35944 - list_add_tail(&ops->node, &syscore_ops_list);
35945 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35946 mutex_unlock(&syscore_ops_lock);
35947 }
35948 EXPORT_SYMBOL_GPL(register_syscore_ops);
35949 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35950 void unregister_syscore_ops(struct syscore_ops *ops)
35951 {
35952 mutex_lock(&syscore_ops_lock);
35953 - list_del(&ops->node);
35954 + pax_list_del((struct list_head *)&ops->node);
35955 mutex_unlock(&syscore_ops_lock);
35956 }
35957 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35958 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35959 index 90a4e6b..002d10f 100644
35960 --- a/drivers/block/cciss.c
35961 +++ b/drivers/block/cciss.c
35962 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
35963 while (!list_empty(&h->reqQ)) {
35964 c = list_entry(h->reqQ.next, CommandList_struct, list);
35965 /* can't do anything if fifo is full */
35966 - if ((h->access.fifo_full(h))) {
35967 + if ((h->access->fifo_full(h))) {
35968 dev_warn(&h->pdev->dev, "fifo full\n");
35969 break;
35970 }
35971 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
35972 h->Qdepth--;
35973
35974 /* Tell the controller execute command */
35975 - h->access.submit_command(h, c);
35976 + h->access->submit_command(h, c);
35977
35978 /* Put job onto the completed Q */
35979 addQ(&h->cmpQ, c);
35980 @@ -3447,17 +3447,17 @@ startio:
35981
35982 static inline unsigned long get_next_completion(ctlr_info_t *h)
35983 {
35984 - return h->access.command_completed(h);
35985 + return h->access->command_completed(h);
35986 }
35987
35988 static inline int interrupt_pending(ctlr_info_t *h)
35989 {
35990 - return h->access.intr_pending(h);
35991 + return h->access->intr_pending(h);
35992 }
35993
35994 static inline long interrupt_not_for_us(ctlr_info_t *h)
35995 {
35996 - return ((h->access.intr_pending(h) == 0) ||
35997 + return ((h->access->intr_pending(h) == 0) ||
35998 (h->interrupts_enabled == 0));
35999 }
36000
36001 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36002 u32 a;
36003
36004 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36005 - return h->access.command_completed(h);
36006 + return h->access->command_completed(h);
36007
36008 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36009 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36010 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36011 trans_support & CFGTBL_Trans_use_short_tags);
36012
36013 /* Change the access methods to the performant access methods */
36014 - h->access = SA5_performant_access;
36015 + h->access = &SA5_performant_access;
36016 h->transMethod = CFGTBL_Trans_Performant;
36017
36018 return;
36019 @@ -4320,7 +4320,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36020 if (prod_index < 0)
36021 return -ENODEV;
36022 h->product_name = products[prod_index].product_name;
36023 - h->access = *(products[prod_index].access);
36024 + h->access = products[prod_index].access;
36025
36026 if (cciss_board_disabled(h)) {
36027 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36028 @@ -5052,7 +5052,7 @@ reinit_after_soft_reset:
36029 }
36030
36031 /* make sure the board interrupts are off */
36032 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36033 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36034 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36035 if (rc)
36036 goto clean2;
36037 @@ -5102,7 +5102,7 @@ reinit_after_soft_reset:
36038 * fake ones to scoop up any residual completions.
36039 */
36040 spin_lock_irqsave(&h->lock, flags);
36041 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36042 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36043 spin_unlock_irqrestore(&h->lock, flags);
36044 free_irq(h->intr[h->intr_mode], h);
36045 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36046 @@ -5122,9 +5122,9 @@ reinit_after_soft_reset:
36047 dev_info(&h->pdev->dev, "Board READY.\n");
36048 dev_info(&h->pdev->dev,
36049 "Waiting for stale completions to drain.\n");
36050 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36051 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36052 msleep(10000);
36053 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36054 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36055
36056 rc = controller_reset_failed(h->cfgtable);
36057 if (rc)
36058 @@ -5147,7 +5147,7 @@ reinit_after_soft_reset:
36059 cciss_scsi_setup(h);
36060
36061 /* Turn the interrupts on so we can service requests */
36062 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36063 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36064
36065 /* Get the firmware version */
36066 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36067 @@ -5219,7 +5219,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36068 kfree(flush_buf);
36069 if (return_code != IO_OK)
36070 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36071 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36072 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36073 free_irq(h->intr[h->intr_mode], h);
36074 }
36075
36076 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36077 index 7fda30e..eb5dfe0 100644
36078 --- a/drivers/block/cciss.h
36079 +++ b/drivers/block/cciss.h
36080 @@ -101,7 +101,7 @@ struct ctlr_info
36081 /* information about each logical volume */
36082 drive_info_struct *drv[CISS_MAX_LUN];
36083
36084 - struct access_method access;
36085 + struct access_method *access;
36086
36087 /* queue and queue Info */
36088 struct list_head reqQ;
36089 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36090 index 2b94403..fd6ad1f 100644
36091 --- a/drivers/block/cpqarray.c
36092 +++ b/drivers/block/cpqarray.c
36093 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36094 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36095 goto Enomem4;
36096 }
36097 - hba[i]->access.set_intr_mask(hba[i], 0);
36098 + hba[i]->access->set_intr_mask(hba[i], 0);
36099 if (request_irq(hba[i]->intr, do_ida_intr,
36100 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36101 {
36102 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36103 add_timer(&hba[i]->timer);
36104
36105 /* Enable IRQ now that spinlock and rate limit timer are set up */
36106 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36107 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36108
36109 for(j=0; j<NWD; j++) {
36110 struct gendisk *disk = ida_gendisk[i][j];
36111 @@ -694,7 +694,7 @@ DBGINFO(
36112 for(i=0; i<NR_PRODUCTS; i++) {
36113 if (board_id == products[i].board_id) {
36114 c->product_name = products[i].product_name;
36115 - c->access = *(products[i].access);
36116 + c->access = products[i].access;
36117 break;
36118 }
36119 }
36120 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36121 hba[ctlr]->intr = intr;
36122 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36123 hba[ctlr]->product_name = products[j].product_name;
36124 - hba[ctlr]->access = *(products[j].access);
36125 + hba[ctlr]->access = products[j].access;
36126 hba[ctlr]->ctlr = ctlr;
36127 hba[ctlr]->board_id = board_id;
36128 hba[ctlr]->pci_dev = NULL; /* not PCI */
36129 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36130
36131 while((c = h->reqQ) != NULL) {
36132 /* Can't do anything if we're busy */
36133 - if (h->access.fifo_full(h) == 0)
36134 + if (h->access->fifo_full(h) == 0)
36135 return;
36136
36137 /* Get the first entry from the request Q */
36138 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36139 h->Qdepth--;
36140
36141 /* Tell the controller to do our bidding */
36142 - h->access.submit_command(h, c);
36143 + h->access->submit_command(h, c);
36144
36145 /* Get onto the completion Q */
36146 addQ(&h->cmpQ, c);
36147 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36148 unsigned long flags;
36149 __u32 a,a1;
36150
36151 - istat = h->access.intr_pending(h);
36152 + istat = h->access->intr_pending(h);
36153 /* Is this interrupt for us? */
36154 if (istat == 0)
36155 return IRQ_NONE;
36156 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36157 */
36158 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36159 if (istat & FIFO_NOT_EMPTY) {
36160 - while((a = h->access.command_completed(h))) {
36161 + while((a = h->access->command_completed(h))) {
36162 a1 = a; a &= ~3;
36163 if ((c = h->cmpQ) == NULL)
36164 {
36165 @@ -1448,11 +1448,11 @@ static int sendcmd(
36166 /*
36167 * Disable interrupt
36168 */
36169 - info_p->access.set_intr_mask(info_p, 0);
36170 + info_p->access->set_intr_mask(info_p, 0);
36171 /* Make sure there is room in the command FIFO */
36172 /* Actually it should be completely empty at this time. */
36173 for (i = 200000; i > 0; i--) {
36174 - temp = info_p->access.fifo_full(info_p);
36175 + temp = info_p->access->fifo_full(info_p);
36176 if (temp != 0) {
36177 break;
36178 }
36179 @@ -1465,7 +1465,7 @@ DBG(
36180 /*
36181 * Send the cmd
36182 */
36183 - info_p->access.submit_command(info_p, c);
36184 + info_p->access->submit_command(info_p, c);
36185 complete = pollcomplete(ctlr);
36186
36187 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36188 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36189 * we check the new geometry. Then turn interrupts back on when
36190 * we're done.
36191 */
36192 - host->access.set_intr_mask(host, 0);
36193 + host->access->set_intr_mask(host, 0);
36194 getgeometry(ctlr);
36195 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36196 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36197
36198 for(i=0; i<NWD; i++) {
36199 struct gendisk *disk = ida_gendisk[ctlr][i];
36200 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36201 /* Wait (up to 2 seconds) for a command to complete */
36202
36203 for (i = 200000; i > 0; i--) {
36204 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36205 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36206 if (done == 0) {
36207 udelay(10); /* a short fixed delay */
36208 } else
36209 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36210 index be73e9d..7fbf140 100644
36211 --- a/drivers/block/cpqarray.h
36212 +++ b/drivers/block/cpqarray.h
36213 @@ -99,7 +99,7 @@ struct ctlr_info {
36214 drv_info_t drv[NWD];
36215 struct proc_dir_entry *proc;
36216
36217 - struct access_method access;
36218 + struct access_method *access;
36219
36220 cmdlist_t *reqQ;
36221 cmdlist_t *cmpQ;
36222 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36223 index 2d7f608..11245fe 100644
36224 --- a/drivers/block/drbd/drbd_int.h
36225 +++ b/drivers/block/drbd/drbd_int.h
36226 @@ -582,7 +582,7 @@ struct drbd_epoch {
36227 struct drbd_tconn *tconn;
36228 struct list_head list;
36229 unsigned int barrier_nr;
36230 - atomic_t epoch_size; /* increased on every request added. */
36231 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36232 atomic_t active; /* increased on every req. added, and dec on every finished. */
36233 unsigned long flags;
36234 };
36235 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36236 unsigned int al_tr_number;
36237 int al_tr_cycle;
36238 wait_queue_head_t seq_wait;
36239 - atomic_t packet_seq;
36240 + atomic_unchecked_t packet_seq;
36241 unsigned int peer_seq;
36242 spinlock_t peer_seq_lock;
36243 unsigned int minor;
36244 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36245 char __user *uoptval;
36246 int err;
36247
36248 - uoptval = (char __user __force *)optval;
36249 + uoptval = (char __force_user *)optval;
36250
36251 set_fs(KERNEL_DS);
36252 if (level == SOL_SOCKET)
36253 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36254 index 55635ed..40e837c 100644
36255 --- a/drivers/block/drbd/drbd_main.c
36256 +++ b/drivers/block/drbd/drbd_main.c
36257 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36258 p->sector = sector;
36259 p->block_id = block_id;
36260 p->blksize = blksize;
36261 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36262 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36263 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36264 }
36265
36266 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36267 return -EIO;
36268 p->sector = cpu_to_be64(req->i.sector);
36269 p->block_id = (unsigned long)req;
36270 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36271 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36272 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36273 if (mdev->state.conn >= C_SYNC_SOURCE &&
36274 mdev->state.conn <= C_PAUSED_SYNC_T)
36275 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36276 {
36277 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36278
36279 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36280 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36281 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36282 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36283 kfree(tconn->current_epoch);
36284
36285 idr_destroy(&tconn->volumes);
36286 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36287 index 8cc1e64..ba7ffa9 100644
36288 --- a/drivers/block/drbd/drbd_nl.c
36289 +++ b/drivers/block/drbd/drbd_nl.c
36290 @@ -3440,7 +3440,7 @@ out:
36291
36292 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36293 {
36294 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36295 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36296 struct sk_buff *msg;
36297 struct drbd_genlmsghdr *d_out;
36298 unsigned seq;
36299 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36300 return;
36301 }
36302
36303 - seq = atomic_inc_return(&drbd_genl_seq);
36304 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36305 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36306 if (!msg)
36307 goto failed;
36308 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36309 index cc29cd3..d4b058b 100644
36310 --- a/drivers/block/drbd/drbd_receiver.c
36311 +++ b/drivers/block/drbd/drbd_receiver.c
36312 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36313 {
36314 int err;
36315
36316 - atomic_set(&mdev->packet_seq, 0);
36317 + atomic_set_unchecked(&mdev->packet_seq, 0);
36318 mdev->peer_seq = 0;
36319
36320 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36321 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36322 do {
36323 next_epoch = NULL;
36324
36325 - epoch_size = atomic_read(&epoch->epoch_size);
36326 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36327
36328 switch (ev & ~EV_CLEANUP) {
36329 case EV_PUT:
36330 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36331 rv = FE_DESTROYED;
36332 } else {
36333 epoch->flags = 0;
36334 - atomic_set(&epoch->epoch_size, 0);
36335 + atomic_set_unchecked(&epoch->epoch_size, 0);
36336 /* atomic_set(&epoch->active, 0); is already zero */
36337 if (rv == FE_STILL_LIVE)
36338 rv = FE_RECYCLED;
36339 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36340 conn_wait_active_ee_empty(tconn);
36341 drbd_flush(tconn);
36342
36343 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36344 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36345 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36346 if (epoch)
36347 break;
36348 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36349 }
36350
36351 epoch->flags = 0;
36352 - atomic_set(&epoch->epoch_size, 0);
36353 + atomic_set_unchecked(&epoch->epoch_size, 0);
36354 atomic_set(&epoch->active, 0);
36355
36356 spin_lock(&tconn->epoch_lock);
36357 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36358 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36359 list_add(&epoch->list, &tconn->current_epoch->list);
36360 tconn->current_epoch = epoch;
36361 tconn->epochs++;
36362 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36363
36364 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36365 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36366 - atomic_inc(&tconn->current_epoch->epoch_size);
36367 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36368 err2 = drbd_drain_block(mdev, pi->size);
36369 if (!err)
36370 err = err2;
36371 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36372
36373 spin_lock(&tconn->epoch_lock);
36374 peer_req->epoch = tconn->current_epoch;
36375 - atomic_inc(&peer_req->epoch->epoch_size);
36376 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
36377 atomic_inc(&peer_req->epoch->active);
36378 spin_unlock(&tconn->epoch_lock);
36379
36380 @@ -4347,7 +4347,7 @@ struct data_cmd {
36381 int expect_payload;
36382 size_t pkt_size;
36383 int (*fn)(struct drbd_tconn *, struct packet_info *);
36384 -};
36385 +} __do_const;
36386
36387 static struct data_cmd drbd_cmd_handler[] = {
36388 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
36389 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
36390 if (!list_empty(&tconn->current_epoch->list))
36391 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
36392 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
36393 - atomic_set(&tconn->current_epoch->epoch_size, 0);
36394 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
36395 tconn->send.seen_any_write_yet = false;
36396
36397 conn_info(tconn, "Connection closed\n");
36398 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
36399 struct asender_cmd {
36400 size_t pkt_size;
36401 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
36402 -};
36403 +} __do_const;
36404
36405 static struct asender_cmd asender_tbl[] = {
36406 [P_PING] = { 0, got_Ping },
36407 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
36408 index 40e7155..df5c79a 100644
36409 --- a/drivers/block/loop.c
36410 +++ b/drivers/block/loop.c
36411 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
36412
36413 file_start_write(file);
36414 set_fs(get_ds());
36415 - bw = file->f_op->write(file, buf, len, &pos);
36416 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
36417 set_fs(old_fs);
36418 file_end_write(file);
36419 if (likely(bw == len))
36420 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
36421 index f5d0ea1..c62380a 100644
36422 --- a/drivers/block/pktcdvd.c
36423 +++ b/drivers/block/pktcdvd.c
36424 @@ -84,7 +84,7 @@
36425 #define MAX_SPEED 0xffff
36426
36427 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
36428 - ~(sector_t)((pd)->settings.size - 1))
36429 + ~(sector_t)((pd)->settings.size - 1UL))
36430
36431 static DEFINE_MUTEX(pktcdvd_mutex);
36432 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
36433 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
36434 index 7332889..9ece19e 100644
36435 --- a/drivers/bus/arm-cci.c
36436 +++ b/drivers/bus/arm-cci.c
36437 @@ -419,7 +419,7 @@ static int __init cci_probe(void)
36438
36439 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
36440
36441 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
36442 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
36443 if (!ports)
36444 return -ENOMEM;
36445
36446 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
36447 index 8a3aff7..d7538c2 100644
36448 --- a/drivers/cdrom/cdrom.c
36449 +++ b/drivers/cdrom/cdrom.c
36450 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
36451 ENSURE(reset, CDC_RESET);
36452 ENSURE(generic_packet, CDC_GENERIC_PACKET);
36453 cdi->mc_flags = 0;
36454 - cdo->n_minors = 0;
36455 cdi->options = CDO_USE_FFLAGS;
36456
36457 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
36458 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
36459 else
36460 cdi->cdda_method = CDDA_OLD;
36461
36462 - if (!cdo->generic_packet)
36463 - cdo->generic_packet = cdrom_dummy_generic_packet;
36464 + if (!cdo->generic_packet) {
36465 + pax_open_kernel();
36466 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
36467 + pax_close_kernel();
36468 + }
36469
36470 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
36471 mutex_lock(&cdrom_mutex);
36472 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
36473 if (cdi->exit)
36474 cdi->exit(cdi);
36475
36476 - cdi->ops->n_minors--;
36477 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
36478 }
36479
36480 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
36481 */
36482 nr = nframes;
36483 do {
36484 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36485 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
36486 if (cgc.buffer)
36487 break;
36488
36489 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
36490 struct cdrom_device_info *cdi;
36491 int ret;
36492
36493 - ret = scnprintf(info + *pos, max_size - *pos, header);
36494 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
36495 if (!ret)
36496 return 1;
36497
36498 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
36499 index 5980cb9..6d7bd7e 100644
36500 --- a/drivers/cdrom/gdrom.c
36501 +++ b/drivers/cdrom/gdrom.c
36502 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
36503 .audio_ioctl = gdrom_audio_ioctl,
36504 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
36505 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
36506 - .n_minors = 1,
36507 };
36508
36509 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
36510 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
36511 index 1421997..33f5d6d 100644
36512 --- a/drivers/char/Kconfig
36513 +++ b/drivers/char/Kconfig
36514 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
36515
36516 config DEVKMEM
36517 bool "/dev/kmem virtual device support"
36518 - default y
36519 + default n
36520 + depends on !GRKERNSEC_KMEM
36521 help
36522 Say Y here if you want to support the /dev/kmem device. The
36523 /dev/kmem device is rarely used, but can be used for certain
36524 @@ -570,6 +571,7 @@ config DEVPORT
36525 bool
36526 depends on !M68K
36527 depends on ISA || PCI
36528 + depends on !GRKERNSEC_KMEM
36529 default y
36530
36531 source "drivers/s390/char/Kconfig"
36532 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
36533 index a48e05b..6bac831 100644
36534 --- a/drivers/char/agp/compat_ioctl.c
36535 +++ b/drivers/char/agp/compat_ioctl.c
36536 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
36537 return -ENOMEM;
36538 }
36539
36540 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
36541 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
36542 sizeof(*usegment) * ureserve.seg_count)) {
36543 kfree(usegment);
36544 kfree(ksegment);
36545 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
36546 index 1b19239..b87b143 100644
36547 --- a/drivers/char/agp/frontend.c
36548 +++ b/drivers/char/agp/frontend.c
36549 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36550 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
36551 return -EFAULT;
36552
36553 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
36554 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
36555 return -EFAULT;
36556
36557 client = agp_find_client_by_pid(reserve.pid);
36558 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
36559 if (segment == NULL)
36560 return -ENOMEM;
36561
36562 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
36563 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
36564 sizeof(struct agp_segment) * reserve.seg_count)) {
36565 kfree(segment);
36566 return -EFAULT;
36567 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
36568 index 4f94375..413694e 100644
36569 --- a/drivers/char/genrtc.c
36570 +++ b/drivers/char/genrtc.c
36571 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
36572 switch (cmd) {
36573
36574 case RTC_PLL_GET:
36575 + memset(&pll, 0, sizeof(pll));
36576 if (get_rtc_pll(&pll))
36577 return -EINVAL;
36578 else
36579 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
36580 index 448ce5e..3a76625 100644
36581 --- a/drivers/char/hpet.c
36582 +++ b/drivers/char/hpet.c
36583 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
36584 }
36585
36586 static int
36587 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
36588 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
36589 struct hpet_info *info)
36590 {
36591 struct hpet_timer __iomem *timer;
36592 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
36593 index 86fe45c..c0ea948 100644
36594 --- a/drivers/char/hw_random/intel-rng.c
36595 +++ b/drivers/char/hw_random/intel-rng.c
36596 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
36597
36598 if (no_fwh_detect)
36599 return -ENODEV;
36600 - printk(warning);
36601 + printk("%s", warning);
36602 return -EBUSY;
36603 }
36604
36605 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
36606 index 4445fa1..7c6de37 100644
36607 --- a/drivers/char/ipmi/ipmi_msghandler.c
36608 +++ b/drivers/char/ipmi/ipmi_msghandler.c
36609 @@ -420,7 +420,7 @@ struct ipmi_smi {
36610 struct proc_dir_entry *proc_dir;
36611 char proc_dir_name[10];
36612
36613 - atomic_t stats[IPMI_NUM_STATS];
36614 + atomic_unchecked_t stats[IPMI_NUM_STATS];
36615
36616 /*
36617 * run_to_completion duplicate of smb_info, smi_info
36618 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
36619
36620
36621 #define ipmi_inc_stat(intf, stat) \
36622 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
36623 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
36624 #define ipmi_get_stat(intf, stat) \
36625 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
36626 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
36627
36628 static int is_lan_addr(struct ipmi_addr *addr)
36629 {
36630 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
36631 INIT_LIST_HEAD(&intf->cmd_rcvrs);
36632 init_waitqueue_head(&intf->waitq);
36633 for (i = 0; i < IPMI_NUM_STATS; i++)
36634 - atomic_set(&intf->stats[i], 0);
36635 + atomic_set_unchecked(&intf->stats[i], 0);
36636
36637 intf->proc_dir = NULL;
36638
36639 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
36640 index af4b23f..79806fc 100644
36641 --- a/drivers/char/ipmi/ipmi_si_intf.c
36642 +++ b/drivers/char/ipmi/ipmi_si_intf.c
36643 @@ -275,7 +275,7 @@ struct smi_info {
36644 unsigned char slave_addr;
36645
36646 /* Counters and things for the proc filesystem. */
36647 - atomic_t stats[SI_NUM_STATS];
36648 + atomic_unchecked_t stats[SI_NUM_STATS];
36649
36650 struct task_struct *thread;
36651
36652 @@ -284,9 +284,9 @@ struct smi_info {
36653 };
36654
36655 #define smi_inc_stat(smi, stat) \
36656 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
36657 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
36658 #define smi_get_stat(smi, stat) \
36659 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
36660 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
36661
36662 #define SI_MAX_PARMS 4
36663
36664 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
36665 atomic_set(&new_smi->req_events, 0);
36666 new_smi->run_to_completion = 0;
36667 for (i = 0; i < SI_NUM_STATS; i++)
36668 - atomic_set(&new_smi->stats[i], 0);
36669 + atomic_set_unchecked(&new_smi->stats[i], 0);
36670
36671 new_smi->interrupt_disabled = 1;
36672 atomic_set(&new_smi->stop_operation, 0);
36673 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
36674 index f895a8c..2bc9147 100644
36675 --- a/drivers/char/mem.c
36676 +++ b/drivers/char/mem.c
36677 @@ -18,6 +18,7 @@
36678 #include <linux/raw.h>
36679 #include <linux/tty.h>
36680 #include <linux/capability.h>
36681 +#include <linux/security.h>
36682 #include <linux/ptrace.h>
36683 #include <linux/device.h>
36684 #include <linux/highmem.h>
36685 @@ -37,6 +38,10 @@
36686
36687 #define DEVPORT_MINOR 4
36688
36689 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36690 +extern const struct file_operations grsec_fops;
36691 +#endif
36692 +
36693 static inline unsigned long size_inside_page(unsigned long start,
36694 unsigned long size)
36695 {
36696 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36697
36698 while (cursor < to) {
36699 if (!devmem_is_allowed(pfn)) {
36700 +#ifdef CONFIG_GRKERNSEC_KMEM
36701 + gr_handle_mem_readwrite(from, to);
36702 +#else
36703 printk(KERN_INFO
36704 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
36705 current->comm, from, to);
36706 +#endif
36707 return 0;
36708 }
36709 cursor += PAGE_SIZE;
36710 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36711 }
36712 return 1;
36713 }
36714 +#elif defined(CONFIG_GRKERNSEC_KMEM)
36715 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36716 +{
36717 + return 0;
36718 +}
36719 #else
36720 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
36721 {
36722 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36723
36724 while (count > 0) {
36725 unsigned long remaining;
36726 + char *temp;
36727
36728 sz = size_inside_page(p, count);
36729
36730 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
36731 if (!ptr)
36732 return -EFAULT;
36733
36734 - remaining = copy_to_user(buf, ptr, sz);
36735 +#ifdef CONFIG_PAX_USERCOPY
36736 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36737 + if (!temp) {
36738 + unxlate_dev_mem_ptr(p, ptr);
36739 + return -ENOMEM;
36740 + }
36741 + memcpy(temp, ptr, sz);
36742 +#else
36743 + temp = ptr;
36744 +#endif
36745 +
36746 + remaining = copy_to_user(buf, temp, sz);
36747 +
36748 +#ifdef CONFIG_PAX_USERCOPY
36749 + kfree(temp);
36750 +#endif
36751 +
36752 unxlate_dev_mem_ptr(p, ptr);
36753 if (remaining)
36754 return -EFAULT;
36755 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36756 size_t count, loff_t *ppos)
36757 {
36758 unsigned long p = *ppos;
36759 - ssize_t low_count, read, sz;
36760 + ssize_t low_count, read, sz, err = 0;
36761 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
36762 - int err = 0;
36763
36764 read = 0;
36765 if (p < (unsigned long) high_memory) {
36766 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36767 }
36768 #endif
36769 while (low_count > 0) {
36770 + char *temp;
36771 +
36772 sz = size_inside_page(p, low_count);
36773
36774 /*
36775 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
36776 */
36777 kbuf = xlate_dev_kmem_ptr((char *)p);
36778
36779 - if (copy_to_user(buf, kbuf, sz))
36780 +#ifdef CONFIG_PAX_USERCOPY
36781 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
36782 + if (!temp)
36783 + return -ENOMEM;
36784 + memcpy(temp, kbuf, sz);
36785 +#else
36786 + temp = kbuf;
36787 +#endif
36788 +
36789 + err = copy_to_user(buf, temp, sz);
36790 +
36791 +#ifdef CONFIG_PAX_USERCOPY
36792 + kfree(temp);
36793 +#endif
36794 +
36795 + if (err)
36796 return -EFAULT;
36797 buf += sz;
36798 p += sz;
36799 @@ -822,6 +869,9 @@ static const struct memdev {
36800 #ifdef CONFIG_PRINTK
36801 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
36802 #endif
36803 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
36804 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
36805 +#endif
36806 };
36807
36808 static int memory_open(struct inode *inode, struct file *filp)
36809 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
36810 continue;
36811
36812 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
36813 - NULL, devlist[minor].name);
36814 + NULL, "%s", devlist[minor].name);
36815 }
36816
36817 return tty_init();
36818 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
36819 index 9df78e2..01ba9ae 100644
36820 --- a/drivers/char/nvram.c
36821 +++ b/drivers/char/nvram.c
36822 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
36823
36824 spin_unlock_irq(&rtc_lock);
36825
36826 - if (copy_to_user(buf, contents, tmp - contents))
36827 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
36828 return -EFAULT;
36829
36830 *ppos = i;
36831 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
36832 index 5c5cc00..ac9edb7 100644
36833 --- a/drivers/char/pcmcia/synclink_cs.c
36834 +++ b/drivers/char/pcmcia/synclink_cs.c
36835 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36836
36837 if (debug_level >= DEBUG_LEVEL_INFO)
36838 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
36839 - __FILE__, __LINE__, info->device_name, port->count);
36840 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
36841
36842 - WARN_ON(!port->count);
36843 + WARN_ON(!atomic_read(&port->count));
36844
36845 if (tty_port_close_start(port, tty, filp) == 0)
36846 goto cleanup;
36847 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36848 cleanup:
36849 if (debug_level >= DEBUG_LEVEL_INFO)
36850 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36851 - tty->driver->name, port->count);
36852 + tty->driver->name, atomic_read(&port->count));
36853 }
36854
36855 /* Wait until the transmitter is empty.
36856 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36857
36858 if (debug_level >= DEBUG_LEVEL_INFO)
36859 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36860 - __FILE__, __LINE__, tty->driver->name, port->count);
36861 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36862
36863 /* If port is closing, signal caller to try again */
36864 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36865 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36866 goto cleanup;
36867 }
36868 spin_lock(&port->lock);
36869 - port->count++;
36870 + atomic_inc(&port->count);
36871 spin_unlock(&port->lock);
36872 spin_unlock_irqrestore(&info->netlock, flags);
36873
36874 - if (port->count == 1) {
36875 + if (atomic_read(&port->count) == 1) {
36876 /* 1st open on this device, init hardware */
36877 retval = startup(info, tty);
36878 if (retval < 0)
36879 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36880 unsigned short new_crctype;
36881
36882 /* return error if TTY interface open */
36883 - if (info->port.count)
36884 + if (atomic_read(&info->port.count))
36885 return -EBUSY;
36886
36887 switch (encoding)
36888 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36889
36890 /* arbitrate between network and tty opens */
36891 spin_lock_irqsave(&info->netlock, flags);
36892 - if (info->port.count != 0 || info->netcount != 0) {
36893 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36894 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36895 spin_unlock_irqrestore(&info->netlock, flags);
36896 return -EBUSY;
36897 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36898 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36899
36900 /* return error if TTY interface open */
36901 - if (info->port.count)
36902 + if (atomic_read(&info->port.count))
36903 return -EBUSY;
36904
36905 if (cmd != SIOCWANDEV)
36906 diff --git a/drivers/char/random.c b/drivers/char/random.c
36907 index 92e6c67..c640ec3 100644
36908 --- a/drivers/char/random.c
36909 +++ b/drivers/char/random.c
36910 @@ -272,8 +272,13 @@
36911 /*
36912 * Configuration information
36913 */
36914 +#ifdef CONFIG_GRKERNSEC_RANDNET
36915 +#define INPUT_POOL_WORDS 512
36916 +#define OUTPUT_POOL_WORDS 128
36917 +#else
36918 #define INPUT_POOL_WORDS 128
36919 #define OUTPUT_POOL_WORDS 32
36920 +#endif
36921 #define SEC_XFER_SIZE 512
36922 #define EXTRACT_SIZE 10
36923
36924 @@ -313,10 +318,17 @@ static struct poolinfo {
36925 int poolwords;
36926 int tap1, tap2, tap3, tap4, tap5;
36927 } poolinfo_table[] = {
36928 +#ifdef CONFIG_GRKERNSEC_RANDNET
36929 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36930 + { 512, 411, 308, 208, 104, 1 },
36931 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36932 + { 128, 103, 76, 51, 25, 1 },
36933 +#else
36934 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36935 { 128, 103, 76, 51, 25, 1 },
36936 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36937 { 32, 26, 20, 14, 7, 1 },
36938 +#endif
36939 #if 0
36940 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36941 { 2048, 1638, 1231, 819, 411, 1 },
36942 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36943 input_rotate += i ? 7 : 14;
36944 }
36945
36946 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36947 - ACCESS_ONCE(r->add_ptr) = i;
36948 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36949 + ACCESS_ONCE_RW(r->add_ptr) = i;
36950 smp_wmb();
36951
36952 if (out)
36953 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36954
36955 extract_buf(r, tmp);
36956 i = min_t(int, nbytes, EXTRACT_SIZE);
36957 - if (copy_to_user(buf, tmp, i)) {
36958 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36959 ret = -EFAULT;
36960 break;
36961 }
36962 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36963 #include <linux/sysctl.h>
36964
36965 static int min_read_thresh = 8, min_write_thresh;
36966 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36967 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36968 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36969 static char sysctl_bootid[16];
36970
36971 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36972 static int proc_do_uuid(struct ctl_table *table, int write,
36973 void __user *buffer, size_t *lenp, loff_t *ppos)
36974 {
36975 - struct ctl_table fake_table;
36976 + ctl_table_no_const fake_table;
36977 unsigned char buf[64], tmp_uuid[16], *uuid;
36978
36979 uuid = table->data;
36980 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36981 index bf2349db..5456d53 100644
36982 --- a/drivers/char/sonypi.c
36983 +++ b/drivers/char/sonypi.c
36984 @@ -54,6 +54,7 @@
36985
36986 #include <asm/uaccess.h>
36987 #include <asm/io.h>
36988 +#include <asm/local.h>
36989
36990 #include <linux/sonypi.h>
36991
36992 @@ -490,7 +491,7 @@ static struct sonypi_device {
36993 spinlock_t fifo_lock;
36994 wait_queue_head_t fifo_proc_list;
36995 struct fasync_struct *fifo_async;
36996 - int open_count;
36997 + local_t open_count;
36998 int model;
36999 struct input_dev *input_jog_dev;
37000 struct input_dev *input_key_dev;
37001 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37002 static int sonypi_misc_release(struct inode *inode, struct file *file)
37003 {
37004 mutex_lock(&sonypi_device.lock);
37005 - sonypi_device.open_count--;
37006 + local_dec(&sonypi_device.open_count);
37007 mutex_unlock(&sonypi_device.lock);
37008 return 0;
37009 }
37010 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37011 {
37012 mutex_lock(&sonypi_device.lock);
37013 /* Flush input queue on first open */
37014 - if (!sonypi_device.open_count)
37015 + if (!local_read(&sonypi_device.open_count))
37016 kfifo_reset(&sonypi_device.fifo);
37017 - sonypi_device.open_count++;
37018 + local_inc(&sonypi_device.open_count);
37019 mutex_unlock(&sonypi_device.lock);
37020
37021 return 0;
37022 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37023 index 64420b3..5c40b56 100644
37024 --- a/drivers/char/tpm/tpm_acpi.c
37025 +++ b/drivers/char/tpm/tpm_acpi.c
37026 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37027 virt = acpi_os_map_memory(start, len);
37028 if (!virt) {
37029 kfree(log->bios_event_log);
37030 + log->bios_event_log = NULL;
37031 printk("%s: ERROR - Unable to map memory\n", __func__);
37032 return -EIO;
37033 }
37034
37035 - memcpy_fromio(log->bios_event_log, virt, len);
37036 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37037
37038 acpi_os_unmap_memory(virt, len);
37039 return 0;
37040 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37041 index 84ddc55..1d32f1e 100644
37042 --- a/drivers/char/tpm/tpm_eventlog.c
37043 +++ b/drivers/char/tpm/tpm_eventlog.c
37044 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37045 event = addr;
37046
37047 if ((event->event_type == 0 && event->event_size == 0) ||
37048 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37049 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37050 return NULL;
37051
37052 return addr;
37053 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37054 return NULL;
37055
37056 if ((event->event_type == 0 && event->event_size == 0) ||
37057 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37058 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37059 return NULL;
37060
37061 (*pos)++;
37062 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37063 int i;
37064
37065 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37066 - seq_putc(m, data[i]);
37067 + if (!seq_putc(m, data[i]))
37068 + return -EFAULT;
37069
37070 return 0;
37071 }
37072 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37073 index fc45567..fa2a590 100644
37074 --- a/drivers/char/virtio_console.c
37075 +++ b/drivers/char/virtio_console.c
37076 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37077 if (to_user) {
37078 ssize_t ret;
37079
37080 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37081 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37082 if (ret)
37083 return -EFAULT;
37084 } else {
37085 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37086 if (!port_has_data(port) && !port->host_connected)
37087 return 0;
37088
37089 - return fill_readbuf(port, ubuf, count, true);
37090 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37091 }
37092
37093 static int wait_port_writable(struct port *port, bool nonblock)
37094 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37095 index a33f46f..a720eed 100644
37096 --- a/drivers/clk/clk-composite.c
37097 +++ b/drivers/clk/clk-composite.c
37098 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37099 struct clk *clk;
37100 struct clk_init_data init;
37101 struct clk_composite *composite;
37102 - struct clk_ops *clk_composite_ops;
37103 + clk_ops_no_const *clk_composite_ops;
37104
37105 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37106 if (!composite) {
37107 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37108 index 5bb848c..f1d4fc9 100644
37109 --- a/drivers/clk/socfpga/clk.c
37110 +++ b/drivers/clk/socfpga/clk.c
37111 @@ -22,6 +22,7 @@
37112 #include <linux/clk-provider.h>
37113 #include <linux/io.h>
37114 #include <linux/of.h>
37115 +#include <asm/pgtable.h>
37116
37117 /* Clock Manager offsets */
37118 #define CLKMGR_CTRL 0x0
37119 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37120 streq(clk_name, "periph_pll") ||
37121 streq(clk_name, "sdram_pll")) {
37122 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37123 - clk_pll_ops.enable = clk_gate_ops.enable;
37124 - clk_pll_ops.disable = clk_gate_ops.disable;
37125 + pax_open_kernel();
37126 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37127 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37128 + pax_close_kernel();
37129 }
37130
37131 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37132 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37133 return parent_rate / div;
37134 }
37135
37136 -static struct clk_ops gateclk_ops = {
37137 +static clk_ops_no_const gateclk_ops __read_only = {
37138 .recalc_rate = socfpga_clk_recalc_rate,
37139 .get_parent = socfpga_clk_get_parent,
37140 .set_parent = socfpga_clk_set_parent,
37141 diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
37142 index 08ae128..c73fc2b 100644
37143 --- a/drivers/connector/cn_proc.c
37144 +++ b/drivers/connector/cn_proc.c
37145 @@ -65,6 +65,7 @@ void proc_fork_connector(struct task_struct *task)
37146
37147 msg = (struct cn_msg *)buffer;
37148 ev = (struct proc_event *)msg->data;
37149 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37150 get_seq(&msg->seq, &ev->cpu);
37151 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37152 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37153 @@ -80,6 +81,7 @@ void proc_fork_connector(struct task_struct *task)
37154 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37155 msg->ack = 0; /* not used */
37156 msg->len = sizeof(*ev);
37157 + msg->flags = 0; /* not used */
37158 /* If cn_netlink_send() failed, the data is not sent */
37159 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37160 }
37161 @@ -96,6 +98,7 @@ void proc_exec_connector(struct task_struct *task)
37162
37163 msg = (struct cn_msg *)buffer;
37164 ev = (struct proc_event *)msg->data;
37165 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37166 get_seq(&msg->seq, &ev->cpu);
37167 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37168 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37169 @@ -106,6 +109,7 @@ void proc_exec_connector(struct task_struct *task)
37170 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37171 msg->ack = 0; /* not used */
37172 msg->len = sizeof(*ev);
37173 + msg->flags = 0; /* not used */
37174 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37175 }
37176
37177 @@ -122,6 +126,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
37178
37179 msg = (struct cn_msg *)buffer;
37180 ev = (struct proc_event *)msg->data;
37181 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37182 ev->what = which_id;
37183 ev->event_data.id.process_pid = task->pid;
37184 ev->event_data.id.process_tgid = task->tgid;
37185 @@ -145,6 +150,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
37186 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37187 msg->ack = 0; /* not used */
37188 msg->len = sizeof(*ev);
37189 + msg->flags = 0; /* not used */
37190 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37191 }
37192
37193 @@ -160,6 +166,7 @@ void proc_sid_connector(struct task_struct *task)
37194
37195 msg = (struct cn_msg *)buffer;
37196 ev = (struct proc_event *)msg->data;
37197 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37198 get_seq(&msg->seq, &ev->cpu);
37199 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37200 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37201 @@ -170,6 +177,7 @@ void proc_sid_connector(struct task_struct *task)
37202 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37203 msg->ack = 0; /* not used */
37204 msg->len = sizeof(*ev);
37205 + msg->flags = 0; /* not used */
37206 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37207 }
37208
37209 @@ -185,6 +193,7 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
37210
37211 msg = (struct cn_msg *)buffer;
37212 ev = (struct proc_event *)msg->data;
37213 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37214 get_seq(&msg->seq, &ev->cpu);
37215 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37216 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37217 @@ -203,6 +212,7 @@ void proc_ptrace_connector(struct task_struct *task, int ptrace_id)
37218 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37219 msg->ack = 0; /* not used */
37220 msg->len = sizeof(*ev);
37221 + msg->flags = 0; /* not used */
37222 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37223 }
37224
37225 @@ -218,6 +228,7 @@ void proc_comm_connector(struct task_struct *task)
37226
37227 msg = (struct cn_msg *)buffer;
37228 ev = (struct proc_event *)msg->data;
37229 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37230 get_seq(&msg->seq, &ev->cpu);
37231 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37232 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37233 @@ -229,6 +240,7 @@ void proc_comm_connector(struct task_struct *task)
37234 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37235 msg->ack = 0; /* not used */
37236 msg->len = sizeof(*ev);
37237 + msg->flags = 0; /* not used */
37238 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37239 }
37240
37241 @@ -244,6 +256,7 @@ void proc_coredump_connector(struct task_struct *task)
37242
37243 msg = (struct cn_msg *)buffer;
37244 ev = (struct proc_event *)msg->data;
37245 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37246 get_seq(&msg->seq, &ev->cpu);
37247 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37248 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37249 @@ -254,6 +267,7 @@ void proc_coredump_connector(struct task_struct *task)
37250 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37251 msg->ack = 0; /* not used */
37252 msg->len = sizeof(*ev);
37253 + msg->flags = 0; /* not used */
37254 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37255 }
37256
37257 @@ -269,6 +283,7 @@ void proc_exit_connector(struct task_struct *task)
37258
37259 msg = (struct cn_msg *)buffer;
37260 ev = (struct proc_event *)msg->data;
37261 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37262 get_seq(&msg->seq, &ev->cpu);
37263 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37264 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37265 @@ -281,6 +296,7 @@ void proc_exit_connector(struct task_struct *task)
37266 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37267 msg->ack = 0; /* not used */
37268 msg->len = sizeof(*ev);
37269 + msg->flags = 0; /* not used */
37270 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37271 }
37272
37273 @@ -304,6 +320,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
37274
37275 msg = (struct cn_msg *)buffer;
37276 ev = (struct proc_event *)msg->data;
37277 + memset(&ev->event_data, 0, sizeof(ev->event_data));
37278 msg->seq = rcvd_seq;
37279 ktime_get_ts(&ts); /* get high res monotonic timestamp */
37280 put_unaligned(timespec_to_ns(&ts), (__u64 *)&ev->timestamp_ns);
37281 @@ -313,6 +330,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
37282 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
37283 msg->ack = rcvd_ack + 1;
37284 msg->len = sizeof(*ev);
37285 + msg->flags = 0; /* not used */
37286 cn_netlink_send(msg, CN_IDX_PROC, GFP_KERNEL);
37287 }
37288
37289 diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
37290 index 6ecfa75..0daa11e 100644
37291 --- a/drivers/connector/connector.c
37292 +++ b/drivers/connector/connector.c
37293 @@ -157,17 +157,18 @@ static int cn_call_callback(struct sk_buff *skb)
37294 static void cn_rx_skb(struct sk_buff *__skb)
37295 {
37296 struct nlmsghdr *nlh;
37297 - int err;
37298 struct sk_buff *skb;
37299 + int len, err;
37300
37301 skb = skb_get(__skb);
37302
37303 if (skb->len >= NLMSG_HDRLEN) {
37304 nlh = nlmsg_hdr(skb);
37305 + len = nlmsg_len(nlh);
37306
37307 - if (nlh->nlmsg_len < sizeof(struct cn_msg) ||
37308 + if (len < (int)sizeof(struct cn_msg) ||
37309 skb->len < nlh->nlmsg_len ||
37310 - nlh->nlmsg_len > CONNECTOR_MAX_MSG_SIZE) {
37311 + len > CONNECTOR_MAX_MSG_SIZE) {
37312 kfree_skb(skb);
37313 return;
37314 }
37315 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37316 index 3926402..37b580d 100644
37317 --- a/drivers/cpufreq/acpi-cpufreq.c
37318 +++ b/drivers/cpufreq/acpi-cpufreq.c
37319 @@ -173,7 +173,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37320 return sprintf(buf, "%u\n", boost_enabled);
37321 }
37322
37323 -static struct global_attr global_boost = __ATTR(boost, 0644,
37324 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37325 show_global_boost,
37326 store_global_boost);
37327
37328 @@ -722,8 +722,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37329 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37330 per_cpu(acfreq_data, cpu) = data;
37331
37332 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37333 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37334 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37335 + pax_open_kernel();
37336 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37337 + pax_close_kernel();
37338 + }
37339
37340 result = acpi_processor_register_performance(data->acpi_data, cpu);
37341 if (result)
37342 @@ -851,7 +854,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37343 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37344 break;
37345 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37346 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37347 + pax_open_kernel();
37348 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37349 + pax_close_kernel();
37350 policy->cur = get_cur_freq_on_cpu(cpu);
37351 break;
37352 default:
37353 @@ -862,8 +867,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37354 acpi_processor_notify_smm(THIS_MODULE);
37355
37356 /* Check for APERF/MPERF support in hardware */
37357 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
37358 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37359 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
37360 + pax_open_kernel();
37361 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
37362 + pax_close_kernel();
37363 + }
37364
37365 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
37366 for (i = 0; i < perf->state_count; i++)
37367 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37368 index f0a5e2b..0a7ee46 100644
37369 --- a/drivers/cpufreq/cpufreq.c
37370 +++ b/drivers/cpufreq/cpufreq.c
37371 @@ -1959,7 +1959,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37372 return NOTIFY_OK;
37373 }
37374
37375 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37376 +static struct notifier_block cpufreq_cpu_notifier = {
37377 .notifier_call = cpufreq_cpu_callback,
37378 };
37379
37380 @@ -1991,8 +1991,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37381
37382 pr_debug("trying to register driver %s\n", driver_data->name);
37383
37384 - if (driver_data->setpolicy)
37385 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37386 + if (driver_data->setpolicy) {
37387 + pax_open_kernel();
37388 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37389 + pax_close_kernel();
37390 + }
37391
37392 write_lock_irqsave(&cpufreq_driver_lock, flags);
37393 if (cpufreq_driver) {
37394 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37395 index e59afaa..a53a3ff 100644
37396 --- a/drivers/cpufreq/cpufreq_governor.c
37397 +++ b/drivers/cpufreq/cpufreq_governor.c
37398 @@ -191,7 +191,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37399 struct dbs_data *dbs_data;
37400 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37401 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37402 - struct od_ops *od_ops = NULL;
37403 + const struct od_ops *od_ops = NULL;
37404 struct od_dbs_tuners *od_tuners = NULL;
37405 struct cs_dbs_tuners *cs_tuners = NULL;
37406 struct cpu_dbs_common_info *cpu_cdbs;
37407 @@ -257,7 +257,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37408
37409 if ((cdata->governor == GOV_CONSERVATIVE) &&
37410 (!policy->governor->initialized)) {
37411 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37412 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37413
37414 cpufreq_register_notifier(cs_ops->notifier_block,
37415 CPUFREQ_TRANSITION_NOTIFIER);
37416 @@ -277,7 +277,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37417
37418 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37419 (policy->governor->initialized == 1)) {
37420 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37421 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37422
37423 cpufreq_unregister_notifier(cs_ops->notifier_block,
37424 CPUFREQ_TRANSITION_NOTIFIER);
37425 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37426 index d5f12b4..eb30af1 100644
37427 --- a/drivers/cpufreq/cpufreq_governor.h
37428 +++ b/drivers/cpufreq/cpufreq_governor.h
37429 @@ -204,7 +204,7 @@ struct common_dbs_data {
37430 void (*exit)(struct dbs_data *dbs_data);
37431
37432 /* Governor specific ops, see below */
37433 - void *gov_ops;
37434 + const void *gov_ops;
37435 };
37436
37437 /* Governer Per policy data */
37438 @@ -224,7 +224,7 @@ struct od_ops {
37439 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37440 unsigned int freq_next, unsigned int relation);
37441 void (*freq_increase)(struct cpufreq_policy *p, unsigned int freq);
37442 -};
37443 +} __no_const;
37444
37445 struct cs_ops {
37446 struct notifier_block *notifier_block;
37447 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37448 index c087347..989aa2e 100644
37449 --- a/drivers/cpufreq/cpufreq_ondemand.c
37450 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37451 @@ -560,7 +560,7 @@ static void od_exit(struct dbs_data *dbs_data)
37452
37453 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37454
37455 -static struct od_ops od_ops = {
37456 +static struct od_ops od_ops __read_only = {
37457 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37458 .powersave_bias_target = generic_powersave_bias_target,
37459 .freq_increase = dbs_freq_increase,
37460 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37461 (struct cpufreq_policy *, unsigned int, unsigned int),
37462 unsigned int powersave_bias)
37463 {
37464 - od_ops.powersave_bias_target = f;
37465 + pax_open_kernel();
37466 + *(void **)&od_ops.powersave_bias_target = f;
37467 + pax_close_kernel();
37468 od_set_powersave_bias(powersave_bias);
37469 }
37470 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37471
37472 void od_unregister_powersave_bias_handler(void)
37473 {
37474 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37475 + pax_open_kernel();
37476 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37477 + pax_close_kernel();
37478 od_set_powersave_bias(0);
37479 }
37480 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37481 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37482 index d37568c..fbb19a1 100644
37483 --- a/drivers/cpufreq/cpufreq_stats.c
37484 +++ b/drivers/cpufreq/cpufreq_stats.c
37485 @@ -365,7 +365,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37486 }
37487
37488 /* priority=1 so this will get called before cpufreq_remove_dev */
37489 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37490 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37491 .notifier_call = cpufreq_stat_cpu_callback,
37492 .priority = 1,
37493 };
37494 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37495 index 9ee7817..17b658e 100644
37496 --- a/drivers/cpufreq/p4-clockmod.c
37497 +++ b/drivers/cpufreq/p4-clockmod.c
37498 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37499 case 0x0F: /* Core Duo */
37500 case 0x16: /* Celeron Core */
37501 case 0x1C: /* Atom */
37502 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37503 + pax_open_kernel();
37504 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37505 + pax_close_kernel();
37506 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37507 case 0x0D: /* Pentium M (Dothan) */
37508 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37509 + pax_open_kernel();
37510 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37511 + pax_close_kernel();
37512 /* fall through */
37513 case 0x09: /* Pentium M (Banias) */
37514 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37515 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37516
37517 /* on P-4s, the TSC runs with constant frequency independent whether
37518 * throttling is active or not. */
37519 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37520 + pax_open_kernel();
37521 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37522 + pax_close_kernel();
37523
37524 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37525 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37526 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37527 index 880ee29..2445bc6 100644
37528 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37529 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37530 @@ -18,14 +18,12 @@
37531 #include <asm/head.h>
37532 #include <asm/timer.h>
37533
37534 -static struct cpufreq_driver *cpufreq_us3_driver;
37535 -
37536 struct us3_freq_percpu_info {
37537 struct cpufreq_frequency_table table[4];
37538 };
37539
37540 /* Indexed by cpu number. */
37541 -static struct us3_freq_percpu_info *us3_freq_table;
37542 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
37543
37544 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
37545 * in the Safari config register.
37546 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
37547
37548 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
37549 {
37550 - if (cpufreq_us3_driver)
37551 - us3_set_cpu_divider_index(policy, 0);
37552 + us3_set_cpu_divider_index(policy->cpu, 0);
37553
37554 return 0;
37555 }
37556
37557 +static int __init us3_freq_init(void);
37558 +static void __exit us3_freq_exit(void);
37559 +
37560 +static struct cpufreq_driver cpufreq_us3_driver = {
37561 + .init = us3_freq_cpu_init,
37562 + .verify = us3_freq_verify,
37563 + .target = us3_freq_target,
37564 + .get = us3_freq_get,
37565 + .exit = us3_freq_cpu_exit,
37566 + .owner = THIS_MODULE,
37567 + .name = "UltraSPARC-III",
37568 +
37569 +};
37570 +
37571 static int __init us3_freq_init(void)
37572 {
37573 unsigned long manuf, impl, ver;
37574 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
37575 (impl == CHEETAH_IMPL ||
37576 impl == CHEETAH_PLUS_IMPL ||
37577 impl == JAGUAR_IMPL ||
37578 - impl == PANTHER_IMPL)) {
37579 - struct cpufreq_driver *driver;
37580 -
37581 - ret = -ENOMEM;
37582 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
37583 - if (!driver)
37584 - goto err_out;
37585 -
37586 - us3_freq_table = kzalloc(
37587 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
37588 - GFP_KERNEL);
37589 - if (!us3_freq_table)
37590 - goto err_out;
37591 -
37592 - driver->init = us3_freq_cpu_init;
37593 - driver->verify = us3_freq_verify;
37594 - driver->target = us3_freq_target;
37595 - driver->get = us3_freq_get;
37596 - driver->exit = us3_freq_cpu_exit;
37597 - driver->owner = THIS_MODULE,
37598 - strcpy(driver->name, "UltraSPARC-III");
37599 -
37600 - cpufreq_us3_driver = driver;
37601 - ret = cpufreq_register_driver(driver);
37602 - if (ret)
37603 - goto err_out;
37604 -
37605 - return 0;
37606 -
37607 -err_out:
37608 - if (driver) {
37609 - kfree(driver);
37610 - cpufreq_us3_driver = NULL;
37611 - }
37612 - kfree(us3_freq_table);
37613 - us3_freq_table = NULL;
37614 - return ret;
37615 - }
37616 + impl == PANTHER_IMPL))
37617 + return cpufreq_register_driver(&cpufreq_us3_driver);
37618
37619 return -ENODEV;
37620 }
37621
37622 static void __exit us3_freq_exit(void)
37623 {
37624 - if (cpufreq_us3_driver) {
37625 - cpufreq_unregister_driver(cpufreq_us3_driver);
37626 - kfree(cpufreq_us3_driver);
37627 - cpufreq_us3_driver = NULL;
37628 - kfree(us3_freq_table);
37629 - us3_freq_table = NULL;
37630 - }
37631 + cpufreq_unregister_driver(&cpufreq_us3_driver);
37632 }
37633
37634 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
37635 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
37636 index 0915e71..53376ed 100644
37637 --- a/drivers/cpufreq/speedstep-centrino.c
37638 +++ b/drivers/cpufreq/speedstep-centrino.c
37639 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
37640 !cpu_has(cpu, X86_FEATURE_EST))
37641 return -ENODEV;
37642
37643 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
37644 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37645 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
37646 + pax_open_kernel();
37647 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
37648 + pax_close_kernel();
37649 + }
37650
37651 if (policy->cpu != 0)
37652 return -ENODEV;
37653 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
37654 index fdc432f..98e64e2 100644
37655 --- a/drivers/cpuidle/cpuidle.c
37656 +++ b/drivers/cpuidle/cpuidle.c
37657 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
37658
37659 static void poll_idle_init(struct cpuidle_driver *drv)
37660 {
37661 - struct cpuidle_state *state = &drv->states[0];
37662 + cpuidle_state_no_const *state = &drv->states[0];
37663
37664 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
37665 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
37666 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
37667 index ea2f8e7..70ac501 100644
37668 --- a/drivers/cpuidle/governor.c
37669 +++ b/drivers/cpuidle/governor.c
37670 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
37671 mutex_lock(&cpuidle_lock);
37672 if (__cpuidle_find_governor(gov->name) == NULL) {
37673 ret = 0;
37674 - list_add_tail(&gov->governor_list, &cpuidle_governors);
37675 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
37676 if (!cpuidle_curr_governor ||
37677 cpuidle_curr_governor->rating < gov->rating)
37678 cpuidle_switch_governor(gov);
37679 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
37680 new_gov = cpuidle_replace_governor(gov->rating);
37681 cpuidle_switch_governor(new_gov);
37682 }
37683 - list_del(&gov->governor_list);
37684 + pax_list_del((struct list_head *)&gov->governor_list);
37685 mutex_unlock(&cpuidle_lock);
37686 }
37687
37688 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
37689 index 428754a..8bdf9cc 100644
37690 --- a/drivers/cpuidle/sysfs.c
37691 +++ b/drivers/cpuidle/sysfs.c
37692 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
37693 NULL
37694 };
37695
37696 -static struct attribute_group cpuidle_attr_group = {
37697 +static attribute_group_no_const cpuidle_attr_group = {
37698 .attrs = cpuidle_default_attrs,
37699 .name = "cpuidle",
37700 };
37701 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
37702 index 12fea3e..1e28f47 100644
37703 --- a/drivers/crypto/hifn_795x.c
37704 +++ b/drivers/crypto/hifn_795x.c
37705 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
37706 MODULE_PARM_DESC(hifn_pll_ref,
37707 "PLL reference clock (pci[freq] or ext[freq], default ext)");
37708
37709 -static atomic_t hifn_dev_number;
37710 +static atomic_unchecked_t hifn_dev_number;
37711
37712 #define ACRYPTO_OP_DECRYPT 0
37713 #define ACRYPTO_OP_ENCRYPT 1
37714 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
37715 goto err_out_disable_pci_device;
37716
37717 snprintf(name, sizeof(name), "hifn%d",
37718 - atomic_inc_return(&hifn_dev_number)-1);
37719 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
37720
37721 err = pci_request_regions(pdev, name);
37722 if (err)
37723 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
37724 index e94e619..f7e249c 100644
37725 --- a/drivers/devfreq/devfreq.c
37726 +++ b/drivers/devfreq/devfreq.c
37727 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
37728 goto err_out;
37729 }
37730
37731 - list_add(&governor->node, &devfreq_governor_list);
37732 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
37733
37734 list_for_each_entry(devfreq, &devfreq_list, node) {
37735 int ret = 0;
37736 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
37737 }
37738 }
37739
37740 - list_del(&governor->node);
37741 + pax_list_del((struct list_head *)&governor->node);
37742 err_out:
37743 mutex_unlock(&devfreq_list_lock);
37744
37745 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
37746 index 5039fbc..841169f 100644
37747 --- a/drivers/dma/sh/shdma.c
37748 +++ b/drivers/dma/sh/shdma.c
37749 @@ -488,7 +488,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
37750 return ret;
37751 }
37752
37753 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
37754 +static struct notifier_block sh_dmae_nmi_notifier = {
37755 .notifier_call = sh_dmae_nmi_handler,
37756
37757 /* Run before NMI debug handler and KGDB */
37758 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
37759 index 211021d..201d47f 100644
37760 --- a/drivers/edac/edac_device.c
37761 +++ b/drivers/edac/edac_device.c
37762 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
37763 */
37764 int edac_device_alloc_index(void)
37765 {
37766 - static atomic_t device_indexes = ATOMIC_INIT(0);
37767 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
37768
37769 - return atomic_inc_return(&device_indexes) - 1;
37770 + return atomic_inc_return_unchecked(&device_indexes) - 1;
37771 }
37772 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
37773
37774 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
37775 index e7c32c4..6397af1 100644
37776 --- a/drivers/edac/edac_mc_sysfs.c
37777 +++ b/drivers/edac/edac_mc_sysfs.c
37778 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
37779 struct dev_ch_attribute {
37780 struct device_attribute attr;
37781 int channel;
37782 -};
37783 +} __do_const;
37784
37785 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
37786 struct dev_ch_attribute dev_attr_legacy_##_name = \
37787 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
37788 }
37789
37790 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
37791 + pax_open_kernel();
37792 if (mci->get_sdram_scrub_rate) {
37793 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37794 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37795 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
37796 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
37797 }
37798 if (mci->set_sdram_scrub_rate) {
37799 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37800 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37801 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
37802 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
37803 }
37804 + pax_close_kernel();
37805 err = device_create_file(&mci->dev,
37806 &dev_attr_sdram_scrub_rate);
37807 if (err) {
37808 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
37809 index dd370f9..0281629 100644
37810 --- a/drivers/edac/edac_pci.c
37811 +++ b/drivers/edac/edac_pci.c
37812 @@ -29,7 +29,7 @@
37813
37814 static DEFINE_MUTEX(edac_pci_ctls_mutex);
37815 static LIST_HEAD(edac_pci_list);
37816 -static atomic_t pci_indexes = ATOMIC_INIT(0);
37817 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
37818
37819 /*
37820 * edac_pci_alloc_ctl_info
37821 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
37822 */
37823 int edac_pci_alloc_index(void)
37824 {
37825 - return atomic_inc_return(&pci_indexes) - 1;
37826 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
37827 }
37828 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
37829
37830 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
37831 index e8658e4..22746d6 100644
37832 --- a/drivers/edac/edac_pci_sysfs.c
37833 +++ b/drivers/edac/edac_pci_sysfs.c
37834 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
37835 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
37836 static int edac_pci_poll_msec = 1000; /* one second workq period */
37837
37838 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
37839 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
37840 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
37841 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
37842
37843 static struct kobject *edac_pci_top_main_kobj;
37844 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
37845 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
37846 void *value;
37847 ssize_t(*show) (void *, char *);
37848 ssize_t(*store) (void *, const char *, size_t);
37849 -};
37850 +} __do_const;
37851
37852 /* Set of show/store abstract level functions for PCI Parity object */
37853 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
37854 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37855 edac_printk(KERN_CRIT, EDAC_PCI,
37856 "Signaled System Error on %s\n",
37857 pci_name(dev));
37858 - atomic_inc(&pci_nonparity_count);
37859 + atomic_inc_unchecked(&pci_nonparity_count);
37860 }
37861
37862 if (status & (PCI_STATUS_PARITY)) {
37863 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37864 "Master Data Parity Error on %s\n",
37865 pci_name(dev));
37866
37867 - atomic_inc(&pci_parity_count);
37868 + atomic_inc_unchecked(&pci_parity_count);
37869 }
37870
37871 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37872 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37873 "Detected Parity Error on %s\n",
37874 pci_name(dev));
37875
37876 - atomic_inc(&pci_parity_count);
37877 + atomic_inc_unchecked(&pci_parity_count);
37878 }
37879 }
37880
37881 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37882 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
37883 "Signaled System Error on %s\n",
37884 pci_name(dev));
37885 - atomic_inc(&pci_nonparity_count);
37886 + atomic_inc_unchecked(&pci_nonparity_count);
37887 }
37888
37889 if (status & (PCI_STATUS_PARITY)) {
37890 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37891 "Master Data Parity Error on "
37892 "%s\n", pci_name(dev));
37893
37894 - atomic_inc(&pci_parity_count);
37895 + atomic_inc_unchecked(&pci_parity_count);
37896 }
37897
37898 if (status & (PCI_STATUS_DETECTED_PARITY)) {
37899 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
37900 "Detected Parity Error on %s\n",
37901 pci_name(dev));
37902
37903 - atomic_inc(&pci_parity_count);
37904 + atomic_inc_unchecked(&pci_parity_count);
37905 }
37906 }
37907 }
37908 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
37909 if (!check_pci_errors)
37910 return;
37911
37912 - before_count = atomic_read(&pci_parity_count);
37913 + before_count = atomic_read_unchecked(&pci_parity_count);
37914
37915 /* scan all PCI devices looking for a Parity Error on devices and
37916 * bridges.
37917 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
37918 /* Only if operator has selected panic on PCI Error */
37919 if (edac_pci_get_panic_on_pe()) {
37920 /* If the count is different 'after' from 'before' */
37921 - if (before_count != atomic_read(&pci_parity_count))
37922 + if (before_count != atomic_read_unchecked(&pci_parity_count))
37923 panic("EDAC: PCI Parity Error");
37924 }
37925 }
37926 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
37927 index 51b7e3a..aa8a3e8 100644
37928 --- a/drivers/edac/mce_amd.h
37929 +++ b/drivers/edac/mce_amd.h
37930 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
37931 bool (*mc0_mce)(u16, u8);
37932 bool (*mc1_mce)(u16, u8);
37933 bool (*mc2_mce)(u16, u8);
37934 -};
37935 +} __no_const;
37936
37937 void amd_report_gart_errors(bool);
37938 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
37939 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
37940 index 57ea7f4..af06b76 100644
37941 --- a/drivers/firewire/core-card.c
37942 +++ b/drivers/firewire/core-card.c
37943 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
37944 const struct fw_card_driver *driver,
37945 struct device *device)
37946 {
37947 - static atomic_t index = ATOMIC_INIT(-1);
37948 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
37949
37950 - card->index = atomic_inc_return(&index);
37951 + card->index = atomic_inc_return_unchecked(&index);
37952 card->driver = driver;
37953 card->device = device;
37954 card->current_tlabel = 0;
37955 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
37956
37957 void fw_core_remove_card(struct fw_card *card)
37958 {
37959 - struct fw_card_driver dummy_driver = dummy_driver_template;
37960 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
37961
37962 card->driver->update_phy_reg(card, 4,
37963 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
37964 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
37965 index de4aa40..49ab1f2 100644
37966 --- a/drivers/firewire/core-device.c
37967 +++ b/drivers/firewire/core-device.c
37968 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
37969 struct config_rom_attribute {
37970 struct device_attribute attr;
37971 u32 key;
37972 -};
37973 +} __do_const;
37974
37975 static ssize_t show_immediate(struct device *dev,
37976 struct device_attribute *dattr, char *buf)
37977 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
37978 index 28a94c7..58da63a 100644
37979 --- a/drivers/firewire/core-transaction.c
37980 +++ b/drivers/firewire/core-transaction.c
37981 @@ -38,6 +38,7 @@
37982 #include <linux/timer.h>
37983 #include <linux/types.h>
37984 #include <linux/workqueue.h>
37985 +#include <linux/sched.h>
37986
37987 #include <asm/byteorder.h>
37988
37989 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
37990 index 515a42c..5ecf3ba 100644
37991 --- a/drivers/firewire/core.h
37992 +++ b/drivers/firewire/core.h
37993 @@ -111,6 +111,7 @@ struct fw_card_driver {
37994
37995 int (*stop_iso)(struct fw_iso_context *ctx);
37996 };
37997 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
37998
37999 void fw_card_initialize(struct fw_card *card,
38000 const struct fw_card_driver *driver, struct device *device);
38001 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
38002 index 94a58a0..f5eba42 100644
38003 --- a/drivers/firmware/dmi-id.c
38004 +++ b/drivers/firmware/dmi-id.c
38005 @@ -16,7 +16,7 @@
38006 struct dmi_device_attribute{
38007 struct device_attribute dev_attr;
38008 int field;
38009 -};
38010 +} __do_const;
38011 #define to_dmi_dev_attr(_dev_attr) \
38012 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
38013
38014 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
38015 index 232fa8f..386c255 100644
38016 --- a/drivers/firmware/dmi_scan.c
38017 +++ b/drivers/firmware/dmi_scan.c
38018 @@ -504,11 +504,6 @@ void __init dmi_scan_machine(void)
38019 }
38020 }
38021 else {
38022 - /*
38023 - * no iounmap() for that ioremap(); it would be a no-op, but
38024 - * it's so early in setup that sucker gets confused into doing
38025 - * what it shouldn't if we actually call it.
38026 - */
38027 p = dmi_ioremap(0xF0000, 0x10000);
38028 if (p == NULL)
38029 goto error;
38030 @@ -806,7 +801,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
38031 if (buf == NULL)
38032 return -1;
38033
38034 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
38035 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
38036
38037 iounmap(buf);
38038 return 0;
38039 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
38040 index 5145fa3..0d3babd 100644
38041 --- a/drivers/firmware/efi/efi.c
38042 +++ b/drivers/firmware/efi/efi.c
38043 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
38044 };
38045
38046 static struct efivars generic_efivars;
38047 -static struct efivar_operations generic_ops;
38048 +static efivar_operations_no_const generic_ops __read_only;
38049
38050 static int generic_ops_register(void)
38051 {
38052 - generic_ops.get_variable = efi.get_variable;
38053 - generic_ops.set_variable = efi.set_variable;
38054 - generic_ops.get_next_variable = efi.get_next_variable;
38055 - generic_ops.query_variable_store = efi_query_variable_store;
38056 + pax_open_kernel();
38057 + *(void **)&generic_ops.get_variable = efi.get_variable;
38058 + *(void **)&generic_ops.set_variable = efi.set_variable;
38059 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
38060 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
38061 + pax_close_kernel();
38062
38063 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
38064 }
38065 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
38066 index 8a7432a..28fb839 100644
38067 --- a/drivers/firmware/efi/efivars.c
38068 +++ b/drivers/firmware/efi/efivars.c
38069 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
38070 static int
38071 create_efivars_bin_attributes(void)
38072 {
38073 - struct bin_attribute *attr;
38074 + bin_attribute_no_const *attr;
38075 int error;
38076
38077 /* new_var */
38078 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
38079 index 2a90ba6..07f3733 100644
38080 --- a/drivers/firmware/google/memconsole.c
38081 +++ b/drivers/firmware/google/memconsole.c
38082 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
38083 if (!found_memconsole())
38084 return -ENODEV;
38085
38086 - memconsole_bin_attr.size = memconsole_length;
38087 + pax_open_kernel();
38088 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
38089 + pax_close_kernel();
38090
38091 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
38092
38093 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
38094 index 2729e3d..f9deca1 100644
38095 --- a/drivers/gpio/gpio-ich.c
38096 +++ b/drivers/gpio/gpio-ich.c
38097 @@ -71,7 +71,7 @@ struct ichx_desc {
38098 /* Some chipsets have quirks, let these use their own request/get */
38099 int (*request)(struct gpio_chip *chip, unsigned offset);
38100 int (*get)(struct gpio_chip *chip, unsigned offset);
38101 -};
38102 +} __do_const;
38103
38104 static struct {
38105 spinlock_t lock;
38106 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
38107 index 9902732..64b62dd 100644
38108 --- a/drivers/gpio/gpio-vr41xx.c
38109 +++ b/drivers/gpio/gpio-vr41xx.c
38110 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
38111 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
38112 maskl, pendl, maskh, pendh);
38113
38114 - atomic_inc(&irq_err_count);
38115 + atomic_inc_unchecked(&irq_err_count);
38116
38117 return -EINVAL;
38118 }
38119 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
38120 index 6a64749..0767a9f 100644
38121 --- a/drivers/gpu/drm/drm_crtc_helper.c
38122 +++ b/drivers/gpu/drm/drm_crtc_helper.c
38123 @@ -322,7 +322,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
38124 struct drm_crtc *tmp;
38125 int crtc_mask = 1;
38126
38127 - WARN(!crtc, "checking null crtc?\n");
38128 + BUG_ON(!crtc);
38129
38130 dev = crtc->dev;
38131
38132 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
38133 index 99fcd7c..13cf6c5 100644
38134 --- a/drivers/gpu/drm/drm_drv.c
38135 +++ b/drivers/gpu/drm/drm_drv.c
38136 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
38137 /**
38138 * Copy and IOCTL return string to user space
38139 */
38140 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
38141 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
38142 {
38143 int len;
38144
38145 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
38146 struct drm_file *file_priv = filp->private_data;
38147 struct drm_device *dev;
38148 const struct drm_ioctl_desc *ioctl = NULL;
38149 - drm_ioctl_t *func;
38150 + drm_ioctl_no_const_t func;
38151 unsigned int nr = DRM_IOCTL_NR(cmd);
38152 int retcode = -EINVAL;
38153 char stack_kdata[128];
38154 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
38155 return -ENODEV;
38156
38157 atomic_inc(&dev->ioctl_count);
38158 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
38159 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
38160 ++file_priv->ioctl_count;
38161
38162 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
38163 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
38164 index 3a24385..4e426e0 100644
38165 --- a/drivers/gpu/drm/drm_fops.c
38166 +++ b/drivers/gpu/drm/drm_fops.c
38167 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
38168 }
38169
38170 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38171 - atomic_set(&dev->counts[i], 0);
38172 + atomic_set_unchecked(&dev->counts[i], 0);
38173
38174 dev->sigdata.lock = NULL;
38175
38176 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
38177 if (drm_device_is_unplugged(dev))
38178 return -ENODEV;
38179
38180 - if (!dev->open_count++)
38181 + if (local_inc_return(&dev->open_count) == 1)
38182 need_setup = 1;
38183 mutex_lock(&dev->struct_mutex);
38184 old_imapping = inode->i_mapping;
38185 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
38186 retcode = drm_open_helper(inode, filp, dev);
38187 if (retcode)
38188 goto err_undo;
38189 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38190 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38191 if (need_setup) {
38192 retcode = drm_setup(dev);
38193 if (retcode)
38194 @@ -166,7 +166,7 @@ err_undo:
38195 iput(container_of(dev->dev_mapping, struct inode, i_data));
38196 dev->dev_mapping = old_mapping;
38197 mutex_unlock(&dev->struct_mutex);
38198 - dev->open_count--;
38199 + local_dec(&dev->open_count);
38200 return retcode;
38201 }
38202 EXPORT_SYMBOL(drm_open);
38203 @@ -456,7 +456,7 @@ int drm_release(struct inode *inode, struct file *filp)
38204
38205 mutex_lock(&drm_global_mutex);
38206
38207 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38208 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38209
38210 if (dev->driver->preclose)
38211 dev->driver->preclose(dev, file_priv);
38212 @@ -465,10 +465,10 @@ int drm_release(struct inode *inode, struct file *filp)
38213 * Begin inline drm_release
38214 */
38215
38216 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38217 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38218 task_pid_nr(current),
38219 (long)old_encode_dev(file_priv->minor->device),
38220 - dev->open_count);
38221 + local_read(&dev->open_count));
38222
38223 /* Release any auth tokens that might point to this file_priv,
38224 (do that under the drm_global_mutex) */
38225 @@ -565,8 +565,8 @@ int drm_release(struct inode *inode, struct file *filp)
38226 * End inline drm_release
38227 */
38228
38229 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38230 - if (!--dev->open_count) {
38231 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38232 + if (local_dec_and_test(&dev->open_count)) {
38233 if (atomic_read(&dev->ioctl_count)) {
38234 DRM_ERROR("Device busy: %d\n",
38235 atomic_read(&dev->ioctl_count));
38236 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38237 index f731116..629842c 100644
38238 --- a/drivers/gpu/drm/drm_global.c
38239 +++ b/drivers/gpu/drm/drm_global.c
38240 @@ -36,7 +36,7 @@
38241 struct drm_global_item {
38242 struct mutex mutex;
38243 void *object;
38244 - int refcount;
38245 + atomic_t refcount;
38246 };
38247
38248 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38249 @@ -49,7 +49,7 @@ void drm_global_init(void)
38250 struct drm_global_item *item = &glob[i];
38251 mutex_init(&item->mutex);
38252 item->object = NULL;
38253 - item->refcount = 0;
38254 + atomic_set(&item->refcount, 0);
38255 }
38256 }
38257
38258 @@ -59,7 +59,7 @@ void drm_global_release(void)
38259 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38260 struct drm_global_item *item = &glob[i];
38261 BUG_ON(item->object != NULL);
38262 - BUG_ON(item->refcount != 0);
38263 + BUG_ON(atomic_read(&item->refcount) != 0);
38264 }
38265 }
38266
38267 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38268 void *object;
38269
38270 mutex_lock(&item->mutex);
38271 - if (item->refcount == 0) {
38272 + if (atomic_read(&item->refcount) == 0) {
38273 item->object = kzalloc(ref->size, GFP_KERNEL);
38274 if (unlikely(item->object == NULL)) {
38275 ret = -ENOMEM;
38276 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38277 goto out_err;
38278
38279 }
38280 - ++item->refcount;
38281 + atomic_inc(&item->refcount);
38282 ref->object = item->object;
38283 object = item->object;
38284 mutex_unlock(&item->mutex);
38285 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38286 struct drm_global_item *item = &glob[ref->global_type];
38287
38288 mutex_lock(&item->mutex);
38289 - BUG_ON(item->refcount == 0);
38290 + BUG_ON(atomic_read(&item->refcount) == 0);
38291 BUG_ON(ref->object != item->object);
38292 - if (--item->refcount == 0) {
38293 + if (atomic_dec_and_test(&item->refcount)) {
38294 ref->release(ref);
38295 item->object = NULL;
38296 }
38297 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38298 index d4b20ce..77a8d41 100644
38299 --- a/drivers/gpu/drm/drm_info.c
38300 +++ b/drivers/gpu/drm/drm_info.c
38301 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38302 struct drm_local_map *map;
38303 struct drm_map_list *r_list;
38304
38305 - /* Hardcoded from _DRM_FRAME_BUFFER,
38306 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38307 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38308 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38309 + static const char * const types[] = {
38310 + [_DRM_FRAME_BUFFER] = "FB",
38311 + [_DRM_REGISTERS] = "REG",
38312 + [_DRM_SHM] = "SHM",
38313 + [_DRM_AGP] = "AGP",
38314 + [_DRM_SCATTER_GATHER] = "SG",
38315 + [_DRM_CONSISTENT] = "PCI",
38316 + [_DRM_GEM] = "GEM" };
38317 const char *type;
38318 int i;
38319
38320 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38321 map = r_list->map;
38322 if (!map)
38323 continue;
38324 - if (map->type < 0 || map->type > 5)
38325 + if (map->type >= ARRAY_SIZE(types))
38326 type = "??";
38327 else
38328 type = types[map->type];
38329 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38330 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38331 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38332 vma->vm_flags & VM_IO ? 'i' : '-',
38333 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38334 + 0);
38335 +#else
38336 vma->vm_pgoff);
38337 +#endif
38338
38339 #if defined(__i386__)
38340 pgprot = pgprot_val(vma->vm_page_prot);
38341 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38342 index 2f4c434..dd12cd2 100644
38343 --- a/drivers/gpu/drm/drm_ioc32.c
38344 +++ b/drivers/gpu/drm/drm_ioc32.c
38345 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38346 request = compat_alloc_user_space(nbytes);
38347 if (!access_ok(VERIFY_WRITE, request, nbytes))
38348 return -EFAULT;
38349 - list = (struct drm_buf_desc *) (request + 1);
38350 + list = (struct drm_buf_desc __user *) (request + 1);
38351
38352 if (__put_user(count, &request->count)
38353 || __put_user(list, &request->list))
38354 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38355 request = compat_alloc_user_space(nbytes);
38356 if (!access_ok(VERIFY_WRITE, request, nbytes))
38357 return -EFAULT;
38358 - list = (struct drm_buf_pub *) (request + 1);
38359 + list = (struct drm_buf_pub __user *) (request + 1);
38360
38361 if (__put_user(count, &request->count)
38362 || __put_user(list, &request->list))
38363 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38364 return 0;
38365 }
38366
38367 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38368 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38369 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38370 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38371 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38372 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38373 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38374 {
38375 unsigned int nr = DRM_IOCTL_NR(cmd);
38376 - drm_ioctl_compat_t *fn;
38377 int ret;
38378
38379 /* Assume that ioctls without an explicit compat routine will just
38380 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38381 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38382 return drm_ioctl(filp, cmd, arg);
38383
38384 - fn = drm_compat_ioctls[nr];
38385 -
38386 - if (fn != NULL)
38387 - ret = (*fn) (filp, cmd, arg);
38388 + if (drm_compat_ioctls[nr] != NULL)
38389 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38390 else
38391 ret = drm_ioctl(filp, cmd, arg);
38392
38393 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
38394 index ffd7a7b..a64643e 100644
38395 --- a/drivers/gpu/drm/drm_ioctl.c
38396 +++ b/drivers/gpu/drm/drm_ioctl.c
38397 @@ -265,7 +265,7 @@ int drm_getstats(struct drm_device *dev, void *data,
38398 stats->data[i].value =
38399 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
38400 else
38401 - stats->data[i].value = atomic_read(&dev->counts[i]);
38402 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
38403 stats->data[i].type = dev->types[i];
38404 }
38405
38406 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38407 index d752c96..fe08455 100644
38408 --- a/drivers/gpu/drm/drm_lock.c
38409 +++ b/drivers/gpu/drm/drm_lock.c
38410 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38411 if (drm_lock_take(&master->lock, lock->context)) {
38412 master->lock.file_priv = file_priv;
38413 master->lock.lock_time = jiffies;
38414 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38415 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38416 break; /* Got lock */
38417 }
38418
38419 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38420 return -EINVAL;
38421 }
38422
38423 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38424 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38425
38426 if (drm_lock_free(&master->lock, lock->context)) {
38427 /* FIXME: Should really bail out here. */
38428 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38429 index 327ca19..684d3c0 100644
38430 --- a/drivers/gpu/drm/drm_stub.c
38431 +++ b/drivers/gpu/drm/drm_stub.c
38432 @@ -495,7 +495,7 @@ void drm_unplug_dev(struct drm_device *dev)
38433
38434 drm_device_set_unplugged(dev);
38435
38436 - if (dev->open_count == 0) {
38437 + if (local_read(&dev->open_count) == 0) {
38438 drm_put_dev(dev);
38439 }
38440 mutex_unlock(&drm_global_mutex);
38441 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38442 index 2290b3b..22056a1 100644
38443 --- a/drivers/gpu/drm/drm_sysfs.c
38444 +++ b/drivers/gpu/drm/drm_sysfs.c
38445 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38446 int drm_sysfs_device_add(struct drm_minor *minor)
38447 {
38448 int err;
38449 - char *minor_str;
38450 + const char *minor_str;
38451
38452 minor->kdev.parent = minor->dev->dev;
38453
38454 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38455 index ada49ed..29275a0 100644
38456 --- a/drivers/gpu/drm/i810/i810_dma.c
38457 +++ b/drivers/gpu/drm/i810/i810_dma.c
38458 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38459 dma->buflist[vertex->idx],
38460 vertex->discard, vertex->used);
38461
38462 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38463 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38464 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38465 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38466 sarea_priv->last_enqueue = dev_priv->counter - 1;
38467 sarea_priv->last_dispatch = (int)hw_status[5];
38468
38469 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38470 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38471 mc->last_render);
38472
38473 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38474 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38475 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38476 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38477 sarea_priv->last_enqueue = dev_priv->counter - 1;
38478 sarea_priv->last_dispatch = (int)hw_status[5];
38479
38480 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38481 index 6e0acad..93c8289 100644
38482 --- a/drivers/gpu/drm/i810/i810_drv.h
38483 +++ b/drivers/gpu/drm/i810/i810_drv.h
38484 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38485 int page_flipping;
38486
38487 wait_queue_head_t irq_queue;
38488 - atomic_t irq_received;
38489 - atomic_t irq_emitted;
38490 + atomic_unchecked_t irq_received;
38491 + atomic_unchecked_t irq_emitted;
38492
38493 int front_offset;
38494 } drm_i810_private_t;
38495 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38496 index 47d6c74..279123f 100644
38497 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38498 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38499 @@ -541,7 +541,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38500 I915_READ(GTIMR));
38501 }
38502 seq_printf(m, "Interrupts received: %d\n",
38503 - atomic_read(&dev_priv->irq_received));
38504 + atomic_read_unchecked(&dev_priv->irq_received));
38505 for_each_ring(ring, dev_priv, i) {
38506 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38507 seq_printf(m,
38508 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38509 index f466980..8f2883f 100644
38510 --- a/drivers/gpu/drm/i915/i915_dma.c
38511 +++ b/drivers/gpu/drm/i915/i915_dma.c
38512 @@ -1260,7 +1260,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38513 bool can_switch;
38514
38515 spin_lock(&dev->count_lock);
38516 - can_switch = (dev->open_count == 0);
38517 + can_switch = (local_read(&dev->open_count) == 0);
38518 spin_unlock(&dev->count_lock);
38519 return can_switch;
38520 }
38521 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38522 index 2f09e80..077876d 100644
38523 --- a/drivers/gpu/drm/i915/i915_drv.h
38524 +++ b/drivers/gpu/drm/i915/i915_drv.h
38525 @@ -1028,7 +1028,7 @@ typedef struct drm_i915_private {
38526 drm_dma_handle_t *status_page_dmah;
38527 struct resource mch_res;
38528
38529 - atomic_t irq_received;
38530 + atomic_unchecked_t irq_received;
38531
38532 /* protects the irq masks */
38533 spinlock_t irq_lock;
38534 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38535 index 87a3227..cd13d8f 100644
38536 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38537 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38538 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38539
38540 static int
38541 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38542 - int count)
38543 + unsigned int count)
38544 {
38545 - int i;
38546 + unsigned int i;
38547 int relocs_total = 0;
38548 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38549
38550 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38551 index 3c59584..500f2e9 100644
38552 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38553 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38554 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38555 (unsigned long)request);
38556 }
38557
38558 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38559 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38560 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38561 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38562 [DRM_I915_GETPARAM] = compat_i915_getparam,
38563 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38564 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38565 {
38566 unsigned int nr = DRM_IOCTL_NR(cmd);
38567 - drm_ioctl_compat_t *fn = NULL;
38568 int ret;
38569
38570 if (nr < DRM_COMMAND_BASE)
38571 return drm_compat_ioctl(filp, cmd, arg);
38572
38573 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
38574 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38575 -
38576 - if (fn != NULL)
38577 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
38578 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
38579 ret = (*fn) (filp, cmd, arg);
38580 - else
38581 + } else
38582 ret = drm_ioctl(filp, cmd, arg);
38583
38584 return ret;
38585 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
38586 index 46d46ba..6e49848 100644
38587 --- a/drivers/gpu/drm/i915/i915_irq.c
38588 +++ b/drivers/gpu/drm/i915/i915_irq.c
38589 @@ -975,7 +975,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
38590 int pipe;
38591 u32 pipe_stats[I915_MAX_PIPES];
38592
38593 - atomic_inc(&dev_priv->irq_received);
38594 + atomic_inc_unchecked(&dev_priv->irq_received);
38595
38596 while (true) {
38597 iir = I915_READ(VLV_IIR);
38598 @@ -1192,7 +1192,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
38599 irqreturn_t ret = IRQ_NONE;
38600 int i;
38601
38602 - atomic_inc(&dev_priv->irq_received);
38603 + atomic_inc_unchecked(&dev_priv->irq_received);
38604
38605 /* We get interrupts on unclaimed registers, so check for this before we
38606 * do any I915_{READ,WRITE}. */
38607 @@ -1312,7 +1312,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
38608 int ret = IRQ_NONE;
38609 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
38610
38611 - atomic_inc(&dev_priv->irq_received);
38612 + atomic_inc_unchecked(&dev_priv->irq_received);
38613
38614 /* disable master interrupt before clearing iir */
38615 de_ier = I915_READ(DEIER);
38616 @@ -2617,7 +2617,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
38617 {
38618 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38619
38620 - atomic_set(&dev_priv->irq_received, 0);
38621 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38622
38623 I915_WRITE(HWSTAM, 0xeffe);
38624
38625 @@ -2639,7 +2639,7 @@ static void ivybridge_irq_preinstall(struct drm_device *dev)
38626 {
38627 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38628
38629 - atomic_set(&dev_priv->irq_received, 0);
38630 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38631
38632 I915_WRITE(HWSTAM, 0xeffe);
38633
38634 @@ -2667,7 +2667,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
38635 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38636 int pipe;
38637
38638 - atomic_set(&dev_priv->irq_received, 0);
38639 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38640
38641 /* VLV magic */
38642 I915_WRITE(VLV_IMR, 0);
38643 @@ -2979,7 +2979,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
38644 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38645 int pipe;
38646
38647 - atomic_set(&dev_priv->irq_received, 0);
38648 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38649
38650 for_each_pipe(pipe)
38651 I915_WRITE(PIPESTAT(pipe), 0);
38652 @@ -3058,7 +3058,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
38653 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38654 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38655
38656 - atomic_inc(&dev_priv->irq_received);
38657 + atomic_inc_unchecked(&dev_priv->irq_received);
38658
38659 iir = I915_READ16(IIR);
38660 if (iir == 0)
38661 @@ -3133,7 +3133,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
38662 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38663 int pipe;
38664
38665 - atomic_set(&dev_priv->irq_received, 0);
38666 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38667
38668 if (I915_HAS_HOTPLUG(dev)) {
38669 I915_WRITE(PORT_HOTPLUG_EN, 0);
38670 @@ -3232,7 +3232,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
38671 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38672 int pipe, ret = IRQ_NONE;
38673
38674 - atomic_inc(&dev_priv->irq_received);
38675 + atomic_inc_unchecked(&dev_priv->irq_received);
38676
38677 iir = I915_READ(IIR);
38678 do {
38679 @@ -3356,7 +3356,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
38680 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
38681 int pipe;
38682
38683 - atomic_set(&dev_priv->irq_received, 0);
38684 + atomic_set_unchecked(&dev_priv->irq_received, 0);
38685
38686 I915_WRITE(PORT_HOTPLUG_EN, 0);
38687 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
38688 @@ -3465,7 +3465,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
38689 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
38690 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
38691
38692 - atomic_inc(&dev_priv->irq_received);
38693 + atomic_inc_unchecked(&dev_priv->irq_received);
38694
38695 iir = I915_READ(IIR);
38696
38697 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
38698 index 90a7c17..ecedc6a 100644
38699 --- a/drivers/gpu/drm/i915/intel_display.c
38700 +++ b/drivers/gpu/drm/i915/intel_display.c
38701 @@ -9424,13 +9424,13 @@ struct intel_quirk {
38702 int subsystem_vendor;
38703 int subsystem_device;
38704 void (*hook)(struct drm_device *dev);
38705 -};
38706 +} __do_const;
38707
38708 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
38709 struct intel_dmi_quirk {
38710 void (*hook)(struct drm_device *dev);
38711 const struct dmi_system_id (*dmi_id_list)[];
38712 -};
38713 +} __do_const;
38714
38715 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38716 {
38717 @@ -9438,18 +9438,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
38718 return 1;
38719 }
38720
38721 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38722 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
38723 {
38724 - .dmi_id_list = &(const struct dmi_system_id[]) {
38725 - {
38726 - .callback = intel_dmi_reverse_brightness,
38727 - .ident = "NCR Corporation",
38728 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38729 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
38730 - },
38731 - },
38732 - { } /* terminating entry */
38733 + .callback = intel_dmi_reverse_brightness,
38734 + .ident = "NCR Corporation",
38735 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
38736 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
38737 },
38738 + },
38739 + { } /* terminating entry */
38740 +};
38741 +
38742 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
38743 + {
38744 + .dmi_id_list = &intel_dmi_quirks_table,
38745 .hook = quirk_invert_brightness,
38746 },
38747 };
38748 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
38749 index 54558a0..2d97005 100644
38750 --- a/drivers/gpu/drm/mga/mga_drv.h
38751 +++ b/drivers/gpu/drm/mga/mga_drv.h
38752 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
38753 u32 clear_cmd;
38754 u32 maccess;
38755
38756 - atomic_t vbl_received; /**< Number of vblanks received. */
38757 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
38758 wait_queue_head_t fence_queue;
38759 - atomic_t last_fence_retired;
38760 + atomic_unchecked_t last_fence_retired;
38761 u32 next_fence_to_post;
38762
38763 unsigned int fb_cpp;
38764 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
38765 index 709e90d..89a1c0d 100644
38766 --- a/drivers/gpu/drm/mga/mga_ioc32.c
38767 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
38768 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
38769 return 0;
38770 }
38771
38772 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
38773 +drm_ioctl_compat_t mga_compat_ioctls[] = {
38774 [DRM_MGA_INIT] = compat_mga_init,
38775 [DRM_MGA_GETPARAM] = compat_mga_getparam,
38776 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
38777 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
38778 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38779 {
38780 unsigned int nr = DRM_IOCTL_NR(cmd);
38781 - drm_ioctl_compat_t *fn = NULL;
38782 int ret;
38783
38784 if (nr < DRM_COMMAND_BASE)
38785 return drm_compat_ioctl(filp, cmd, arg);
38786
38787 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
38788 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38789 -
38790 - if (fn != NULL)
38791 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
38792 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
38793 ret = (*fn) (filp, cmd, arg);
38794 - else
38795 + } else
38796 ret = drm_ioctl(filp, cmd, arg);
38797
38798 return ret;
38799 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
38800 index 598c281..60d590e 100644
38801 --- a/drivers/gpu/drm/mga/mga_irq.c
38802 +++ b/drivers/gpu/drm/mga/mga_irq.c
38803 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
38804 if (crtc != 0)
38805 return 0;
38806
38807 - return atomic_read(&dev_priv->vbl_received);
38808 + return atomic_read_unchecked(&dev_priv->vbl_received);
38809 }
38810
38811
38812 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38813 /* VBLANK interrupt */
38814 if (status & MGA_VLINEPEN) {
38815 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
38816 - atomic_inc(&dev_priv->vbl_received);
38817 + atomic_inc_unchecked(&dev_priv->vbl_received);
38818 drm_handle_vblank(dev, 0);
38819 handled = 1;
38820 }
38821 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
38822 if ((prim_start & ~0x03) != (prim_end & ~0x03))
38823 MGA_WRITE(MGA_PRIMEND, prim_end);
38824
38825 - atomic_inc(&dev_priv->last_fence_retired);
38826 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
38827 DRM_WAKEUP(&dev_priv->fence_queue);
38828 handled = 1;
38829 }
38830 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
38831 * using fences.
38832 */
38833 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
38834 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
38835 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
38836 - *sequence) <= (1 << 23)));
38837
38838 *sequence = cur_fence;
38839 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
38840 index 3e72876..d1c15ad 100644
38841 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
38842 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
38843 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
38844 struct bit_table {
38845 const char id;
38846 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
38847 -};
38848 +} __no_const;
38849
38850 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
38851
38852 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
38853 index 41ff7e0..fa854ef 100644
38854 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
38855 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
38856 @@ -92,7 +92,6 @@ struct nouveau_drm {
38857 struct drm_global_reference mem_global_ref;
38858 struct ttm_bo_global_ref bo_global_ref;
38859 struct ttm_bo_device bdev;
38860 - atomic_t validate_sequence;
38861 int (*move)(struct nouveau_channel *,
38862 struct ttm_buffer_object *,
38863 struct ttm_mem_reg *, struct ttm_mem_reg *);
38864 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38865 index 08214bc..9208577 100644
38866 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38867 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
38868 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
38869 unsigned long arg)
38870 {
38871 unsigned int nr = DRM_IOCTL_NR(cmd);
38872 - drm_ioctl_compat_t *fn = NULL;
38873 + drm_ioctl_compat_t fn = NULL;
38874 int ret;
38875
38876 if (nr < DRM_COMMAND_BASE)
38877 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
38878 index 25d3495..d81aaf6 100644
38879 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
38880 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
38881 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
38882 bool can_switch;
38883
38884 spin_lock(&dev->count_lock);
38885 - can_switch = (dev->open_count == 0);
38886 + can_switch = (local_read(&dev->open_count) == 0);
38887 spin_unlock(&dev->count_lock);
38888 return can_switch;
38889 }
38890 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
38891 index 1dfd84c..104896c 100644
38892 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
38893 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
38894 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
38895 }
38896 }
38897
38898 -static struct vm_operations_struct qxl_ttm_vm_ops;
38899 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
38900 static const struct vm_operations_struct *ttm_vm_ops;
38901
38902 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38903 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
38904 return r;
38905 if (unlikely(ttm_vm_ops == NULL)) {
38906 ttm_vm_ops = vma->vm_ops;
38907 + pax_open_kernel();
38908 qxl_ttm_vm_ops = *ttm_vm_ops;
38909 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
38910 + pax_close_kernel();
38911 }
38912 vma->vm_ops = &qxl_ttm_vm_ops;
38913 return 0;
38914 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
38915 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
38916 {
38917 #if defined(CONFIG_DEBUG_FS)
38918 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
38919 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
38920 - unsigned i;
38921 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
38922 + {
38923 + .name = "qxl_mem_mm",
38924 + .show = &qxl_mm_dump_table,
38925 + },
38926 + {
38927 + .name = "qxl_surf_mm",
38928 + .show = &qxl_mm_dump_table,
38929 + }
38930 + };
38931
38932 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
38933 - if (i == 0)
38934 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
38935 - else
38936 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
38937 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
38938 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
38939 - qxl_mem_types_list[i].driver_features = 0;
38940 - if (i == 0)
38941 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38942 - else
38943 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38944 + pax_open_kernel();
38945 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
38946 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
38947 + pax_close_kernel();
38948
38949 - }
38950 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
38951 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
38952 #else
38953 return 0;
38954 #endif
38955 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
38956 index d4660cf..70dbe65 100644
38957 --- a/drivers/gpu/drm/r128/r128_cce.c
38958 +++ b/drivers/gpu/drm/r128/r128_cce.c
38959 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
38960
38961 /* GH: Simple idle check.
38962 */
38963 - atomic_set(&dev_priv->idle_count, 0);
38964 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38965
38966 /* We don't support anything other than bus-mastering ring mode,
38967 * but the ring can be in either AGP or PCI space for the ring
38968 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
38969 index 930c71b..499aded 100644
38970 --- a/drivers/gpu/drm/r128/r128_drv.h
38971 +++ b/drivers/gpu/drm/r128/r128_drv.h
38972 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
38973 int is_pci;
38974 unsigned long cce_buffers_offset;
38975
38976 - atomic_t idle_count;
38977 + atomic_unchecked_t idle_count;
38978
38979 int page_flipping;
38980 int current_page;
38981 u32 crtc_offset;
38982 u32 crtc_offset_cntl;
38983
38984 - atomic_t vbl_received;
38985 + atomic_unchecked_t vbl_received;
38986
38987 u32 color_fmt;
38988 unsigned int front_offset;
38989 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
38990 index a954c54..9cc595c 100644
38991 --- a/drivers/gpu/drm/r128/r128_ioc32.c
38992 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
38993 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
38994 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
38995 }
38996
38997 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
38998 +drm_ioctl_compat_t r128_compat_ioctls[] = {
38999 [DRM_R128_INIT] = compat_r128_init,
39000 [DRM_R128_DEPTH] = compat_r128_depth,
39001 [DRM_R128_STIPPLE] = compat_r128_stipple,
39002 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
39003 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39004 {
39005 unsigned int nr = DRM_IOCTL_NR(cmd);
39006 - drm_ioctl_compat_t *fn = NULL;
39007 int ret;
39008
39009 if (nr < DRM_COMMAND_BASE)
39010 return drm_compat_ioctl(filp, cmd, arg);
39011
39012 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
39013 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39014 -
39015 - if (fn != NULL)
39016 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
39017 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39018 ret = (*fn) (filp, cmd, arg);
39019 - else
39020 + } else
39021 ret = drm_ioctl(filp, cmd, arg);
39022
39023 return ret;
39024 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
39025 index 2ea4f09..d391371 100644
39026 --- a/drivers/gpu/drm/r128/r128_irq.c
39027 +++ b/drivers/gpu/drm/r128/r128_irq.c
39028 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
39029 if (crtc != 0)
39030 return 0;
39031
39032 - return atomic_read(&dev_priv->vbl_received);
39033 + return atomic_read_unchecked(&dev_priv->vbl_received);
39034 }
39035
39036 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39037 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39038 /* VBLANK interrupt */
39039 if (status & R128_CRTC_VBLANK_INT) {
39040 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
39041 - atomic_inc(&dev_priv->vbl_received);
39042 + atomic_inc_unchecked(&dev_priv->vbl_received);
39043 drm_handle_vblank(dev, 0);
39044 return IRQ_HANDLED;
39045 }
39046 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
39047 index 19bb7e6..de7e2a2 100644
39048 --- a/drivers/gpu/drm/r128/r128_state.c
39049 +++ b/drivers/gpu/drm/r128/r128_state.c
39050 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
39051
39052 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
39053 {
39054 - if (atomic_read(&dev_priv->idle_count) == 0)
39055 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
39056 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
39057 else
39058 - atomic_set(&dev_priv->idle_count, 0);
39059 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39060 }
39061
39062 #endif
39063 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
39064 index af85299..ed9ac8d 100644
39065 --- a/drivers/gpu/drm/radeon/mkregtable.c
39066 +++ b/drivers/gpu/drm/radeon/mkregtable.c
39067 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
39068 regex_t mask_rex;
39069 regmatch_t match[4];
39070 char buf[1024];
39071 - size_t end;
39072 + long end;
39073 int len;
39074 int done = 0;
39075 int r;
39076 unsigned o;
39077 struct offset *offset;
39078 char last_reg_s[10];
39079 - int last_reg;
39080 + unsigned long last_reg;
39081
39082 if (regcomp
39083 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
39084 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
39085 index d15f27e..ef11ffc 100644
39086 --- a/drivers/gpu/drm/radeon/radeon_device.c
39087 +++ b/drivers/gpu/drm/radeon/radeon_device.c
39088 @@ -1105,7 +1105,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
39089 bool can_switch;
39090
39091 spin_lock(&dev->count_lock);
39092 - can_switch = (dev->open_count == 0);
39093 + can_switch = (local_read(&dev->open_count) == 0);
39094 spin_unlock(&dev->count_lock);
39095 return can_switch;
39096 }
39097 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39098 index b369d42..8dd04eb 100644
39099 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39100 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39101 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39102
39103 /* SW interrupt */
39104 wait_queue_head_t swi_queue;
39105 - atomic_t swi_emitted;
39106 + atomic_unchecked_t swi_emitted;
39107 int vblank_crtc;
39108 uint32_t irq_enable_reg;
39109 uint32_t r500_disp_irq_reg;
39110 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39111 index c180df8..5fd8186 100644
39112 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39113 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39114 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39115 request = compat_alloc_user_space(sizeof(*request));
39116 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39117 || __put_user(req32.param, &request->param)
39118 - || __put_user((void __user *)(unsigned long)req32.value,
39119 + || __put_user((unsigned long)req32.value,
39120 &request->value))
39121 return -EFAULT;
39122
39123 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39124 #define compat_radeon_cp_setparam NULL
39125 #endif /* X86_64 || IA64 */
39126
39127 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39128 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39129 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39130 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39131 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39132 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39133 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39134 {
39135 unsigned int nr = DRM_IOCTL_NR(cmd);
39136 - drm_ioctl_compat_t *fn = NULL;
39137 int ret;
39138
39139 if (nr < DRM_COMMAND_BASE)
39140 return drm_compat_ioctl(filp, cmd, arg);
39141
39142 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39143 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39144 -
39145 - if (fn != NULL)
39146 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39147 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39148 ret = (*fn) (filp, cmd, arg);
39149 - else
39150 + } else
39151 ret = drm_ioctl(filp, cmd, arg);
39152
39153 return ret;
39154 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39155 index 8d68e97..9dcfed8 100644
39156 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39157 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39158 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39159 unsigned int ret;
39160 RING_LOCALS;
39161
39162 - atomic_inc(&dev_priv->swi_emitted);
39163 - ret = atomic_read(&dev_priv->swi_emitted);
39164 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39165 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39166
39167 BEGIN_RING(4);
39168 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39169 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39170 drm_radeon_private_t *dev_priv =
39171 (drm_radeon_private_t *) dev->dev_private;
39172
39173 - atomic_set(&dev_priv->swi_emitted, 0);
39174 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39175 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39176
39177 dev->max_vblank_count = 0x001fffff;
39178 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39179 index 4d20910..6726b6d 100644
39180 --- a/drivers/gpu/drm/radeon/radeon_state.c
39181 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39182 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39183 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39184 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39185
39186 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39187 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39188 sarea_priv->nbox * sizeof(depth_boxes[0])))
39189 return -EFAULT;
39190
39191 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39192 {
39193 drm_radeon_private_t *dev_priv = dev->dev_private;
39194 drm_radeon_getparam_t *param = data;
39195 - int value;
39196 + int value = 0;
39197
39198 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39199
39200 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39201 index 6c0ce89..57a2529 100644
39202 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39203 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39204 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39205 man->size = size >> PAGE_SHIFT;
39206 }
39207
39208 -static struct vm_operations_struct radeon_ttm_vm_ops;
39209 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39210 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39211
39212 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39213 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39214 }
39215 if (unlikely(ttm_vm_ops == NULL)) {
39216 ttm_vm_ops = vma->vm_ops;
39217 + pax_open_kernel();
39218 radeon_ttm_vm_ops = *ttm_vm_ops;
39219 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39220 + pax_close_kernel();
39221 }
39222 vma->vm_ops = &radeon_ttm_vm_ops;
39223 return 0;
39224 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39225 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39226 {
39227 #if defined(CONFIG_DEBUG_FS)
39228 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39229 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39230 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39231 + {
39232 + .name = "radeon_vram_mm",
39233 + .show = &radeon_mm_dump_table,
39234 + },
39235 + {
39236 + .name = "radeon_gtt_mm",
39237 + .show = &radeon_mm_dump_table,
39238 + },
39239 + {
39240 + .name = "ttm_page_pool",
39241 + .show = &ttm_page_alloc_debugfs,
39242 + },
39243 + {
39244 + .name = "ttm_dma_page_pool",
39245 + .show = &ttm_dma_page_alloc_debugfs,
39246 + },
39247 + };
39248 unsigned i;
39249
39250 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39251 - if (i == 0)
39252 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39253 - else
39254 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39255 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39256 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39257 - radeon_mem_types_list[i].driver_features = 0;
39258 - if (i == 0)
39259 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39260 - else
39261 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39262 -
39263 - }
39264 - /* Add ttm page pool to debugfs */
39265 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39266 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39267 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39268 - radeon_mem_types_list[i].driver_features = 0;
39269 - radeon_mem_types_list[i++].data = NULL;
39270 + pax_open_kernel();
39271 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39272 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39273 + pax_close_kernel();
39274 #ifdef CONFIG_SWIOTLB
39275 - if (swiotlb_nr_tbl()) {
39276 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39277 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39278 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39279 - radeon_mem_types_list[i].driver_features = 0;
39280 - radeon_mem_types_list[i++].data = NULL;
39281 - }
39282 + if (swiotlb_nr_tbl())
39283 + i++;
39284 #endif
39285 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39286
39287 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39288 index d8ddfb3..609de1d 100644
39289 --- a/drivers/gpu/drm/radeon/rs690.c
39290 +++ b/drivers/gpu/drm/radeon/rs690.c
39291 @@ -345,9 +345,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39292 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39293 rdev->pm.sideport_bandwidth.full)
39294 max_bandwidth = rdev->pm.sideport_bandwidth;
39295 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39296 + read_delay_latency.full = dfixed_const(800 * 1000);
39297 read_delay_latency.full = dfixed_div(read_delay_latency,
39298 rdev->pm.igp_sideport_mclk);
39299 + a.full = dfixed_const(370);
39300 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39301 } else {
39302 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39303 rdev->pm.k8_bandwidth.full)
39304 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39305 index dbc2def..0a9f710 100644
39306 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39307 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39308 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39309 zone->glob = glob;
39310 glob->zone_kernel = zone;
39311 ret = kobject_init_and_add(
39312 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39313 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39314 if (unlikely(ret != 0)) {
39315 kobject_put(&zone->kobj);
39316 return ret;
39317 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39318 zone->glob = glob;
39319 glob->zone_dma32 = zone;
39320 ret = kobject_init_and_add(
39321 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39322 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39323 if (unlikely(ret != 0)) {
39324 kobject_put(&zone->kobj);
39325 return ret;
39326 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39327 index bd2a3b4..122d9ad 100644
39328 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39329 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39330 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
39331 static int ttm_pool_mm_shrink(struct shrinker *shrink,
39332 struct shrink_control *sc)
39333 {
39334 - static atomic_t start_pool = ATOMIC_INIT(0);
39335 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39336 unsigned i;
39337 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39338 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39339 struct ttm_page_pool *pool;
39340 int shrink_pages = sc->nr_to_scan;
39341
39342 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39343 index 97e9d61..bf23c461 100644
39344 --- a/drivers/gpu/drm/udl/udl_fb.c
39345 +++ b/drivers/gpu/drm/udl/udl_fb.c
39346 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39347 fb_deferred_io_cleanup(info);
39348 kfree(info->fbdefio);
39349 info->fbdefio = NULL;
39350 - info->fbops->fb_mmap = udl_fb_mmap;
39351 }
39352
39353 pr_warn("released /dev/fb%d user=%d count=%d\n",
39354 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39355 index 893a650..6190d3b 100644
39356 --- a/drivers/gpu/drm/via/via_drv.h
39357 +++ b/drivers/gpu/drm/via/via_drv.h
39358 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39359 typedef uint32_t maskarray_t[5];
39360
39361 typedef struct drm_via_irq {
39362 - atomic_t irq_received;
39363 + atomic_unchecked_t irq_received;
39364 uint32_t pending_mask;
39365 uint32_t enable_mask;
39366 wait_queue_head_t irq_queue;
39367 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39368 struct timeval last_vblank;
39369 int last_vblank_valid;
39370 unsigned usec_per_vblank;
39371 - atomic_t vbl_received;
39372 + atomic_unchecked_t vbl_received;
39373 drm_via_state_t hc_state;
39374 char pci_buf[VIA_PCI_BUF_SIZE];
39375 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39376 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39377 index ac98964..5dbf512 100644
39378 --- a/drivers/gpu/drm/via/via_irq.c
39379 +++ b/drivers/gpu/drm/via/via_irq.c
39380 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39381 if (crtc != 0)
39382 return 0;
39383
39384 - return atomic_read(&dev_priv->vbl_received);
39385 + return atomic_read_unchecked(&dev_priv->vbl_received);
39386 }
39387
39388 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39389 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39390
39391 status = VIA_READ(VIA_REG_INTERRUPT);
39392 if (status & VIA_IRQ_VBLANK_PENDING) {
39393 - atomic_inc(&dev_priv->vbl_received);
39394 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39395 + atomic_inc_unchecked(&dev_priv->vbl_received);
39396 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39397 do_gettimeofday(&cur_vblank);
39398 if (dev_priv->last_vblank_valid) {
39399 dev_priv->usec_per_vblank =
39400 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39401 dev_priv->last_vblank = cur_vblank;
39402 dev_priv->last_vblank_valid = 1;
39403 }
39404 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39405 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39406 DRM_DEBUG("US per vblank is: %u\n",
39407 dev_priv->usec_per_vblank);
39408 }
39409 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39410
39411 for (i = 0; i < dev_priv->num_irqs; ++i) {
39412 if (status & cur_irq->pending_mask) {
39413 - atomic_inc(&cur_irq->irq_received);
39414 + atomic_inc_unchecked(&cur_irq->irq_received);
39415 DRM_WAKEUP(&cur_irq->irq_queue);
39416 handled = 1;
39417 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39418 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39419 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39420 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39421 masks[irq][4]));
39422 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39423 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39424 } else {
39425 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39426 (((cur_irq_sequence =
39427 - atomic_read(&cur_irq->irq_received)) -
39428 + atomic_read_unchecked(&cur_irq->irq_received)) -
39429 *sequence) <= (1 << 23)));
39430 }
39431 *sequence = cur_irq_sequence;
39432 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39433 }
39434
39435 for (i = 0; i < dev_priv->num_irqs; ++i) {
39436 - atomic_set(&cur_irq->irq_received, 0);
39437 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39438 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39439 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39440 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39441 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39442 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39443 case VIA_IRQ_RELATIVE:
39444 irqwait->request.sequence +=
39445 - atomic_read(&cur_irq->irq_received);
39446 + atomic_read_unchecked(&cur_irq->irq_received);
39447 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39448 case VIA_IRQ_ABSOLUTE:
39449 break;
39450 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39451 index 13aeda7..4a952d1 100644
39452 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39453 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39454 @@ -290,7 +290,7 @@ struct vmw_private {
39455 * Fencing and IRQs.
39456 */
39457
39458 - atomic_t marker_seq;
39459 + atomic_unchecked_t marker_seq;
39460 wait_queue_head_t fence_queue;
39461 wait_queue_head_t fifo_queue;
39462 int fence_queue_waiters; /* Protected by hw_mutex */
39463 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39464 index 3eb1486..0a47ee9 100644
39465 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39466 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
39467 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
39468 (unsigned int) min,
39469 (unsigned int) fifo->capabilities);
39470
39471 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39472 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
39473 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
39474 vmw_marker_queue_init(&fifo->marker_queue);
39475 return vmw_fifo_send_fence(dev_priv, &dummy);
39476 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
39477 if (reserveable)
39478 iowrite32(bytes, fifo_mem +
39479 SVGA_FIFO_RESERVED);
39480 - return fifo_mem + (next_cmd >> 2);
39481 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
39482 } else {
39483 need_bounce = true;
39484 }
39485 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39486
39487 fm = vmw_fifo_reserve(dev_priv, bytes);
39488 if (unlikely(fm == NULL)) {
39489 - *seqno = atomic_read(&dev_priv->marker_seq);
39490 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39491 ret = -ENOMEM;
39492 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
39493 false, 3*HZ);
39494 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
39495 }
39496
39497 do {
39498 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
39499 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
39500 } while (*seqno == 0);
39501
39502 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
39503 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39504 index c509d40..3b640c3 100644
39505 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39506 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
39507 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
39508 int ret;
39509
39510 num_clips = arg->num_clips;
39511 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39512 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39513
39514 if (unlikely(num_clips == 0))
39515 return 0;
39516 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
39517 int ret;
39518
39519 num_clips = arg->num_clips;
39520 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
39521 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
39522
39523 if (unlikely(num_clips == 0))
39524 return 0;
39525 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39526 index 4640adb..e1384ed 100644
39527 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39528 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
39529 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
39530 * emitted. Then the fence is stale and signaled.
39531 */
39532
39533 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
39534 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
39535 > VMW_FENCE_WRAP);
39536
39537 return ret;
39538 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
39539
39540 if (fifo_idle)
39541 down_read(&fifo_state->rwsem);
39542 - signal_seq = atomic_read(&dev_priv->marker_seq);
39543 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
39544 ret = 0;
39545
39546 for (;;) {
39547 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39548 index 8a8725c2..afed796 100644
39549 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39550 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
39551 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
39552 while (!vmw_lag_lt(queue, us)) {
39553 spin_lock(&queue->lock);
39554 if (list_empty(&queue->head))
39555 - seqno = atomic_read(&dev_priv->marker_seq);
39556 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
39557 else {
39558 marker = list_first_entry(&queue->head,
39559 struct vmw_marker, head);
39560 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
39561 index 5360e5a..c2c0d26 100644
39562 --- a/drivers/gpu/host1x/drm/dc.c
39563 +++ b/drivers/gpu/host1x/drm/dc.c
39564 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
39565 }
39566
39567 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
39568 - dc->debugfs_files[i].data = dc;
39569 + *(void **)&dc->debugfs_files[i].data = dc;
39570
39571 err = drm_debugfs_create_files(dc->debugfs_files,
39572 ARRAY_SIZE(debugfs_files),
39573 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
39574 index 9f60d63..c89e0b7 100644
39575 --- a/drivers/hid/hid-core.c
39576 +++ b/drivers/hid/hid-core.c
39577 @@ -2370,7 +2370,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
39578
39579 int hid_add_device(struct hid_device *hdev)
39580 {
39581 - static atomic_t id = ATOMIC_INIT(0);
39582 + static atomic_unchecked_t id = ATOMIC_INIT(0);
39583 int ret;
39584
39585 if (WARN_ON(hdev->status & HID_STAT_ADDED))
39586 @@ -2404,7 +2404,7 @@ int hid_add_device(struct hid_device *hdev)
39587 /* XXX hack, any other cleaner solution after the driver core
39588 * is converted to allow more than 20 bytes as the device name? */
39589 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
39590 - hdev->vendor, hdev->product, atomic_inc_return(&id));
39591 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
39592
39593 hid_debug_register(hdev, dev_name(&hdev->dev));
39594 ret = device_add(&hdev->dev);
39595 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
39596 index c13fb5b..55a3802 100644
39597 --- a/drivers/hid/hid-wiimote-debug.c
39598 +++ b/drivers/hid/hid-wiimote-debug.c
39599 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
39600 else if (size == 0)
39601 return -EIO;
39602
39603 - if (copy_to_user(u, buf, size))
39604 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
39605 return -EFAULT;
39606
39607 *off += size;
39608 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
39609 index 145a4cb..2353a3e 100644
39610 --- a/drivers/hid/uhid.c
39611 +++ b/drivers/hid/uhid.c
39612 @@ -47,7 +47,7 @@ struct uhid_device {
39613 struct mutex report_lock;
39614 wait_queue_head_t report_wait;
39615 atomic_t report_done;
39616 - atomic_t report_id;
39617 + atomic_unchecked_t report_id;
39618 struct uhid_event report_buf;
39619 };
39620
39621 @@ -187,7 +187,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
39622
39623 spin_lock_irqsave(&uhid->qlock, flags);
39624 ev->type = UHID_FEATURE;
39625 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
39626 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
39627 ev->u.feature.rnum = rnum;
39628 ev->u.feature.rtype = report_type;
39629
39630 @@ -471,7 +471,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
39631 spin_lock_irqsave(&uhid->qlock, flags);
39632
39633 /* id for old report; drop it silently */
39634 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
39635 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
39636 goto unlock;
39637 if (atomic_read(&uhid->report_done))
39638 goto unlock;
39639 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
39640 index 6de6c98..18319e9 100644
39641 --- a/drivers/hv/channel.c
39642 +++ b/drivers/hv/channel.c
39643 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
39644 int ret = 0;
39645 int t;
39646
39647 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
39648 - atomic_inc(&vmbus_connection.next_gpadl_handle);
39649 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
39650 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
39651
39652 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
39653 if (ret)
39654 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
39655 index 88f4096..e50452e 100644
39656 --- a/drivers/hv/hv.c
39657 +++ b/drivers/hv/hv.c
39658 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
39659 u64 output_address = (output) ? virt_to_phys(output) : 0;
39660 u32 output_address_hi = output_address >> 32;
39661 u32 output_address_lo = output_address & 0xFFFFFFFF;
39662 - void *hypercall_page = hv_context.hypercall_page;
39663 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
39664
39665 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
39666 "=a"(hv_status_lo) : "d" (control_hi),
39667 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
39668 index deb5c25..ed2d4fd 100644
39669 --- a/drivers/hv/hv_balloon.c
39670 +++ b/drivers/hv/hv_balloon.c
39671 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
39672
39673 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
39674 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
39675 -static atomic_t trans_id = ATOMIC_INIT(0);
39676 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
39677
39678 static int dm_ring_size = (5 * PAGE_SIZE);
39679
39680 @@ -825,7 +825,7 @@ static void hot_add_req(struct work_struct *dummy)
39681 memset(&resp, 0, sizeof(struct dm_hot_add_response));
39682 resp.hdr.type = DM_MEM_HOT_ADD_RESPONSE;
39683 resp.hdr.size = sizeof(struct dm_hot_add_response);
39684 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39685 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39686
39687 #ifdef CONFIG_MEMORY_HOTPLUG
39688 pg_start = dm->ha_wrk.ha_page_range.finfo.start_page;
39689 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
39690 memset(&status, 0, sizeof(struct dm_status));
39691 status.hdr.type = DM_STATUS_REPORT;
39692 status.hdr.size = sizeof(struct dm_status);
39693 - status.hdr.trans_id = atomic_inc_return(&trans_id);
39694 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39695
39696 /*
39697 * The host expects the guest to report free memory.
39698 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
39699 * send the status. This can happen if we were interrupted
39700 * after we picked our transaction ID.
39701 */
39702 - if (status.hdr.trans_id != atomic_read(&trans_id))
39703 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
39704 return;
39705
39706 vmbus_sendpacket(dm->dev->channel, &status,
39707 @@ -1081,7 +1081,7 @@ static void balloon_up(struct work_struct *dummy)
39708 bl_resp = (struct dm_balloon_response *)send_buffer;
39709 memset(send_buffer, 0, PAGE_SIZE);
39710 bl_resp->hdr.type = DM_BALLOON_RESPONSE;
39711 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
39712 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39713 bl_resp->hdr.size = sizeof(struct dm_balloon_response);
39714 bl_resp->more_pages = 1;
39715
39716 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
39717
39718 memset(&resp, 0, sizeof(struct dm_unballoon_response));
39719 resp.hdr.type = DM_UNBALLOON_RESPONSE;
39720 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
39721 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39722 resp.hdr.size = sizeof(struct dm_unballoon_response);
39723
39724 vmbus_sendpacket(dm_device.dev->channel, &resp,
39725 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
39726 memset(&version_req, 0, sizeof(struct dm_version_request));
39727 version_req.hdr.type = DM_VERSION_REQUEST;
39728 version_req.hdr.size = sizeof(struct dm_version_request);
39729 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39730 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39731 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
39732 version_req.is_last_attempt = 1;
39733
39734 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
39735 memset(&version_req, 0, sizeof(struct dm_version_request));
39736 version_req.hdr.type = DM_VERSION_REQUEST;
39737 version_req.hdr.size = sizeof(struct dm_version_request);
39738 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
39739 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39740 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
39741 version_req.is_last_attempt = 0;
39742
39743 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
39744 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
39745 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
39746 cap_msg.hdr.size = sizeof(struct dm_capabilities);
39747 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
39748 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
39749
39750 cap_msg.caps.cap_bits.balloon = 1;
39751 cap_msg.caps.cap_bits.hot_add = 1;
39752 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
39753 index d84918f..7f38f9f 100644
39754 --- a/drivers/hv/hyperv_vmbus.h
39755 +++ b/drivers/hv/hyperv_vmbus.h
39756 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
39757 struct vmbus_connection {
39758 enum vmbus_connect_state conn_state;
39759
39760 - atomic_t next_gpadl_handle;
39761 + atomic_unchecked_t next_gpadl_handle;
39762
39763 /*
39764 * Represents channel interrupts. Each bit position represents a
39765 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
39766 index e8e071f..5b4b245 100644
39767 --- a/drivers/hv/vmbus_drv.c
39768 +++ b/drivers/hv/vmbus_drv.c
39769 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
39770 {
39771 int ret = 0;
39772
39773 - static atomic_t device_num = ATOMIC_INIT(0);
39774 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
39775
39776 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
39777 - atomic_inc_return(&device_num));
39778 + atomic_inc_return_unchecked(&device_num));
39779
39780 child_device_obj->device.bus = &hv_bus;
39781 child_device_obj->device.parent = &hv_acpi_dev->dev;
39782 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
39783 index 6351aba..dc4aaf4 100644
39784 --- a/drivers/hwmon/acpi_power_meter.c
39785 +++ b/drivers/hwmon/acpi_power_meter.c
39786 @@ -117,7 +117,7 @@ struct sensor_template {
39787 struct device_attribute *devattr,
39788 const char *buf, size_t count);
39789 int index;
39790 -};
39791 +} __do_const;
39792
39793 /* Averaging interval */
39794 static int update_avg_interval(struct acpi_power_meter_resource *resource)
39795 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
39796 struct sensor_template *attrs)
39797 {
39798 struct device *dev = &resource->acpi_dev->dev;
39799 - struct sensor_device_attribute *sensors =
39800 + sensor_device_attribute_no_const *sensors =
39801 &resource->sensors[resource->num_sensors];
39802 int res = 0;
39803
39804 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
39805 index 3288f13..71cfb4e 100644
39806 --- a/drivers/hwmon/applesmc.c
39807 +++ b/drivers/hwmon/applesmc.c
39808 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
39809 {
39810 struct applesmc_node_group *grp;
39811 struct applesmc_dev_attr *node;
39812 - struct attribute *attr;
39813 + attribute_no_const *attr;
39814 int ret, i;
39815
39816 for (grp = groups; grp->format; grp++) {
39817 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
39818 index b25c643..a13460d 100644
39819 --- a/drivers/hwmon/asus_atk0110.c
39820 +++ b/drivers/hwmon/asus_atk0110.c
39821 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
39822 struct atk_sensor_data {
39823 struct list_head list;
39824 struct atk_data *data;
39825 - struct device_attribute label_attr;
39826 - struct device_attribute input_attr;
39827 - struct device_attribute limit1_attr;
39828 - struct device_attribute limit2_attr;
39829 + device_attribute_no_const label_attr;
39830 + device_attribute_no_const input_attr;
39831 + device_attribute_no_const limit1_attr;
39832 + device_attribute_no_const limit2_attr;
39833 char label_attr_name[ATTR_NAME_SIZE];
39834 char input_attr_name[ATTR_NAME_SIZE];
39835 char limit1_attr_name[ATTR_NAME_SIZE];
39836 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
39837 static struct device_attribute atk_name_attr =
39838 __ATTR(name, 0444, atk_name_show, NULL);
39839
39840 -static void atk_init_attribute(struct device_attribute *attr, char *name,
39841 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
39842 sysfs_show_func show)
39843 {
39844 sysfs_attr_init(&attr->attr);
39845 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
39846 index 2e5e2dc..5208b31 100644
39847 --- a/drivers/hwmon/coretemp.c
39848 +++ b/drivers/hwmon/coretemp.c
39849 @@ -785,7 +785,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
39850 return NOTIFY_OK;
39851 }
39852
39853 -static struct notifier_block coretemp_cpu_notifier __refdata = {
39854 +static struct notifier_block coretemp_cpu_notifier = {
39855 .notifier_call = coretemp_cpu_callback,
39856 };
39857
39858 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
39859 index 1429f6e..ee03d59 100644
39860 --- a/drivers/hwmon/ibmaem.c
39861 +++ b/drivers/hwmon/ibmaem.c
39862 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
39863 struct aem_rw_sensor_template *rw)
39864 {
39865 struct device *dev = &data->pdev->dev;
39866 - struct sensor_device_attribute *sensors = data->sensors;
39867 + sensor_device_attribute_no_const *sensors = data->sensors;
39868 int err;
39869
39870 /* Set up read-only sensors */
39871 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
39872 index 708081b..fe2d4ab 100644
39873 --- a/drivers/hwmon/iio_hwmon.c
39874 +++ b/drivers/hwmon/iio_hwmon.c
39875 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
39876 {
39877 struct device *dev = &pdev->dev;
39878 struct iio_hwmon_state *st;
39879 - struct sensor_device_attribute *a;
39880 + sensor_device_attribute_no_const *a;
39881 int ret, i;
39882 int in_i = 1, temp_i = 1, curr_i = 1;
39883 enum iio_chan_type type;
39884 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
39885 index 9add6092..ee7ba3f 100644
39886 --- a/drivers/hwmon/pmbus/pmbus_core.c
39887 +++ b/drivers/hwmon/pmbus/pmbus_core.c
39888 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
39889 return 0;
39890 }
39891
39892 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39893 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
39894 const char *name,
39895 umode_t mode,
39896 ssize_t (*show)(struct device *dev,
39897 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
39898 dev_attr->store = store;
39899 }
39900
39901 -static void pmbus_attr_init(struct sensor_device_attribute *a,
39902 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
39903 const char *name,
39904 umode_t mode,
39905 ssize_t (*show)(struct device *dev,
39906 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
39907 u16 reg, u8 mask)
39908 {
39909 struct pmbus_boolean *boolean;
39910 - struct sensor_device_attribute *a;
39911 + sensor_device_attribute_no_const *a;
39912
39913 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
39914 if (!boolean)
39915 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
39916 bool update, bool readonly)
39917 {
39918 struct pmbus_sensor *sensor;
39919 - struct device_attribute *a;
39920 + device_attribute_no_const *a;
39921
39922 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
39923 if (!sensor)
39924 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
39925 const char *lstring, int index)
39926 {
39927 struct pmbus_label *label;
39928 - struct device_attribute *a;
39929 + device_attribute_no_const *a;
39930
39931 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
39932 if (!label)
39933 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
39934 index 2507f90..1645765 100644
39935 --- a/drivers/hwmon/sht15.c
39936 +++ b/drivers/hwmon/sht15.c
39937 @@ -169,7 +169,7 @@ struct sht15_data {
39938 int supply_uv;
39939 bool supply_uv_valid;
39940 struct work_struct update_supply_work;
39941 - atomic_t interrupt_handled;
39942 + atomic_unchecked_t interrupt_handled;
39943 };
39944
39945 /**
39946 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
39947 ret = gpio_direction_input(data->pdata->gpio_data);
39948 if (ret)
39949 return ret;
39950 - atomic_set(&data->interrupt_handled, 0);
39951 + atomic_set_unchecked(&data->interrupt_handled, 0);
39952
39953 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39954 if (gpio_get_value(data->pdata->gpio_data) == 0) {
39955 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
39956 /* Only relevant if the interrupt hasn't occurred. */
39957 - if (!atomic_read(&data->interrupt_handled))
39958 + if (!atomic_read_unchecked(&data->interrupt_handled))
39959 schedule_work(&data->read_work);
39960 }
39961 ret = wait_event_timeout(data->wait_queue,
39962 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
39963
39964 /* First disable the interrupt */
39965 disable_irq_nosync(irq);
39966 - atomic_inc(&data->interrupt_handled);
39967 + atomic_inc_unchecked(&data->interrupt_handled);
39968 /* Then schedule a reading work struct */
39969 if (data->state != SHT15_READING_NOTHING)
39970 schedule_work(&data->read_work);
39971 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
39972 * If not, then start the interrupt again - care here as could
39973 * have gone low in meantime so verify it hasn't!
39974 */
39975 - atomic_set(&data->interrupt_handled, 0);
39976 + atomic_set_unchecked(&data->interrupt_handled, 0);
39977 enable_irq(gpio_to_irq(data->pdata->gpio_data));
39978 /* If still not occurred or another handler was scheduled */
39979 if (gpio_get_value(data->pdata->gpio_data)
39980 - || atomic_read(&data->interrupt_handled))
39981 + || atomic_read_unchecked(&data->interrupt_handled))
39982 return;
39983 }
39984
39985 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
39986 index 38944e9..ae9e5ed 100644
39987 --- a/drivers/hwmon/via-cputemp.c
39988 +++ b/drivers/hwmon/via-cputemp.c
39989 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
39990 return NOTIFY_OK;
39991 }
39992
39993 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
39994 +static struct notifier_block via_cputemp_cpu_notifier = {
39995 .notifier_call = via_cputemp_cpu_callback,
39996 };
39997
39998 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
39999 index 07f01ac..d79ad3d 100644
40000 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40001 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40002 @@ -43,7 +43,7 @@
40003 extern struct i2c_adapter amd756_smbus;
40004
40005 static struct i2c_adapter *s4882_adapter;
40006 -static struct i2c_algorithm *s4882_algo;
40007 +static i2c_algorithm_no_const *s4882_algo;
40008
40009 /* Wrapper access functions for multiplexed SMBus */
40010 static DEFINE_MUTEX(amd756_lock);
40011 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40012 index 2ca268d..c6acbdf 100644
40013 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40014 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40015 @@ -41,7 +41,7 @@
40016 extern struct i2c_adapter *nforce2_smbus;
40017
40018 static struct i2c_adapter *s4985_adapter;
40019 -static struct i2c_algorithm *s4985_algo;
40020 +static i2c_algorithm_no_const *s4985_algo;
40021
40022 /* Wrapper access functions for multiplexed SMBus */
40023 static DEFINE_MUTEX(nforce2_lock);
40024 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40025 index c3ccdea..5b3dc1a 100644
40026 --- a/drivers/i2c/i2c-dev.c
40027 +++ b/drivers/i2c/i2c-dev.c
40028 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40029 break;
40030 }
40031
40032 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40033 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40034 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40035 if (IS_ERR(rdwr_pa[i].buf)) {
40036 res = PTR_ERR(rdwr_pa[i].buf);
40037 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40038 index 0b510ba..4fbb5085 100644
40039 --- a/drivers/ide/ide-cd.c
40040 +++ b/drivers/ide/ide-cd.c
40041 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40042 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40043 if ((unsigned long)buf & alignment
40044 || blk_rq_bytes(rq) & q->dma_pad_mask
40045 - || object_is_on_stack(buf))
40046 + || object_starts_on_stack(buf))
40047 drive->dma = 0;
40048 }
40049 }
40050 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40051 index e145931..08bfc59 100644
40052 --- a/drivers/iio/industrialio-core.c
40053 +++ b/drivers/iio/industrialio-core.c
40054 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40055 }
40056
40057 static
40058 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40059 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40060 const char *postfix,
40061 struct iio_chan_spec const *chan,
40062 ssize_t (*readfunc)(struct device *dev,
40063 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40064 index 784b97c..c9ceadf 100644
40065 --- a/drivers/infiniband/core/cm.c
40066 +++ b/drivers/infiniband/core/cm.c
40067 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40068
40069 struct cm_counter_group {
40070 struct kobject obj;
40071 - atomic_long_t counter[CM_ATTR_COUNT];
40072 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40073 };
40074
40075 struct cm_counter_attribute {
40076 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40077 struct ib_mad_send_buf *msg = NULL;
40078 int ret;
40079
40080 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40081 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40082 counter[CM_REQ_COUNTER]);
40083
40084 /* Quick state check to discard duplicate REQs. */
40085 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40086 if (!cm_id_priv)
40087 return;
40088
40089 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40090 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40091 counter[CM_REP_COUNTER]);
40092 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40093 if (ret)
40094 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40095 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40096 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40097 spin_unlock_irq(&cm_id_priv->lock);
40098 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40099 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40100 counter[CM_RTU_COUNTER]);
40101 goto out;
40102 }
40103 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40104 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40105 dreq_msg->local_comm_id);
40106 if (!cm_id_priv) {
40107 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40108 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40109 counter[CM_DREQ_COUNTER]);
40110 cm_issue_drep(work->port, work->mad_recv_wc);
40111 return -EINVAL;
40112 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40113 case IB_CM_MRA_REP_RCVD:
40114 break;
40115 case IB_CM_TIMEWAIT:
40116 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40117 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40118 counter[CM_DREQ_COUNTER]);
40119 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40120 goto unlock;
40121 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40122 cm_free_msg(msg);
40123 goto deref;
40124 case IB_CM_DREQ_RCVD:
40125 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40126 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40127 counter[CM_DREQ_COUNTER]);
40128 goto unlock;
40129 default:
40130 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40131 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40132 cm_id_priv->msg, timeout)) {
40133 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40134 - atomic_long_inc(&work->port->
40135 + atomic_long_inc_unchecked(&work->port->
40136 counter_group[CM_RECV_DUPLICATES].
40137 counter[CM_MRA_COUNTER]);
40138 goto out;
40139 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40140 break;
40141 case IB_CM_MRA_REQ_RCVD:
40142 case IB_CM_MRA_REP_RCVD:
40143 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40144 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40145 counter[CM_MRA_COUNTER]);
40146 /* fall through */
40147 default:
40148 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40149 case IB_CM_LAP_IDLE:
40150 break;
40151 case IB_CM_MRA_LAP_SENT:
40152 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40153 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40154 counter[CM_LAP_COUNTER]);
40155 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40156 goto unlock;
40157 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40158 cm_free_msg(msg);
40159 goto deref;
40160 case IB_CM_LAP_RCVD:
40161 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40162 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40163 counter[CM_LAP_COUNTER]);
40164 goto unlock;
40165 default:
40166 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40167 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40168 if (cur_cm_id_priv) {
40169 spin_unlock_irq(&cm.lock);
40170 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40171 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40172 counter[CM_SIDR_REQ_COUNTER]);
40173 goto out; /* Duplicate message. */
40174 }
40175 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40176 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40177 msg->retries = 1;
40178
40179 - atomic_long_add(1 + msg->retries,
40180 + atomic_long_add_unchecked(1 + msg->retries,
40181 &port->counter_group[CM_XMIT].counter[attr_index]);
40182 if (msg->retries)
40183 - atomic_long_add(msg->retries,
40184 + atomic_long_add_unchecked(msg->retries,
40185 &port->counter_group[CM_XMIT_RETRIES].
40186 counter[attr_index]);
40187
40188 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40189 }
40190
40191 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40192 - atomic_long_inc(&port->counter_group[CM_RECV].
40193 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40194 counter[attr_id - CM_ATTR_ID_OFFSET]);
40195
40196 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40197 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40198 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40199
40200 return sprintf(buf, "%ld\n",
40201 - atomic_long_read(&group->counter[cm_attr->index]));
40202 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40203 }
40204
40205 static const struct sysfs_ops cm_counter_ops = {
40206 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40207 index 9f5ad7c..588cd84 100644
40208 --- a/drivers/infiniband/core/fmr_pool.c
40209 +++ b/drivers/infiniband/core/fmr_pool.c
40210 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40211
40212 struct task_struct *thread;
40213
40214 - atomic_t req_ser;
40215 - atomic_t flush_ser;
40216 + atomic_unchecked_t req_ser;
40217 + atomic_unchecked_t flush_ser;
40218
40219 wait_queue_head_t force_wait;
40220 };
40221 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40222 struct ib_fmr_pool *pool = pool_ptr;
40223
40224 do {
40225 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40226 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40227 ib_fmr_batch_release(pool);
40228
40229 - atomic_inc(&pool->flush_ser);
40230 + atomic_inc_unchecked(&pool->flush_ser);
40231 wake_up_interruptible(&pool->force_wait);
40232
40233 if (pool->flush_function)
40234 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40235 }
40236
40237 set_current_state(TASK_INTERRUPTIBLE);
40238 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40239 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40240 !kthread_should_stop())
40241 schedule();
40242 __set_current_state(TASK_RUNNING);
40243 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40244 pool->dirty_watermark = params->dirty_watermark;
40245 pool->dirty_len = 0;
40246 spin_lock_init(&pool->pool_lock);
40247 - atomic_set(&pool->req_ser, 0);
40248 - atomic_set(&pool->flush_ser, 0);
40249 + atomic_set_unchecked(&pool->req_ser, 0);
40250 + atomic_set_unchecked(&pool->flush_ser, 0);
40251 init_waitqueue_head(&pool->force_wait);
40252
40253 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40254 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40255 }
40256 spin_unlock_irq(&pool->pool_lock);
40257
40258 - serial = atomic_inc_return(&pool->req_ser);
40259 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40260 wake_up_process(pool->thread);
40261
40262 if (wait_event_interruptible(pool->force_wait,
40263 - atomic_read(&pool->flush_ser) - serial >= 0))
40264 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40265 return -EINTR;
40266
40267 return 0;
40268 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40269 } else {
40270 list_add_tail(&fmr->list, &pool->dirty_list);
40271 if (++pool->dirty_len >= pool->dirty_watermark) {
40272 - atomic_inc(&pool->req_ser);
40273 + atomic_inc_unchecked(&pool->req_ser);
40274 wake_up_process(pool->thread);
40275 }
40276 }
40277 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40278 index 4cb8eb2..146bf60 100644
40279 --- a/drivers/infiniband/hw/cxgb4/mem.c
40280 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40281 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40282 int err;
40283 struct fw_ri_tpte tpt;
40284 u32 stag_idx;
40285 - static atomic_t key;
40286 + static atomic_unchecked_t key;
40287
40288 if (c4iw_fatal_error(rdev))
40289 return -EIO;
40290 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40291 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40292 rdev->stats.stag.max = rdev->stats.stag.cur;
40293 mutex_unlock(&rdev->stats.lock);
40294 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40295 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40296 }
40297 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40298 __func__, stag_state, type, pdid, stag_idx);
40299 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40300 index 79b3dbc..96e5fcc 100644
40301 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40302 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40303 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40304 struct ib_atomic_eth *ateth;
40305 struct ipath_ack_entry *e;
40306 u64 vaddr;
40307 - atomic64_t *maddr;
40308 + atomic64_unchecked_t *maddr;
40309 u64 sdata;
40310 u32 rkey;
40311 u8 next;
40312 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40313 IB_ACCESS_REMOTE_ATOMIC)))
40314 goto nack_acc_unlck;
40315 /* Perform atomic OP and save result. */
40316 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40317 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40318 sdata = be64_to_cpu(ateth->swap_data);
40319 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40320 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40321 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40322 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40323 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40324 be64_to_cpu(ateth->compare_data),
40325 sdata);
40326 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40327 index 1f95bba..9530f87 100644
40328 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40329 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40330 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40331 unsigned long flags;
40332 struct ib_wc wc;
40333 u64 sdata;
40334 - atomic64_t *maddr;
40335 + atomic64_unchecked_t *maddr;
40336 enum ib_wc_status send_status;
40337
40338 /*
40339 @@ -382,11 +382,11 @@ again:
40340 IB_ACCESS_REMOTE_ATOMIC)))
40341 goto acc_err;
40342 /* Perform atomic OP and save result. */
40343 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40344 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40345 sdata = wqe->wr.wr.atomic.compare_add;
40346 *(u64 *) sqp->s_sge.sge.vaddr =
40347 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40348 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40349 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40350 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40351 sdata, wqe->wr.wr.atomic.swap);
40352 goto send_comp;
40353 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40354 index f2a3f48..673ec79 100644
40355 --- a/drivers/infiniband/hw/mlx4/mad.c
40356 +++ b/drivers/infiniband/hw/mlx4/mad.c
40357 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40358
40359 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40360 {
40361 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40362 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40363 cpu_to_be64(0xff00000000000000LL);
40364 }
40365
40366 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40367 index 25b2cdf..099ff97 100644
40368 --- a/drivers/infiniband/hw/mlx4/mcg.c
40369 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40370 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40371 {
40372 char name[20];
40373
40374 - atomic_set(&ctx->tid, 0);
40375 + atomic_set_unchecked(&ctx->tid, 0);
40376 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40377 ctx->mcg_wq = create_singlethread_workqueue(name);
40378 if (!ctx->mcg_wq)
40379 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40380 index f61ec26..ebf72cf 100644
40381 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40382 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40383 @@ -398,7 +398,7 @@ struct mlx4_ib_demux_ctx {
40384 struct list_head mcg_mgid0_list;
40385 struct workqueue_struct *mcg_wq;
40386 struct mlx4_ib_demux_pv_ctx **tun;
40387 - atomic_t tid;
40388 + atomic_unchecked_t tid;
40389 int flushing; /* flushing the work queue */
40390 };
40391
40392 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40393 index 9d3e5c1..d9afe4a 100644
40394 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40395 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40396 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40397 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40398 }
40399
40400 -int mthca_QUERY_FW(struct mthca_dev *dev)
40401 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40402 {
40403 struct mthca_mailbox *mailbox;
40404 u32 *outbox;
40405 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
40406 index ed9a989..e0c5871 100644
40407 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
40408 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
40409 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
40410 return key;
40411 }
40412
40413 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40414 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
40415 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
40416 {
40417 struct mthca_mailbox *mailbox;
40418 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
40419 index 4291410..d2ab1fb 100644
40420 --- a/drivers/infiniband/hw/nes/nes.c
40421 +++ b/drivers/infiniband/hw/nes/nes.c
40422 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
40423 LIST_HEAD(nes_adapter_list);
40424 static LIST_HEAD(nes_dev_list);
40425
40426 -atomic_t qps_destroyed;
40427 +atomic_unchecked_t qps_destroyed;
40428
40429 static unsigned int ee_flsh_adapter;
40430 static unsigned int sysfs_nonidx_addr;
40431 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
40432 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
40433 struct nes_adapter *nesadapter = nesdev->nesadapter;
40434
40435 - atomic_inc(&qps_destroyed);
40436 + atomic_inc_unchecked(&qps_destroyed);
40437
40438 /* Free the control structures */
40439
40440 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
40441 index 33cc589..3bd6538 100644
40442 --- a/drivers/infiniband/hw/nes/nes.h
40443 +++ b/drivers/infiniband/hw/nes/nes.h
40444 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
40445 extern unsigned int wqm_quanta;
40446 extern struct list_head nes_adapter_list;
40447
40448 -extern atomic_t cm_connects;
40449 -extern atomic_t cm_accepts;
40450 -extern atomic_t cm_disconnects;
40451 -extern atomic_t cm_closes;
40452 -extern atomic_t cm_connecteds;
40453 -extern atomic_t cm_connect_reqs;
40454 -extern atomic_t cm_rejects;
40455 -extern atomic_t mod_qp_timouts;
40456 -extern atomic_t qps_created;
40457 -extern atomic_t qps_destroyed;
40458 -extern atomic_t sw_qps_destroyed;
40459 +extern atomic_unchecked_t cm_connects;
40460 +extern atomic_unchecked_t cm_accepts;
40461 +extern atomic_unchecked_t cm_disconnects;
40462 +extern atomic_unchecked_t cm_closes;
40463 +extern atomic_unchecked_t cm_connecteds;
40464 +extern atomic_unchecked_t cm_connect_reqs;
40465 +extern atomic_unchecked_t cm_rejects;
40466 +extern atomic_unchecked_t mod_qp_timouts;
40467 +extern atomic_unchecked_t qps_created;
40468 +extern atomic_unchecked_t qps_destroyed;
40469 +extern atomic_unchecked_t sw_qps_destroyed;
40470 extern u32 mh_detected;
40471 extern u32 mh_pauses_sent;
40472 extern u32 cm_packets_sent;
40473 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
40474 extern u32 cm_packets_received;
40475 extern u32 cm_packets_dropped;
40476 extern u32 cm_packets_retrans;
40477 -extern atomic_t cm_listens_created;
40478 -extern atomic_t cm_listens_destroyed;
40479 +extern atomic_unchecked_t cm_listens_created;
40480 +extern atomic_unchecked_t cm_listens_destroyed;
40481 extern u32 cm_backlog_drops;
40482 -extern atomic_t cm_loopbacks;
40483 -extern atomic_t cm_nodes_created;
40484 -extern atomic_t cm_nodes_destroyed;
40485 -extern atomic_t cm_accel_dropped_pkts;
40486 -extern atomic_t cm_resets_recvd;
40487 -extern atomic_t pau_qps_created;
40488 -extern atomic_t pau_qps_destroyed;
40489 +extern atomic_unchecked_t cm_loopbacks;
40490 +extern atomic_unchecked_t cm_nodes_created;
40491 +extern atomic_unchecked_t cm_nodes_destroyed;
40492 +extern atomic_unchecked_t cm_accel_dropped_pkts;
40493 +extern atomic_unchecked_t cm_resets_recvd;
40494 +extern atomic_unchecked_t pau_qps_created;
40495 +extern atomic_unchecked_t pau_qps_destroyed;
40496
40497 extern u32 int_mod_timer_init;
40498 extern u32 int_mod_cq_depth_256;
40499 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
40500 index 24b9f1a..00fd004 100644
40501 --- a/drivers/infiniband/hw/nes/nes_cm.c
40502 +++ b/drivers/infiniband/hw/nes/nes_cm.c
40503 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
40504 u32 cm_packets_retrans;
40505 u32 cm_packets_created;
40506 u32 cm_packets_received;
40507 -atomic_t cm_listens_created;
40508 -atomic_t cm_listens_destroyed;
40509 +atomic_unchecked_t cm_listens_created;
40510 +atomic_unchecked_t cm_listens_destroyed;
40511 u32 cm_backlog_drops;
40512 -atomic_t cm_loopbacks;
40513 -atomic_t cm_nodes_created;
40514 -atomic_t cm_nodes_destroyed;
40515 -atomic_t cm_accel_dropped_pkts;
40516 -atomic_t cm_resets_recvd;
40517 +atomic_unchecked_t cm_loopbacks;
40518 +atomic_unchecked_t cm_nodes_created;
40519 +atomic_unchecked_t cm_nodes_destroyed;
40520 +atomic_unchecked_t cm_accel_dropped_pkts;
40521 +atomic_unchecked_t cm_resets_recvd;
40522
40523 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
40524 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
40525 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
40526
40527 static struct nes_cm_core *g_cm_core;
40528
40529 -atomic_t cm_connects;
40530 -atomic_t cm_accepts;
40531 -atomic_t cm_disconnects;
40532 -atomic_t cm_closes;
40533 -atomic_t cm_connecteds;
40534 -atomic_t cm_connect_reqs;
40535 -atomic_t cm_rejects;
40536 +atomic_unchecked_t cm_connects;
40537 +atomic_unchecked_t cm_accepts;
40538 +atomic_unchecked_t cm_disconnects;
40539 +atomic_unchecked_t cm_closes;
40540 +atomic_unchecked_t cm_connecteds;
40541 +atomic_unchecked_t cm_connect_reqs;
40542 +atomic_unchecked_t cm_rejects;
40543
40544 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
40545 {
40546 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
40547 kfree(listener);
40548 listener = NULL;
40549 ret = 0;
40550 - atomic_inc(&cm_listens_destroyed);
40551 + atomic_inc_unchecked(&cm_listens_destroyed);
40552 } else {
40553 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
40554 }
40555 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
40556 cm_node->rem_mac);
40557
40558 add_hte_node(cm_core, cm_node);
40559 - atomic_inc(&cm_nodes_created);
40560 + atomic_inc_unchecked(&cm_nodes_created);
40561
40562 return cm_node;
40563 }
40564 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
40565 }
40566
40567 atomic_dec(&cm_core->node_cnt);
40568 - atomic_inc(&cm_nodes_destroyed);
40569 + atomic_inc_unchecked(&cm_nodes_destroyed);
40570 nesqp = cm_node->nesqp;
40571 if (nesqp) {
40572 nesqp->cm_node = NULL;
40573 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
40574
40575 static void drop_packet(struct sk_buff *skb)
40576 {
40577 - atomic_inc(&cm_accel_dropped_pkts);
40578 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40579 dev_kfree_skb_any(skb);
40580 }
40581
40582 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
40583 {
40584
40585 int reset = 0; /* whether to send reset in case of err.. */
40586 - atomic_inc(&cm_resets_recvd);
40587 + atomic_inc_unchecked(&cm_resets_recvd);
40588 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
40589 " refcnt=%d\n", cm_node, cm_node->state,
40590 atomic_read(&cm_node->ref_count));
40591 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
40592 rem_ref_cm_node(cm_node->cm_core, cm_node);
40593 return NULL;
40594 }
40595 - atomic_inc(&cm_loopbacks);
40596 + atomic_inc_unchecked(&cm_loopbacks);
40597 loopbackremotenode->loopbackpartner = cm_node;
40598 loopbackremotenode->tcp_cntxt.rcv_wscale =
40599 NES_CM_DEFAULT_RCV_WND_SCALE;
40600 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
40601 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
40602 else {
40603 rem_ref_cm_node(cm_core, cm_node);
40604 - atomic_inc(&cm_accel_dropped_pkts);
40605 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
40606 dev_kfree_skb_any(skb);
40607 }
40608 break;
40609 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40610
40611 if ((cm_id) && (cm_id->event_handler)) {
40612 if (issue_disconn) {
40613 - atomic_inc(&cm_disconnects);
40614 + atomic_inc_unchecked(&cm_disconnects);
40615 cm_event.event = IW_CM_EVENT_DISCONNECT;
40616 cm_event.status = disconn_status;
40617 cm_event.local_addr = cm_id->local_addr;
40618 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
40619 }
40620
40621 if (issue_close) {
40622 - atomic_inc(&cm_closes);
40623 + atomic_inc_unchecked(&cm_closes);
40624 nes_disconnect(nesqp, 1);
40625
40626 cm_id->provider_data = nesqp;
40627 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40628
40629 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
40630 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
40631 - atomic_inc(&cm_accepts);
40632 + atomic_inc_unchecked(&cm_accepts);
40633
40634 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
40635 netdev_refcnt_read(nesvnic->netdev));
40636 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
40637 struct nes_cm_core *cm_core;
40638 u8 *start_buff;
40639
40640 - atomic_inc(&cm_rejects);
40641 + atomic_inc_unchecked(&cm_rejects);
40642 cm_node = (struct nes_cm_node *)cm_id->provider_data;
40643 loopback = cm_node->loopbackpartner;
40644 cm_core = cm_node->cm_core;
40645 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
40646 ntohl(cm_id->local_addr.sin_addr.s_addr),
40647 ntohs(cm_id->local_addr.sin_port));
40648
40649 - atomic_inc(&cm_connects);
40650 + atomic_inc_unchecked(&cm_connects);
40651 nesqp->active_conn = 1;
40652
40653 /* cache the cm_id in the qp */
40654 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
40655 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
40656 return err;
40657 }
40658 - atomic_inc(&cm_listens_created);
40659 + atomic_inc_unchecked(&cm_listens_created);
40660 }
40661
40662 cm_id->add_ref(cm_id);
40663 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
40664
40665 if (nesqp->destroyed)
40666 return;
40667 - atomic_inc(&cm_connecteds);
40668 + atomic_inc_unchecked(&cm_connecteds);
40669 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
40670 " local port 0x%04X. jiffies = %lu.\n",
40671 nesqp->hwqp.qp_id,
40672 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
40673
40674 cm_id->add_ref(cm_id);
40675 ret = cm_id->event_handler(cm_id, &cm_event);
40676 - atomic_inc(&cm_closes);
40677 + atomic_inc_unchecked(&cm_closes);
40678 cm_event.event = IW_CM_EVENT_CLOSE;
40679 cm_event.status = 0;
40680 cm_event.provider_data = cm_id->provider_data;
40681 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
40682 return;
40683 cm_id = cm_node->cm_id;
40684
40685 - atomic_inc(&cm_connect_reqs);
40686 + atomic_inc_unchecked(&cm_connect_reqs);
40687 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40688 cm_node, cm_id, jiffies);
40689
40690 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
40691 return;
40692 cm_id = cm_node->cm_id;
40693
40694 - atomic_inc(&cm_connect_reqs);
40695 + atomic_inc_unchecked(&cm_connect_reqs);
40696 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
40697 cm_node, cm_id, jiffies);
40698
40699 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
40700 index 4166452..fc952c3 100644
40701 --- a/drivers/infiniband/hw/nes/nes_mgt.c
40702 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
40703 @@ -40,8 +40,8 @@
40704 #include "nes.h"
40705 #include "nes_mgt.h"
40706
40707 -atomic_t pau_qps_created;
40708 -atomic_t pau_qps_destroyed;
40709 +atomic_unchecked_t pau_qps_created;
40710 +atomic_unchecked_t pau_qps_destroyed;
40711
40712 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
40713 {
40714 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
40715 {
40716 struct sk_buff *skb;
40717 unsigned long flags;
40718 - atomic_inc(&pau_qps_destroyed);
40719 + atomic_inc_unchecked(&pau_qps_destroyed);
40720
40721 /* Free packets that have not yet been forwarded */
40722 /* Lock is acquired by skb_dequeue when removing the skb */
40723 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
40724 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
40725 skb_queue_head_init(&nesqp->pau_list);
40726 spin_lock_init(&nesqp->pau_lock);
40727 - atomic_inc(&pau_qps_created);
40728 + atomic_inc_unchecked(&pau_qps_created);
40729 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
40730 }
40731
40732 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
40733 index 49eb511..a774366 100644
40734 --- a/drivers/infiniband/hw/nes/nes_nic.c
40735 +++ b/drivers/infiniband/hw/nes/nes_nic.c
40736 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
40737 target_stat_values[++index] = mh_detected;
40738 target_stat_values[++index] = mh_pauses_sent;
40739 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
40740 - target_stat_values[++index] = atomic_read(&cm_connects);
40741 - target_stat_values[++index] = atomic_read(&cm_accepts);
40742 - target_stat_values[++index] = atomic_read(&cm_disconnects);
40743 - target_stat_values[++index] = atomic_read(&cm_connecteds);
40744 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
40745 - target_stat_values[++index] = atomic_read(&cm_rejects);
40746 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
40747 - target_stat_values[++index] = atomic_read(&qps_created);
40748 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
40749 - target_stat_values[++index] = atomic_read(&qps_destroyed);
40750 - target_stat_values[++index] = atomic_read(&cm_closes);
40751 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
40752 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
40753 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
40754 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
40755 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
40756 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
40757 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
40758 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
40759 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
40760 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
40761 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
40762 target_stat_values[++index] = cm_packets_sent;
40763 target_stat_values[++index] = cm_packets_bounced;
40764 target_stat_values[++index] = cm_packets_created;
40765 target_stat_values[++index] = cm_packets_received;
40766 target_stat_values[++index] = cm_packets_dropped;
40767 target_stat_values[++index] = cm_packets_retrans;
40768 - target_stat_values[++index] = atomic_read(&cm_listens_created);
40769 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
40770 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
40771 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
40772 target_stat_values[++index] = cm_backlog_drops;
40773 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
40774 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
40775 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
40776 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
40777 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
40778 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
40779 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
40780 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
40781 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
40782 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
40783 target_stat_values[++index] = nesadapter->free_4kpbl;
40784 target_stat_values[++index] = nesadapter->free_256pbl;
40785 target_stat_values[++index] = int_mod_timer_init;
40786 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
40787 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
40788 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
40789 - target_stat_values[++index] = atomic_read(&pau_qps_created);
40790 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
40791 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
40792 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
40793 }
40794
40795 /**
40796 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
40797 index 5b53ca5..443da3c 100644
40798 --- a/drivers/infiniband/hw/nes/nes_verbs.c
40799 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
40800 @@ -46,9 +46,9 @@
40801
40802 #include <rdma/ib_umem.h>
40803
40804 -atomic_t mod_qp_timouts;
40805 -atomic_t qps_created;
40806 -atomic_t sw_qps_destroyed;
40807 +atomic_unchecked_t mod_qp_timouts;
40808 +atomic_unchecked_t qps_created;
40809 +atomic_unchecked_t sw_qps_destroyed;
40810
40811 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
40812
40813 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
40814 if (init_attr->create_flags)
40815 return ERR_PTR(-EINVAL);
40816
40817 - atomic_inc(&qps_created);
40818 + atomic_inc_unchecked(&qps_created);
40819 switch (init_attr->qp_type) {
40820 case IB_QPT_RC:
40821 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
40822 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
40823 struct iw_cm_event cm_event;
40824 int ret = 0;
40825
40826 - atomic_inc(&sw_qps_destroyed);
40827 + atomic_inc_unchecked(&sw_qps_destroyed);
40828 nesqp->destroyed = 1;
40829
40830 /* Blow away the connection if it exists. */
40831 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
40832 index 4a9af79..b993f75 100644
40833 --- a/drivers/infiniband/hw/qib/qib.h
40834 +++ b/drivers/infiniband/hw/qib/qib.h
40835 @@ -52,6 +52,7 @@
40836 #include <linux/kref.h>
40837 #include <linux/sched.h>
40838 #include <linux/kthread.h>
40839 +#include <linux/slab.h>
40840
40841 #include "qib_common.h"
40842 #include "qib_verbs.h"
40843 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
40844 index da739d9..da1c7f4 100644
40845 --- a/drivers/input/gameport/gameport.c
40846 +++ b/drivers/input/gameport/gameport.c
40847 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
40848 */
40849 static void gameport_init_port(struct gameport *gameport)
40850 {
40851 - static atomic_t gameport_no = ATOMIC_INIT(0);
40852 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
40853
40854 __module_get(THIS_MODULE);
40855
40856 mutex_init(&gameport->drv_mutex);
40857 device_initialize(&gameport->dev);
40858 dev_set_name(&gameport->dev, "gameport%lu",
40859 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
40860 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
40861 gameport->dev.bus = &gameport_bus;
40862 gameport->dev.release = gameport_release_port;
40863 if (gameport->parent)
40864 diff --git a/drivers/input/input.c b/drivers/input/input.c
40865 index c044699..174d71a 100644
40866 --- a/drivers/input/input.c
40867 +++ b/drivers/input/input.c
40868 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
40869 */
40870 int input_register_device(struct input_dev *dev)
40871 {
40872 - static atomic_t input_no = ATOMIC_INIT(0);
40873 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
40874 struct input_devres *devres = NULL;
40875 struct input_handler *handler;
40876 unsigned int packet_size;
40877 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
40878 dev->setkeycode = input_default_setkeycode;
40879
40880 dev_set_name(&dev->dev, "input%ld",
40881 - (unsigned long) atomic_inc_return(&input_no) - 1);
40882 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
40883
40884 error = device_add(&dev->dev);
40885 if (error)
40886 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
40887 index 04c69af..5f92d00 100644
40888 --- a/drivers/input/joystick/sidewinder.c
40889 +++ b/drivers/input/joystick/sidewinder.c
40890 @@ -30,6 +30,7 @@
40891 #include <linux/kernel.h>
40892 #include <linux/module.h>
40893 #include <linux/slab.h>
40894 +#include <linux/sched.h>
40895 #include <linux/init.h>
40896 #include <linux/input.h>
40897 #include <linux/gameport.h>
40898 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
40899 index 75e3b10..fb390fd 100644
40900 --- a/drivers/input/joystick/xpad.c
40901 +++ b/drivers/input/joystick/xpad.c
40902 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
40903
40904 static int xpad_led_probe(struct usb_xpad *xpad)
40905 {
40906 - static atomic_t led_seq = ATOMIC_INIT(0);
40907 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
40908 long led_no;
40909 struct xpad_led *led;
40910 struct led_classdev *led_cdev;
40911 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
40912 if (!led)
40913 return -ENOMEM;
40914
40915 - led_no = (long)atomic_inc_return(&led_seq) - 1;
40916 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
40917
40918 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
40919 led->xpad = xpad;
40920 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
40921 index e204f26..8459f15 100644
40922 --- a/drivers/input/misc/ims-pcu.c
40923 +++ b/drivers/input/misc/ims-pcu.c
40924 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
40925
40926 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40927 {
40928 - static atomic_t device_no = ATOMIC_INIT(0);
40929 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
40930
40931 const struct ims_pcu_device_info *info;
40932 u8 device_id;
40933 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
40934 }
40935
40936 /* Device appears to be operable, complete initialization */
40937 - pcu->device_no = atomic_inc_return(&device_no) - 1;
40938 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
40939
40940 error = ims_pcu_setup_backlight(pcu);
40941 if (error)
40942 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
40943 index 2f0b39d..7370f13 100644
40944 --- a/drivers/input/mouse/psmouse.h
40945 +++ b/drivers/input/mouse/psmouse.h
40946 @@ -116,7 +116,7 @@ struct psmouse_attribute {
40947 ssize_t (*set)(struct psmouse *psmouse, void *data,
40948 const char *buf, size_t count);
40949 bool protect;
40950 -};
40951 +} __do_const;
40952 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
40953
40954 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
40955 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
40956 index 4c842c3..590b0bf 100644
40957 --- a/drivers/input/mousedev.c
40958 +++ b/drivers/input/mousedev.c
40959 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
40960
40961 spin_unlock_irq(&client->packet_lock);
40962
40963 - if (copy_to_user(buffer, data, count))
40964 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
40965 return -EFAULT;
40966
40967 return count;
40968 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
40969 index 25fc597..558bf3b3 100644
40970 --- a/drivers/input/serio/serio.c
40971 +++ b/drivers/input/serio/serio.c
40972 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
40973 */
40974 static void serio_init_port(struct serio *serio)
40975 {
40976 - static atomic_t serio_no = ATOMIC_INIT(0);
40977 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
40978
40979 __module_get(THIS_MODULE);
40980
40981 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
40982 mutex_init(&serio->drv_mutex);
40983 device_initialize(&serio->dev);
40984 dev_set_name(&serio->dev, "serio%ld",
40985 - (long)atomic_inc_return(&serio_no) - 1);
40986 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
40987 serio->dev.bus = &serio_bus;
40988 serio->dev.release = serio_release_port;
40989 serio->dev.groups = serio_device_attr_groups;
40990 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
40991 index 59df2e7..8f1cafb 100644
40992 --- a/drivers/input/serio/serio_raw.c
40993 +++ b/drivers/input/serio/serio_raw.c
40994 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
40995
40996 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
40997 {
40998 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
40999 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41000 struct serio_raw *serio_raw;
41001 int err;
41002
41003 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41004 }
41005
41006 snprintf(serio_raw->name, sizeof(serio_raw->name),
41007 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41008 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41009 kref_init(&serio_raw->kref);
41010 INIT_LIST_HEAD(&serio_raw->client_list);
41011 init_waitqueue_head(&serio_raw->wait);
41012 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41013 index fbe9ca7..dbee61d 100644
41014 --- a/drivers/iommu/iommu.c
41015 +++ b/drivers/iommu/iommu.c
41016 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41017 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41018 {
41019 bus_register_notifier(bus, &iommu_bus_nb);
41020 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41021 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41022 }
41023
41024 /**
41025 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41026 index 39f81ae..2660096 100644
41027 --- a/drivers/iommu/irq_remapping.c
41028 +++ b/drivers/iommu/irq_remapping.c
41029 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41030 void panic_if_irq_remap(const char *msg)
41031 {
41032 if (irq_remapping_enabled)
41033 - panic(msg);
41034 + panic("%s", msg);
41035 }
41036
41037 static void ir_ack_apic_edge(struct irq_data *data)
41038 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41039
41040 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41041 {
41042 - chip->irq_print_chip = ir_print_prefix;
41043 - chip->irq_ack = ir_ack_apic_edge;
41044 - chip->irq_eoi = ir_ack_apic_level;
41045 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41046 + pax_open_kernel();
41047 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41048 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41049 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41050 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41051 + pax_close_kernel();
41052 }
41053
41054 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41055 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41056 index ee7c503..5d4ce08 100644
41057 --- a/drivers/irqchip/irq-gic.c
41058 +++ b/drivers/irqchip/irq-gic.c
41059 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41060 * Supported arch specific GIC irq extension.
41061 * Default make them NULL.
41062 */
41063 -struct irq_chip gic_arch_extn = {
41064 +irq_chip_no_const gic_arch_extn = {
41065 .irq_eoi = NULL,
41066 .irq_mask = NULL,
41067 .irq_unmask = NULL,
41068 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41069 chained_irq_exit(chip, desc);
41070 }
41071
41072 -static struct irq_chip gic_chip = {
41073 +static irq_chip_no_const gic_chip __read_only = {
41074 .name = "GIC",
41075 .irq_mask = gic_mask_irq,
41076 .irq_unmask = gic_unmask_irq,
41077 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41078 index ac6f72b..81150f2 100644
41079 --- a/drivers/isdn/capi/capi.c
41080 +++ b/drivers/isdn/capi/capi.c
41081 @@ -81,8 +81,8 @@ struct capiminor {
41082
41083 struct capi20_appl *ap;
41084 u32 ncci;
41085 - atomic_t datahandle;
41086 - atomic_t msgid;
41087 + atomic_unchecked_t datahandle;
41088 + atomic_unchecked_t msgid;
41089
41090 struct tty_port port;
41091 int ttyinstop;
41092 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41093 capimsg_setu16(s, 2, mp->ap->applid);
41094 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41095 capimsg_setu8 (s, 5, CAPI_RESP);
41096 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41097 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41098 capimsg_setu32(s, 8, mp->ncci);
41099 capimsg_setu16(s, 12, datahandle);
41100 }
41101 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41102 mp->outbytes -= len;
41103 spin_unlock_bh(&mp->outlock);
41104
41105 - datahandle = atomic_inc_return(&mp->datahandle);
41106 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41107 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41108 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41109 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41110 capimsg_setu16(skb->data, 2, mp->ap->applid);
41111 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41112 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41113 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41114 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41115 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41116 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41117 capimsg_setu16(skb->data, 16, len); /* Data length */
41118 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41119 index 600c79b..3752bab 100644
41120 --- a/drivers/isdn/gigaset/interface.c
41121 +++ b/drivers/isdn/gigaset/interface.c
41122 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41123 }
41124 tty->driver_data = cs;
41125
41126 - ++cs->port.count;
41127 + atomic_inc(&cs->port.count);
41128
41129 - if (cs->port.count == 1) {
41130 + if (atomic_read(&cs->port.count) == 1) {
41131 tty_port_tty_set(&cs->port, tty);
41132 cs->port.low_latency = 1;
41133 }
41134 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41135
41136 if (!cs->connected)
41137 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41138 - else if (!cs->port.count)
41139 + else if (!atomic_read(&cs->port.count))
41140 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41141 - else if (!--cs->port.count)
41142 + else if (!atomic_dec_return(&cs->port.count))
41143 tty_port_tty_set(&cs->port, NULL);
41144
41145 mutex_unlock(&cs->mutex);
41146 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41147 index d0a41cb..f0cdb8c 100644
41148 --- a/drivers/isdn/gigaset/usb-gigaset.c
41149 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41150 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41151 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41152 memcpy(cs->hw.usb->bchars, buf, 6);
41153 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41154 - 0, 0, &buf, 6, 2000);
41155 + 0, 0, buf, 6, 2000);
41156 }
41157
41158 static void gigaset_freebcshw(struct bc_state *bcs)
41159 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41160 index 4d9b195..455075c 100644
41161 --- a/drivers/isdn/hardware/avm/b1.c
41162 +++ b/drivers/isdn/hardware/avm/b1.c
41163 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41164 }
41165 if (left) {
41166 if (t4file->user) {
41167 - if (copy_from_user(buf, dp, left))
41168 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41169 return -EFAULT;
41170 } else {
41171 memcpy(buf, dp, left);
41172 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41173 }
41174 if (left) {
41175 if (config->user) {
41176 - if (copy_from_user(buf, dp, left))
41177 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41178 return -EFAULT;
41179 } else {
41180 memcpy(buf, dp, left);
41181 diff --git a/drivers/isdn/hisax/amd7930_fn.c b/drivers/isdn/hisax/amd7930_fn.c
41182 index 1063bab..36817e0 100644
41183 --- a/drivers/isdn/hisax/amd7930_fn.c
41184 +++ b/drivers/isdn/hisax/amd7930_fn.c
41185 @@ -314,7 +314,7 @@ Amd7930_empty_Dfifo(struct IsdnCardState *cs, int flag)
41186
41187 t += sprintf(t, "Amd7930: empty_Dfifo cnt: %d |", cs->rcvidx);
41188 QuickHex(t, cs->rcvbuf, cs->rcvidx);
41189 - debugl1(cs, cs->dlog);
41190 + debugl1(cs, "%s", cs->dlog);
41191 }
41192 /* moves received data in sk-buffer */
41193 memcpy(skb_put(skb, cs->rcvidx), cs->rcvbuf, cs->rcvidx);
41194 @@ -406,7 +406,7 @@ Amd7930_fill_Dfifo(struct IsdnCardState *cs)
41195
41196 t += sprintf(t, "Amd7930: fill_Dfifo cnt: %d |", count);
41197 QuickHex(t, deb_ptr, count);
41198 - debugl1(cs, cs->dlog);
41199 + debugl1(cs, "%s", cs->dlog);
41200 }
41201 /* AMD interrupts on */
41202 AmdIrqOn(cs);
41203 diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c
41204 index ee9b9a0..d1427bd 100644
41205 --- a/drivers/isdn/hisax/avm_pci.c
41206 +++ b/drivers/isdn/hisax/avm_pci.c
41207 @@ -285,7 +285,7 @@ hdlc_empty_fifo(struct BCState *bcs, int count)
41208 t += sprintf(t, "hdlc_empty_fifo %c cnt %d",
41209 bcs->channel ? 'B' : 'A', count);
41210 QuickHex(t, p, count);
41211 - debugl1(cs, bcs->blog);
41212 + debugl1(cs, "%s", bcs->blog);
41213 }
41214 }
41215
41216 @@ -345,7 +345,7 @@ hdlc_fill_fifo(struct BCState *bcs)
41217 t += sprintf(t, "hdlc_fill_fifo %c cnt %d",
41218 bcs->channel ? 'B' : 'A', count);
41219 QuickHex(t, p, count);
41220 - debugl1(cs, bcs->blog);
41221 + debugl1(cs, "%s", bcs->blog);
41222 }
41223 }
41224
41225 diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
41226 index bf04d2a..b33f53b 100644
41227 --- a/drivers/isdn/hisax/config.c
41228 +++ b/drivers/isdn/hisax/config.c
41229 @@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if)
41230 ptr--;
41231 *ptr++ = '\n';
41232 *ptr = 0;
41233 - HiSax_putstatus(cs, NULL, cs->dlog);
41234 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41235 } else
41236 HiSax_putstatus(cs, "LogEcho: ",
41237 "warning Frame too big (%d)",
41238 diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c
41239 index 8d0cf6e..4fc90de 100644
41240 --- a/drivers/isdn/hisax/diva.c
41241 +++ b/drivers/isdn/hisax/diva.c
41242 @@ -427,7 +427,7 @@ Memhscx_empty_fifo(struct BCState *bcs, int count)
41243 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41244 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41245 QuickHex(t, ptr, count);
41246 - debugl1(cs, bcs->blog);
41247 + debugl1(cs, "%s", bcs->blog);
41248 }
41249 }
41250
41251 @@ -469,7 +469,7 @@ Memhscx_fill_fifo(struct BCState *bcs)
41252 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41253 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41254 QuickHex(t, ptr, count);
41255 - debugl1(cs, bcs->blog);
41256 + debugl1(cs, "%s", bcs->blog);
41257 }
41258 }
41259
41260 diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
41261 index 1df6f9a..2be1c8a 100644
41262 --- a/drivers/isdn/hisax/elsa.c
41263 +++ b/drivers/isdn/hisax/elsa.c
41264 @@ -535,7 +535,7 @@ check_arcofi(struct IsdnCardState *cs)
41265 t = tmp;
41266 t += sprintf(tmp, "Arcofi data");
41267 QuickHex(t, p, cs->dc.isac.mon_rxp);
41268 - debugl1(cs, tmp);
41269 + debugl1(cs, "%s", tmp);
41270 if ((cs->dc.isac.mon_rxp == 2) && (cs->dc.isac.mon_rx[0] == 0xa0)) {
41271 switch (cs->dc.isac.mon_rx[1]) {
41272 case 0x80:
41273 diff --git a/drivers/isdn/hisax/elsa_ser.c b/drivers/isdn/hisax/elsa_ser.c
41274 index d4c98d3..3f84dd8 100644
41275 --- a/drivers/isdn/hisax/elsa_ser.c
41276 +++ b/drivers/isdn/hisax/elsa_ser.c
41277 @@ -344,7 +344,7 @@ static inline void receive_chars(struct IsdnCardState *cs,
41278
41279 t += sprintf(t, "modem read cnt %d", cs->hw.elsa.rcvcnt);
41280 QuickHex(t, cs->hw.elsa.rcvbuf, cs->hw.elsa.rcvcnt);
41281 - debugl1(cs, tmp);
41282 + debugl1(cs, "%s", tmp);
41283 }
41284 cs->hw.elsa.rcvcnt = 0;
41285 }
41286 diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c
41287 index 3ccd724..497bd02 100644
41288 --- a/drivers/isdn/hisax/hfc_pci.c
41289 +++ b/drivers/isdn/hisax/hfc_pci.c
41290 @@ -901,7 +901,7 @@ Begin:
41291 ptr--;
41292 *ptr++ = '\n';
41293 *ptr = 0;
41294 - HiSax_putstatus(cs, NULL, cs->dlog);
41295 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41296 } else
41297 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
41298 }
41299 diff --git a/drivers/isdn/hisax/hfc_sx.c b/drivers/isdn/hisax/hfc_sx.c
41300 index dc4574f..fa1fefd 100644
41301 --- a/drivers/isdn/hisax/hfc_sx.c
41302 +++ b/drivers/isdn/hisax/hfc_sx.c
41303 @@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs)
41304 ptr--;
41305 *ptr++ = '\n';
41306 *ptr = 0;
41307 - HiSax_putstatus(cs, NULL, cs->dlog);
41308 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41309 } else
41310 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
41311 }
41312 diff --git a/drivers/isdn/hisax/hscx_irq.c b/drivers/isdn/hisax/hscx_irq.c
41313 index f398d48..a8d6188 100644
41314 --- a/drivers/isdn/hisax/hscx_irq.c
41315 +++ b/drivers/isdn/hisax/hscx_irq.c
41316 @@ -75,7 +75,7 @@ hscx_empty_fifo(struct BCState *bcs, int count)
41317 t += sprintf(t, "hscx_empty_fifo %c cnt %d",
41318 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41319 QuickHex(t, ptr, count);
41320 - debugl1(cs, bcs->blog);
41321 + debugl1(cs, "%s", bcs->blog);
41322 }
41323 }
41324
41325 @@ -115,7 +115,7 @@ hscx_fill_fifo(struct BCState *bcs)
41326 t += sprintf(t, "hscx_fill_fifo %c cnt %d",
41327 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41328 QuickHex(t, ptr, count);
41329 - debugl1(cs, bcs->blog);
41330 + debugl1(cs, "%s", bcs->blog);
41331 }
41332 }
41333
41334 diff --git a/drivers/isdn/hisax/icc.c b/drivers/isdn/hisax/icc.c
41335 index db5321f..51dae91 100644
41336 --- a/drivers/isdn/hisax/icc.c
41337 +++ b/drivers/isdn/hisax/icc.c
41338 @@ -134,7 +134,7 @@ icc_empty_fifo(struct IsdnCardState *cs, int count)
41339
41340 t += sprintf(t, "icc_empty_fifo cnt %d", count);
41341 QuickHex(t, ptr, count);
41342 - debugl1(cs, cs->dlog);
41343 + debugl1(cs, "%s", cs->dlog);
41344 }
41345 }
41346
41347 @@ -176,7 +176,7 @@ icc_fill_fifo(struct IsdnCardState *cs)
41348
41349 t += sprintf(t, "icc_fill_fifo cnt %d", count);
41350 QuickHex(t, ptr, count);
41351 - debugl1(cs, cs->dlog);
41352 + debugl1(cs, "%s", cs->dlog);
41353 }
41354 }
41355
41356 diff --git a/drivers/isdn/hisax/ipacx.c b/drivers/isdn/hisax/ipacx.c
41357 index 74feb5c..5faa5de 100644
41358 --- a/drivers/isdn/hisax/ipacx.c
41359 +++ b/drivers/isdn/hisax/ipacx.c
41360 @@ -260,7 +260,7 @@ dch_empty_fifo(struct IsdnCardState *cs, int count)
41361
41362 t += sprintf(t, "dch_empty_fifo() cnt %d", count);
41363 QuickHex(t, ptr, count);
41364 - debugl1(cs, cs->dlog);
41365 + debugl1(cs, "%s", cs->dlog);
41366 }
41367 }
41368
41369 @@ -307,7 +307,7 @@ dch_fill_fifo(struct IsdnCardState *cs)
41370
41371 t += sprintf(t, "dch_fill_fifo() cnt %d", count);
41372 QuickHex(t, ptr, count);
41373 - debugl1(cs, cs->dlog);
41374 + debugl1(cs, "%s", cs->dlog);
41375 }
41376 }
41377
41378 @@ -539,7 +539,7 @@ bch_empty_fifo(struct BCState *bcs, int count)
41379
41380 t += sprintf(t, "bch_empty_fifo() B-%d cnt %d", hscx, count);
41381 QuickHex(t, ptr, count);
41382 - debugl1(cs, bcs->blog);
41383 + debugl1(cs, "%s", bcs->blog);
41384 }
41385 }
41386
41387 @@ -582,7 +582,7 @@ bch_fill_fifo(struct BCState *bcs)
41388
41389 t += sprintf(t, "chb_fill_fifo() B-%d cnt %d", hscx, count);
41390 QuickHex(t, ptr, count);
41391 - debugl1(cs, bcs->blog);
41392 + debugl1(cs, "%s", bcs->blog);
41393 }
41394 }
41395
41396 diff --git a/drivers/isdn/hisax/isac.c b/drivers/isdn/hisax/isac.c
41397 index a365ccc..7fdf78f 100644
41398 --- a/drivers/isdn/hisax/isac.c
41399 +++ b/drivers/isdn/hisax/isac.c
41400 @@ -137,7 +137,7 @@ isac_empty_fifo(struct IsdnCardState *cs, int count)
41401
41402 t += sprintf(t, "isac_empty_fifo cnt %d", count);
41403 QuickHex(t, ptr, count);
41404 - debugl1(cs, cs->dlog);
41405 + debugl1(cs, "%s", cs->dlog);
41406 }
41407 }
41408
41409 @@ -179,7 +179,7 @@ isac_fill_fifo(struct IsdnCardState *cs)
41410
41411 t += sprintf(t, "isac_fill_fifo cnt %d", count);
41412 QuickHex(t, ptr, count);
41413 - debugl1(cs, cs->dlog);
41414 + debugl1(cs, "%s", cs->dlog);
41415 }
41416 }
41417
41418 diff --git a/drivers/isdn/hisax/isar.c b/drivers/isdn/hisax/isar.c
41419 index 7fdf347..f4956c7 100644
41420 --- a/drivers/isdn/hisax/isar.c
41421 +++ b/drivers/isdn/hisax/isar.c
41422 @@ -74,7 +74,7 @@ sendmsg(struct IsdnCardState *cs, u_char his, u_char creg, u_char len,
41423 t = tmp;
41424 t += sprintf(t, "sendmbox cnt %d", len);
41425 QuickHex(t, &msg[len-i], (i > 64) ? 64 : i);
41426 - debugl1(cs, tmp);
41427 + debugl1(cs, "%s", tmp);
41428 i -= 64;
41429 }
41430 }
41431 @@ -105,7 +105,7 @@ rcv_mbox(struct IsdnCardState *cs, struct isar_reg *ireg, u_char *msg)
41432 t = tmp;
41433 t += sprintf(t, "rcv_mbox cnt %d", ireg->clsb);
41434 QuickHex(t, &msg[ireg->clsb - i], (i > 64) ? 64 : i);
41435 - debugl1(cs, tmp);
41436 + debugl1(cs, "%s", tmp);
41437 i -= 64;
41438 }
41439 }
41440 @@ -1248,7 +1248,7 @@ isar_int_main(struct IsdnCardState *cs)
41441 tp += sprintf(debbuf, "msg iis(%x) msb(%x)",
41442 ireg->iis, ireg->cmsb);
41443 QuickHex(tp, (u_char *)ireg->par, ireg->clsb);
41444 - debugl1(cs, debbuf);
41445 + debugl1(cs, "%s", debbuf);
41446 }
41447 break;
41448 case ISAR_IIS_INVMSG:
41449 diff --git a/drivers/isdn/hisax/jade.c b/drivers/isdn/hisax/jade.c
41450 index f946c58..e2ae787 100644
41451 --- a/drivers/isdn/hisax/jade.c
41452 +++ b/drivers/isdn/hisax/jade.c
41453 @@ -81,10 +81,7 @@ modejade(struct BCState *bcs, int mode, int bc)
41454 int jade = bcs->hw.hscx.hscx;
41455
41456 if (cs->debug & L1_DEB_HSCX) {
41457 - char tmp[40];
41458 - sprintf(tmp, "jade %c mode %d ichan %d",
41459 - 'A' + jade, mode, bc);
41460 - debugl1(cs, tmp);
41461 + debugl1(cs, "jade %c mode %d ichan %d", 'A' + jade, mode, bc);
41462 }
41463 bcs->mode = mode;
41464 bcs->channel = bc;
41465 @@ -257,23 +254,18 @@ void
41466 clear_pending_jade_ints(struct IsdnCardState *cs)
41467 {
41468 int val;
41469 - char tmp[64];
41470
41471 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0x00);
41472 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0x00);
41473
41474 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_ISR);
41475 - sprintf(tmp, "jade B ISTA %x", val);
41476 - debugl1(cs, tmp);
41477 + debugl1(cs, "jade B ISTA %x", val);
41478 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_ISR);
41479 - sprintf(tmp, "jade A ISTA %x", val);
41480 - debugl1(cs, tmp);
41481 + debugl1(cs, "jade A ISTA %x", val);
41482 val = cs->BC_Read_Reg(cs, 1, jade_HDLC_STAR);
41483 - sprintf(tmp, "jade B STAR %x", val);
41484 - debugl1(cs, tmp);
41485 + debugl1(cs, "jade B STAR %x", val);
41486 val = cs->BC_Read_Reg(cs, 0, jade_HDLC_STAR);
41487 - sprintf(tmp, "jade A STAR %x", val);
41488 - debugl1(cs, tmp);
41489 + debugl1(cs, "jade A STAR %x", val);
41490 /* Unmask ints */
41491 cs->BC_Write_Reg(cs, 0, jade_HDLC_IMR, 0xF8);
41492 cs->BC_Write_Reg(cs, 1, jade_HDLC_IMR, 0xF8);
41493 diff --git a/drivers/isdn/hisax/jade_irq.c b/drivers/isdn/hisax/jade_irq.c
41494 index f521fc8..b930da9 100644
41495 --- a/drivers/isdn/hisax/jade_irq.c
41496 +++ b/drivers/isdn/hisax/jade_irq.c
41497 @@ -65,7 +65,7 @@ jade_empty_fifo(struct BCState *bcs, int count)
41498 t += sprintf(t, "jade_empty_fifo %c cnt %d",
41499 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41500 QuickHex(t, ptr, count);
41501 - debugl1(cs, bcs->blog);
41502 + debugl1(cs, "%s", bcs->blog);
41503 }
41504 }
41505
41506 @@ -105,7 +105,7 @@ jade_fill_fifo(struct BCState *bcs)
41507 t += sprintf(t, "jade_fill_fifo %c cnt %d",
41508 bcs->hw.hscx.hscx ? 'B' : 'A', count);
41509 QuickHex(t, ptr, count);
41510 - debugl1(cs, bcs->blog);
41511 + debugl1(cs, "%s", bcs->blog);
41512 }
41513 }
41514
41515 diff --git a/drivers/isdn/hisax/l3_1tr6.c b/drivers/isdn/hisax/l3_1tr6.c
41516 index 4c1bca5..875402e 100644
41517 --- a/drivers/isdn/hisax/l3_1tr6.c
41518 +++ b/drivers/isdn/hisax/l3_1tr6.c
41519 @@ -63,7 +63,7 @@ l3_1tr6_error(struct l3_process *pc, u_char *msg, struct sk_buff *skb)
41520 {
41521 dev_kfree_skb(skb);
41522 if (pc->st->l3.debug & L3_DEB_WARN)
41523 - l3_debug(pc->st, msg);
41524 + l3_debug(pc->st, "%s", msg);
41525 l3_1tr6_release_req(pc, 0, NULL);
41526 }
41527
41528 @@ -161,7 +161,6 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41529 {
41530 u_char *p;
41531 int bcfound = 0;
41532 - char tmp[80];
41533 struct sk_buff *skb = arg;
41534
41535 /* Channel Identification */
41536 @@ -214,10 +213,9 @@ l3_1tr6_setup(struct l3_process *pc, u_char pr, void *arg)
41537 /* Signal all services, linklevel takes care of Service-Indicator */
41538 if (bcfound) {
41539 if ((pc->para.setup.si1 != 7) && (pc->st->l3.debug & L3_DEB_WARN)) {
41540 - sprintf(tmp, "non-digital call: %s -> %s",
41541 + l3_debug(pc->st, "non-digital call: %s -> %s",
41542 pc->para.setup.phone,
41543 pc->para.setup.eazmsn);
41544 - l3_debug(pc->st, tmp);
41545 }
41546 newl3state(pc, 6);
41547 pc->st->l3.l3l4(pc->st, CC_SETUP | INDICATION, pc);
41548 @@ -301,7 +299,7 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41549 {
41550 u_char *p;
41551 int i, tmpcharge = 0;
41552 - char a_charge[8], tmp[32];
41553 + char a_charge[8];
41554 struct sk_buff *skb = arg;
41555
41556 p = skb->data;
41557 @@ -316,8 +314,8 @@ l3_1tr6_info(struct l3_process *pc, u_char pr, void *arg)
41558 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41559 }
41560 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41561 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41562 - l3_debug(pc->st, tmp);
41563 + l3_debug(pc->st, "charging info %d",
41564 + pc->para.chargeinfo);
41565 }
41566 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41567 l3_debug(pc->st, "charging info not found");
41568 @@ -399,7 +397,7 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41569 struct sk_buff *skb = arg;
41570 u_char *p;
41571 int i, tmpcharge = 0;
41572 - char a_charge[8], tmp[32];
41573 + char a_charge[8];
41574
41575 StopAllL3Timer(pc);
41576 p = skb->data;
41577 @@ -414,8 +412,8 @@ l3_1tr6_disc(struct l3_process *pc, u_char pr, void *arg)
41578 pc->st->l3.l3l4(pc->st, CC_CHARGE | INDICATION, pc);
41579 }
41580 if (pc->st->l3.debug & L3_DEB_CHARGE) {
41581 - sprintf(tmp, "charging info %d", pc->para.chargeinfo);
41582 - l3_debug(pc->st, tmp);
41583 + l3_debug(pc->st, "charging info %d",
41584 + pc->para.chargeinfo);
41585 }
41586 } else if (pc->st->l3.debug & L3_DEB_CHARGE)
41587 l3_debug(pc->st, "charging info not found");
41588 @@ -746,7 +744,6 @@ up1tr6(struct PStack *st, int pr, void *arg)
41589 int i, mt, cr;
41590 struct l3_process *proc;
41591 struct sk_buff *skb = arg;
41592 - char tmp[80];
41593
41594 switch (pr) {
41595 case (DL_DATA | INDICATION):
41596 @@ -762,26 +759,23 @@ up1tr6(struct PStack *st, int pr, void *arg)
41597 }
41598 if (skb->len < 4) {
41599 if (st->l3.debug & L3_DEB_PROTERR) {
41600 - sprintf(tmp, "up1tr6 len only %d", skb->len);
41601 - l3_debug(st, tmp);
41602 + l3_debug(st, "up1tr6 len only %d", skb->len);
41603 }
41604 dev_kfree_skb(skb);
41605 return;
41606 }
41607 if ((skb->data[0] & 0xfe) != PROTO_DIS_N0) {
41608 if (st->l3.debug & L3_DEB_PROTERR) {
41609 - sprintf(tmp, "up1tr6%sunexpected discriminator %x message len %d",
41610 + l3_debug(st, "up1tr6%sunexpected discriminator %x message len %d",
41611 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41612 skb->data[0], skb->len);
41613 - l3_debug(st, tmp);
41614 }
41615 dev_kfree_skb(skb);
41616 return;
41617 }
41618 if (skb->data[1] != 1) {
41619 if (st->l3.debug & L3_DEB_PROTERR) {
41620 - sprintf(tmp, "up1tr6 CR len not 1");
41621 - l3_debug(st, tmp);
41622 + l3_debug(st, "up1tr6 CR len not 1");
41623 }
41624 dev_kfree_skb(skb);
41625 return;
41626 @@ -791,9 +785,8 @@ up1tr6(struct PStack *st, int pr, void *arg)
41627 if (skb->data[0] == PROTO_DIS_N0) {
41628 dev_kfree_skb(skb);
41629 if (st->l3.debug & L3_DEB_STATE) {
41630 - sprintf(tmp, "up1tr6%s N0 mt %x unhandled",
41631 + l3_debug(st, "up1tr6%s N0 mt %x unhandled",
41632 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ", mt);
41633 - l3_debug(st, tmp);
41634 }
41635 } else if (skb->data[0] == PROTO_DIS_N1) {
41636 if (!(proc = getl3proc(st, cr))) {
41637 @@ -801,8 +794,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41638 if (cr < 128) {
41639 if (!(proc = new_l3_process(st, cr))) {
41640 if (st->l3.debug & L3_DEB_PROTERR) {
41641 - sprintf(tmp, "up1tr6 no roc mem");
41642 - l3_debug(st, tmp);
41643 + l3_debug(st, "up1tr6 no roc mem");
41644 }
41645 dev_kfree_skb(skb);
41646 return;
41647 @@ -821,8 +813,7 @@ up1tr6(struct PStack *st, int pr, void *arg)
41648 } else {
41649 if (!(proc = new_l3_process(st, cr))) {
41650 if (st->l3.debug & L3_DEB_PROTERR) {
41651 - sprintf(tmp, "up1tr6 no roc mem");
41652 - l3_debug(st, tmp);
41653 + l3_debug(st, "up1tr6 no roc mem");
41654 }
41655 dev_kfree_skb(skb);
41656 return;
41657 @@ -837,18 +828,16 @@ up1tr6(struct PStack *st, int pr, void *arg)
41658 if (i == ARRAY_SIZE(datastln1)) {
41659 dev_kfree_skb(skb);
41660 if (st->l3.debug & L3_DEB_STATE) {
41661 - sprintf(tmp, "up1tr6%sstate %d mt %x unhandled",
41662 + l3_debug(st, "up1tr6%sstate %d mt %x unhandled",
41663 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41664 proc->state, mt);
41665 - l3_debug(st, tmp);
41666 }
41667 return;
41668 } else {
41669 if (st->l3.debug & L3_DEB_STATE) {
41670 - sprintf(tmp, "up1tr6%sstate %d mt %x",
41671 + l3_debug(st, "up1tr6%sstate %d mt %x",
41672 (pr == (DL_DATA | INDICATION)) ? " " : "(broadcast) ",
41673 proc->state, mt);
41674 - l3_debug(st, tmp);
41675 }
41676 datastln1[i].rout(proc, pr, skb);
41677 }
41678 @@ -861,7 +850,6 @@ down1tr6(struct PStack *st, int pr, void *arg)
41679 int i, cr;
41680 struct l3_process *proc;
41681 struct Channel *chan;
41682 - char tmp[80];
41683
41684 if ((DL_ESTABLISH | REQUEST) == pr) {
41685 l3_msg(st, pr, NULL);
41686 @@ -888,15 +876,13 @@ down1tr6(struct PStack *st, int pr, void *arg)
41687 break;
41688 if (i == ARRAY_SIZE(downstl)) {
41689 if (st->l3.debug & L3_DEB_STATE) {
41690 - sprintf(tmp, "down1tr6 state %d prim %d unhandled",
41691 + l3_debug(st, "down1tr6 state %d prim %d unhandled",
41692 proc->state, pr);
41693 - l3_debug(st, tmp);
41694 }
41695 } else {
41696 if (st->l3.debug & L3_DEB_STATE) {
41697 - sprintf(tmp, "down1tr6 state %d prim %d",
41698 + l3_debug(st, "down1tr6 state %d prim %d",
41699 proc->state, pr);
41700 - l3_debug(st, tmp);
41701 }
41702 downstl[i].rout(proc, pr, arg);
41703 }
41704 diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c
41705 index b646eed..233e432 100644
41706 --- a/drivers/isdn/hisax/netjet.c
41707 +++ b/drivers/isdn/hisax/netjet.c
41708 @@ -176,7 +176,7 @@ static void printframe(struct IsdnCardState *cs, u_char *buf, int count, char *s
41709 else
41710 j = i;
41711 QuickHex(t, p, j);
41712 - debugl1(cs, tmp);
41713 + debugl1(cs, "%s", tmp);
41714 p += j;
41715 i -= j;
41716 t = tmp;
41717 diff --git a/drivers/isdn/hisax/q931.c b/drivers/isdn/hisax/q931.c
41718 index 041bf52..af1b020 100644
41719 --- a/drivers/isdn/hisax/q931.c
41720 +++ b/drivers/isdn/hisax/q931.c
41721 @@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size)
41722 dp--;
41723 *dp++ = '\n';
41724 *dp = 0;
41725 - HiSax_putstatus(cs, NULL, cs->dlog);
41726 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41727 } else
41728 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
41729 }
41730 @@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41731 }
41732 if (finish) {
41733 *dp = 0;
41734 - HiSax_putstatus(cs, NULL, cs->dlog);
41735 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41736 return;
41737 }
41738 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
41739 @@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir)
41740 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
41741 }
41742 *dp = 0;
41743 - HiSax_putstatus(cs, NULL, cs->dlog);
41744 + HiSax_putstatus(cs, NULL, "%s", cs->dlog);
41745 }
41746 diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c
41747 index d8cac69..a858955 100644
41748 --- a/drivers/isdn/hisax/w6692.c
41749 +++ b/drivers/isdn/hisax/w6692.c
41750 @@ -154,7 +154,7 @@ W6692_empty_fifo(struct IsdnCardState *cs, int count)
41751
41752 t += sprintf(t, "W6692_empty_fifo cnt %d", count);
41753 QuickHex(t, ptr, count);
41754 - debugl1(cs, cs->dlog);
41755 + debugl1(cs, "%s", cs->dlog);
41756 }
41757 }
41758
41759 @@ -196,7 +196,7 @@ W6692_fill_fifo(struct IsdnCardState *cs)
41760
41761 t += sprintf(t, "W6692_fill_fifo cnt %d", count);
41762 QuickHex(t, ptr, count);
41763 - debugl1(cs, cs->dlog);
41764 + debugl1(cs, "%s", cs->dlog);
41765 }
41766 }
41767
41768 @@ -226,7 +226,7 @@ W6692B_empty_fifo(struct BCState *bcs, int count)
41769 t += sprintf(t, "W6692B_empty_fifo %c cnt %d",
41770 bcs->channel + '1', count);
41771 QuickHex(t, ptr, count);
41772 - debugl1(cs, bcs->blog);
41773 + debugl1(cs, "%s", bcs->blog);
41774 }
41775 }
41776
41777 @@ -264,7 +264,7 @@ W6692B_fill_fifo(struct BCState *bcs)
41778 t += sprintf(t, "W6692B_fill_fifo %c cnt %d",
41779 bcs->channel + '1', count);
41780 QuickHex(t, ptr, count);
41781 - debugl1(cs, bcs->blog);
41782 + debugl1(cs, "%s", bcs->blog);
41783 }
41784 }
41785
41786 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41787 index 9bb12ba..d4262f7 100644
41788 --- a/drivers/isdn/i4l/isdn_common.c
41789 +++ b/drivers/isdn/i4l/isdn_common.c
41790 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41791 } else
41792 return -EINVAL;
41793 case IIOCDBGVAR:
41794 + if (!capable(CAP_SYS_RAWIO))
41795 + return -EPERM;
41796 if (arg) {
41797 if (copy_to_user(argp, &dev, sizeof(ulong)))
41798 return -EFAULT;
41799 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41800 index 3c5f249..5fac4d0 100644
41801 --- a/drivers/isdn/i4l/isdn_tty.c
41802 +++ b/drivers/isdn/i4l/isdn_tty.c
41803 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41804
41805 #ifdef ISDN_DEBUG_MODEM_OPEN
41806 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41807 - port->count);
41808 + atomic_read(&port->count));
41809 #endif
41810 - port->count++;
41811 + atomic_inc(&port->count);
41812 port->tty = tty;
41813 /*
41814 * Start up serial port
41815 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41816 #endif
41817 return;
41818 }
41819 - if ((tty->count == 1) && (port->count != 1)) {
41820 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41821 /*
41822 * Uh, oh. tty->count is 1, which means that the tty
41823 * structure will be freed. Info->count should always
41824 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41825 * serial port won't be shutdown.
41826 */
41827 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41828 - "info->count is %d\n", port->count);
41829 - port->count = 1;
41830 + "info->count is %d\n", atomic_read(&port->count));
41831 + atomic_set(&port->count, 1);
41832 }
41833 - if (--port->count < 0) {
41834 + if (atomic_dec_return(&port->count) < 0) {
41835 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41836 - info->line, port->count);
41837 - port->count = 0;
41838 + info->line, atomic_read(&port->count));
41839 + atomic_set(&port->count, 0);
41840 }
41841 - if (port->count) {
41842 + if (atomic_read(&port->count)) {
41843 #ifdef ISDN_DEBUG_MODEM_OPEN
41844 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41845 #endif
41846 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41847 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41848 return;
41849 isdn_tty_shutdown(info);
41850 - port->count = 0;
41851 + atomic_set(&port->count, 0);
41852 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41853 port->tty = NULL;
41854 wake_up_interruptible(&port->open_wait);
41855 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41856 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41857 modem_info *info = &dev->mdm.info[i];
41858
41859 - if (info->port.count == 0)
41860 + if (atomic_read(&info->port.count) == 0)
41861 continue;
41862 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41863 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41864 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41865 index e74df7c..03a03ba 100644
41866 --- a/drivers/isdn/icn/icn.c
41867 +++ b/drivers/isdn/icn/icn.c
41868 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41869 if (count > len)
41870 count = len;
41871 if (user) {
41872 - if (copy_from_user(msg, buf, count))
41873 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41874 return -EFAULT;
41875 } else
41876 memcpy(msg, buf, count);
41877 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41878 index 6a8405d..0bd1c7e 100644
41879 --- a/drivers/leds/leds-clevo-mail.c
41880 +++ b/drivers/leds/leds-clevo-mail.c
41881 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41882 * detected as working, but in reality it is not) as low as
41883 * possible.
41884 */
41885 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
41886 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
41887 {
41888 .callback = clevo_mail_led_dmi_callback,
41889 .ident = "Clevo D410J",
41890 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41891 index 64e204e..c6bf189 100644
41892 --- a/drivers/leds/leds-ss4200.c
41893 +++ b/drivers/leds/leds-ss4200.c
41894 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41895 * detected as working, but in reality it is not) as low as
41896 * possible.
41897 */
41898 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
41899 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
41900 {
41901 .callback = ss4200_led_dmi_callback,
41902 .ident = "Intel SS4200-E",
41903 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41904 index 0bf1e4e..b4bf44e 100644
41905 --- a/drivers/lguest/core.c
41906 +++ b/drivers/lguest/core.c
41907 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41908 * The end address needs +1 because __get_vm_area allocates an
41909 * extra guard page, so we need space for that.
41910 */
41911 +
41912 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41913 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41914 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41915 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41916 +#else
41917 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41918 VM_ALLOC, switcher_addr, switcher_addr
41919 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41920 +#endif
41921 +
41922 if (!switcher_vma) {
41923 err = -ENOMEM;
41924 printk("lguest: could not map switcher pages high\n");
41925 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41926 * Now the Switcher is mapped at the right address, we can't fail!
41927 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41928 */
41929 - memcpy(switcher_vma->addr, start_switcher_text,
41930 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
41931 end_switcher_text - start_switcher_text);
41932
41933 printk(KERN_INFO "lguest: mapped switcher at %p\n",
41934 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
41935 index a35d8d1..59fb772 100644
41936 --- a/drivers/lguest/page_tables.c
41937 +++ b/drivers/lguest/page_tables.c
41938 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
41939 /*:*/
41940
41941 #ifdef CONFIG_X86_PAE
41942 -static void release_pmd(pmd_t *spmd)
41943 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
41944 {
41945 /* If the entry's not present, there's nothing to release. */
41946 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
41947 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
41948 index 5169239..47cb4db 100644
41949 --- a/drivers/lguest/x86/core.c
41950 +++ b/drivers/lguest/x86/core.c
41951 @@ -59,7 +59,7 @@ static struct {
41952 /* Offset from where switcher.S was compiled to where we've copied it */
41953 static unsigned long switcher_offset(void)
41954 {
41955 - return switcher_addr - (unsigned long)start_switcher_text;
41956 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
41957 }
41958
41959 /* This cpu's struct lguest_pages (after the Switcher text page) */
41960 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
41961 * These copies are pretty cheap, so we do them unconditionally: */
41962 /* Save the current Host top-level page directory.
41963 */
41964 +
41965 +#ifdef CONFIG_PAX_PER_CPU_PGD
41966 + pages->state.host_cr3 = read_cr3();
41967 +#else
41968 pages->state.host_cr3 = __pa(current->mm->pgd);
41969 +#endif
41970 +
41971 /*
41972 * Set up the Guest's page tables to see this CPU's pages (and no
41973 * other CPU's pages).
41974 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
41975 * compiled-in switcher code and the high-mapped copy we just made.
41976 */
41977 for (i = 0; i < IDT_ENTRIES; i++)
41978 - default_idt_entries[i] += switcher_offset();
41979 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
41980
41981 /*
41982 * Set up the Switcher's per-cpu areas.
41983 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
41984 * it will be undisturbed when we switch. To change %cs and jump we
41985 * need this structure to feed to Intel's "lcall" instruction.
41986 */
41987 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
41988 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
41989 lguest_entry.segment = LGUEST_CS;
41990
41991 /*
41992 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
41993 index 40634b0..4f5855e 100644
41994 --- a/drivers/lguest/x86/switcher_32.S
41995 +++ b/drivers/lguest/x86/switcher_32.S
41996 @@ -87,6 +87,7 @@
41997 #include <asm/page.h>
41998 #include <asm/segment.h>
41999 #include <asm/lguest.h>
42000 +#include <asm/processor-flags.h>
42001
42002 // We mark the start of the code to copy
42003 // It's placed in .text tho it's never run here
42004 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42005 // Changes type when we load it: damn Intel!
42006 // For after we switch over our page tables
42007 // That entry will be read-only: we'd crash.
42008 +
42009 +#ifdef CONFIG_PAX_KERNEXEC
42010 + mov %cr0, %edx
42011 + xor $X86_CR0_WP, %edx
42012 + mov %edx, %cr0
42013 +#endif
42014 +
42015 movl $(GDT_ENTRY_TSS*8), %edx
42016 ltr %dx
42017
42018 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42019 // Let's clear it again for our return.
42020 // The GDT descriptor of the Host
42021 // Points to the table after two "size" bytes
42022 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42023 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42024 // Clear "used" from type field (byte 5, bit 2)
42025 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42026 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42027 +
42028 +#ifdef CONFIG_PAX_KERNEXEC
42029 + mov %cr0, %eax
42030 + xor $X86_CR0_WP, %eax
42031 + mov %eax, %cr0
42032 +#endif
42033
42034 // Once our page table's switched, the Guest is live!
42035 // The Host fades as we run this final step.
42036 @@ -295,13 +309,12 @@ deliver_to_host:
42037 // I consulted gcc, and it gave
42038 // These instructions, which I gladly credit:
42039 leal (%edx,%ebx,8), %eax
42040 - movzwl (%eax),%edx
42041 - movl 4(%eax), %eax
42042 - xorw %ax, %ax
42043 - orl %eax, %edx
42044 + movl 4(%eax), %edx
42045 + movw (%eax), %dx
42046 // Now the address of the handler's in %edx
42047 // We call it now: its "iret" drops us home.
42048 - jmp *%edx
42049 + ljmp $__KERNEL_CS, $1f
42050 +1: jmp *%edx
42051
42052 // Every interrupt can come to us here
42053 // But we must truly tell each apart.
42054 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42055 index 0003992..854bbce 100644
42056 --- a/drivers/md/bcache/closure.h
42057 +++ b/drivers/md/bcache/closure.h
42058 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42059 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42060 struct workqueue_struct *wq)
42061 {
42062 - BUG_ON(object_is_on_stack(cl));
42063 + BUG_ON(object_starts_on_stack(cl));
42064 closure_set_ip(cl);
42065 cl->fn = fn;
42066 cl->wq = wq;
42067 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42068 index 547c4c5..5be1de4 100644
42069 --- a/drivers/md/bcache/super.c
42070 +++ b/drivers/md/bcache/super.c
42071 @@ -1644,7 +1644,7 @@ err_unlock_gc:
42072 err:
42073 closure_sync(&op.cl);
42074 /* XXX: test this, it's broken */
42075 - bch_cache_set_error(c, err);
42076 + bch_cache_set_error(c, "%s", err);
42077 }
42078
42079 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42080 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42081 index a7fd821..9dcf6c3 100644
42082 --- a/drivers/md/bitmap.c
42083 +++ b/drivers/md/bitmap.c
42084 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42085 chunk_kb ? "KB" : "B");
42086 if (bitmap->storage.file) {
42087 seq_printf(seq, ", file: ");
42088 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42089 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42090 }
42091
42092 seq_printf(seq, "\n");
42093 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42094 index f1b7586..a49c4bd 100644
42095 --- a/drivers/md/dm-ioctl.c
42096 +++ b/drivers/md/dm-ioctl.c
42097 @@ -1739,7 +1739,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42098 cmd == DM_LIST_VERSIONS_CMD)
42099 return 0;
42100
42101 - if ((cmd == DM_DEV_CREATE_CMD)) {
42102 + if (cmd == DM_DEV_CREATE_CMD) {
42103 if (!*param->name) {
42104 DMWARN("name not supplied when creating device");
42105 return -EINVAL;
42106 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42107 index 699b5be..eac0a15 100644
42108 --- a/drivers/md/dm-raid1.c
42109 +++ b/drivers/md/dm-raid1.c
42110 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42111
42112 struct mirror {
42113 struct mirror_set *ms;
42114 - atomic_t error_count;
42115 + atomic_unchecked_t error_count;
42116 unsigned long error_type;
42117 struct dm_dev *dev;
42118 sector_t offset;
42119 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42120 struct mirror *m;
42121
42122 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42123 - if (!atomic_read(&m->error_count))
42124 + if (!atomic_read_unchecked(&m->error_count))
42125 return m;
42126
42127 return NULL;
42128 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42129 * simple way to tell if a device has encountered
42130 * errors.
42131 */
42132 - atomic_inc(&m->error_count);
42133 + atomic_inc_unchecked(&m->error_count);
42134
42135 if (test_and_set_bit(error_type, &m->error_type))
42136 return;
42137 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42138 struct mirror *m = get_default_mirror(ms);
42139
42140 do {
42141 - if (likely(!atomic_read(&m->error_count)))
42142 + if (likely(!atomic_read_unchecked(&m->error_count)))
42143 return m;
42144
42145 if (m-- == ms->mirror)
42146 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42147 {
42148 struct mirror *default_mirror = get_default_mirror(m->ms);
42149
42150 - return !atomic_read(&default_mirror->error_count);
42151 + return !atomic_read_unchecked(&default_mirror->error_count);
42152 }
42153
42154 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42155 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42156 */
42157 if (likely(region_in_sync(ms, region, 1)))
42158 m = choose_mirror(ms, bio->bi_sector);
42159 - else if (m && atomic_read(&m->error_count))
42160 + else if (m && atomic_read_unchecked(&m->error_count))
42161 m = NULL;
42162
42163 if (likely(m))
42164 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42165 }
42166
42167 ms->mirror[mirror].ms = ms;
42168 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42169 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42170 ms->mirror[mirror].error_type = 0;
42171 ms->mirror[mirror].offset = offset;
42172
42173 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
42174 */
42175 static char device_status_char(struct mirror *m)
42176 {
42177 - if (!atomic_read(&(m->error_count)))
42178 + if (!atomic_read_unchecked(&(m->error_count)))
42179 return 'A';
42180
42181 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42182 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42183 index d907ca6..cfb8384 100644
42184 --- a/drivers/md/dm-stripe.c
42185 +++ b/drivers/md/dm-stripe.c
42186 @@ -20,7 +20,7 @@ struct stripe {
42187 struct dm_dev *dev;
42188 sector_t physical_start;
42189
42190 - atomic_t error_count;
42191 + atomic_unchecked_t error_count;
42192 };
42193
42194 struct stripe_c {
42195 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42196 kfree(sc);
42197 return r;
42198 }
42199 - atomic_set(&(sc->stripe[i].error_count), 0);
42200 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42201 }
42202
42203 ti->private = sc;
42204 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42205 DMEMIT("%d ", sc->stripes);
42206 for (i = 0; i < sc->stripes; i++) {
42207 DMEMIT("%s ", sc->stripe[i].dev->name);
42208 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42209 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42210 'D' : 'A';
42211 }
42212 buffer[i] = '\0';
42213 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42214 */
42215 for (i = 0; i < sc->stripes; i++)
42216 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42217 - atomic_inc(&(sc->stripe[i].error_count));
42218 - if (atomic_read(&(sc->stripe[i].error_count)) <
42219 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42220 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42221 DM_IO_ERROR_THRESHOLD)
42222 schedule_work(&sc->trigger_event);
42223 }
42224 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42225 index f221812..aca962b 100644
42226 --- a/drivers/md/dm-table.c
42227 +++ b/drivers/md/dm-table.c
42228 @@ -354,7 +354,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42229 if (!dev_size)
42230 return 0;
42231
42232 - if ((start >= dev_size) || (start + len > dev_size)) {
42233 + if ((start >= dev_size) || (len > dev_size - start)) {
42234 DMWARN("%s: %s too small for target: "
42235 "start=%llu, len=%llu, dev_size=%llu",
42236 dm_device_name(ti->table->md), bdevname(bdev, b),
42237 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42238 index 60bce43..9b997d0 100644
42239 --- a/drivers/md/dm-thin-metadata.c
42240 +++ b/drivers/md/dm-thin-metadata.c
42241 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42242 {
42243 pmd->info.tm = pmd->tm;
42244 pmd->info.levels = 2;
42245 - pmd->info.value_type.context = pmd->data_sm;
42246 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42247 pmd->info.value_type.size = sizeof(__le64);
42248 pmd->info.value_type.inc = data_block_inc;
42249 pmd->info.value_type.dec = data_block_dec;
42250 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42251
42252 pmd->bl_info.tm = pmd->tm;
42253 pmd->bl_info.levels = 1;
42254 - pmd->bl_info.value_type.context = pmd->data_sm;
42255 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42256 pmd->bl_info.value_type.size = sizeof(__le64);
42257 pmd->bl_info.value_type.inc = data_block_inc;
42258 pmd->bl_info.value_type.dec = data_block_dec;
42259 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42260 index 995e1fc..2468cec 100644
42261 --- a/drivers/md/dm.c
42262 +++ b/drivers/md/dm.c
42263 @@ -178,9 +178,9 @@ struct mapped_device {
42264 /*
42265 * Event handling.
42266 */
42267 - atomic_t event_nr;
42268 + atomic_unchecked_t event_nr;
42269 wait_queue_head_t eventq;
42270 - atomic_t uevent_seq;
42271 + atomic_unchecked_t uevent_seq;
42272 struct list_head uevent_list;
42273 spinlock_t uevent_lock; /* Protect access to uevent_list */
42274
42275 @@ -1916,8 +1916,8 @@ static struct mapped_device *alloc_dev(int minor)
42276 spin_lock_init(&md->deferred_lock);
42277 atomic_set(&md->holders, 1);
42278 atomic_set(&md->open_count, 0);
42279 - atomic_set(&md->event_nr, 0);
42280 - atomic_set(&md->uevent_seq, 0);
42281 + atomic_set_unchecked(&md->event_nr, 0);
42282 + atomic_set_unchecked(&md->uevent_seq, 0);
42283 INIT_LIST_HEAD(&md->uevent_list);
42284 spin_lock_init(&md->uevent_lock);
42285
42286 @@ -2068,7 +2068,7 @@ static void event_callback(void *context)
42287
42288 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42289
42290 - atomic_inc(&md->event_nr);
42291 + atomic_inc_unchecked(&md->event_nr);
42292 wake_up(&md->eventq);
42293 }
42294
42295 @@ -2727,18 +2727,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42296
42297 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42298 {
42299 - return atomic_add_return(1, &md->uevent_seq);
42300 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42301 }
42302
42303 uint32_t dm_get_event_nr(struct mapped_device *md)
42304 {
42305 - return atomic_read(&md->event_nr);
42306 + return atomic_read_unchecked(&md->event_nr);
42307 }
42308
42309 int dm_wait_event(struct mapped_device *md, int event_nr)
42310 {
42311 return wait_event_interruptible(md->eventq,
42312 - (event_nr != atomic_read(&md->event_nr)));
42313 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42314 }
42315
42316 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42317 diff --git a/drivers/md/md.c b/drivers/md/md.c
42318 index 9f13e13..411a5b8 100644
42319 --- a/drivers/md/md.c
42320 +++ b/drivers/md/md.c
42321 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42322 * start build, activate spare
42323 */
42324 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42325 -static atomic_t md_event_count;
42326 +static atomic_unchecked_t md_event_count;
42327 void md_new_event(struct mddev *mddev)
42328 {
42329 - atomic_inc(&md_event_count);
42330 + atomic_inc_unchecked(&md_event_count);
42331 wake_up(&md_event_waiters);
42332 }
42333 EXPORT_SYMBOL_GPL(md_new_event);
42334 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42335 */
42336 static void md_new_event_inintr(struct mddev *mddev)
42337 {
42338 - atomic_inc(&md_event_count);
42339 + atomic_inc_unchecked(&md_event_count);
42340 wake_up(&md_event_waiters);
42341 }
42342
42343 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42344 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42345 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42346 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42347 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42348 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42349
42350 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42351 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42352 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42353 else
42354 sb->resync_offset = cpu_to_le64(0);
42355
42356 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42357 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42358
42359 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42360 sb->size = cpu_to_le64(mddev->dev_sectors);
42361 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42362 static ssize_t
42363 errors_show(struct md_rdev *rdev, char *page)
42364 {
42365 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42366 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42367 }
42368
42369 static ssize_t
42370 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42371 char *e;
42372 unsigned long n = simple_strtoul(buf, &e, 10);
42373 if (*buf && (*e == 0 || *e == '\n')) {
42374 - atomic_set(&rdev->corrected_errors, n);
42375 + atomic_set_unchecked(&rdev->corrected_errors, n);
42376 return len;
42377 }
42378 return -EINVAL;
42379 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42380 rdev->sb_loaded = 0;
42381 rdev->bb_page = NULL;
42382 atomic_set(&rdev->nr_pending, 0);
42383 - atomic_set(&rdev->read_errors, 0);
42384 - atomic_set(&rdev->corrected_errors, 0);
42385 + atomic_set_unchecked(&rdev->read_errors, 0);
42386 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42387
42388 INIT_LIST_HEAD(&rdev->same_set);
42389 init_waitqueue_head(&rdev->blocked_wait);
42390 @@ -7024,7 +7024,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42391
42392 spin_unlock(&pers_lock);
42393 seq_printf(seq, "\n");
42394 - seq->poll_event = atomic_read(&md_event_count);
42395 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42396 return 0;
42397 }
42398 if (v == (void*)2) {
42399 @@ -7127,7 +7127,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42400 return error;
42401
42402 seq = file->private_data;
42403 - seq->poll_event = atomic_read(&md_event_count);
42404 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42405 return error;
42406 }
42407
42408 @@ -7141,7 +7141,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42409 /* always allow read */
42410 mask = POLLIN | POLLRDNORM;
42411
42412 - if (seq->poll_event != atomic_read(&md_event_count))
42413 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42414 mask |= POLLERR | POLLPRI;
42415 return mask;
42416 }
42417 @@ -7185,7 +7185,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42418 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42419 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42420 (int)part_stat_read(&disk->part0, sectors[1]) -
42421 - atomic_read(&disk->sync_io);
42422 + atomic_read_unchecked(&disk->sync_io);
42423 /* sync IO will cause sync_io to increase before the disk_stats
42424 * as sync_io is counted when a request starts, and
42425 * disk_stats is counted when it completes.
42426 diff --git a/drivers/md/md.h b/drivers/md/md.h
42427 index 20f02c0..fd8c821 100644
42428 --- a/drivers/md/md.h
42429 +++ b/drivers/md/md.h
42430 @@ -94,13 +94,13 @@ struct md_rdev {
42431 * only maintained for arrays that
42432 * support hot removal
42433 */
42434 - atomic_t read_errors; /* number of consecutive read errors that
42435 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42436 * we have tried to ignore.
42437 */
42438 struct timespec last_read_error; /* monotonic time since our
42439 * last read error
42440 */
42441 - atomic_t corrected_errors; /* number of corrected read errors,
42442 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42443 * for reporting to userspace and storing
42444 * in superblock.
42445 */
42446 @@ -442,7 +442,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42447
42448 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42449 {
42450 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42451 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42452 }
42453
42454 struct md_personality
42455 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42456 index 3e6d115..ffecdeb 100644
42457 --- a/drivers/md/persistent-data/dm-space-map.h
42458 +++ b/drivers/md/persistent-data/dm-space-map.h
42459 @@ -71,6 +71,7 @@ struct dm_space_map {
42460 dm_sm_threshold_fn fn,
42461 void *context);
42462 };
42463 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42464
42465 /*----------------------------------------------------------------*/
42466
42467 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42468 index d60412c..8d4c982 100644
42469 --- a/drivers/md/raid1.c
42470 +++ b/drivers/md/raid1.c
42471 @@ -1823,7 +1823,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42472 if (r1_sync_page_io(rdev, sect, s,
42473 bio->bi_io_vec[idx].bv_page,
42474 READ) != 0)
42475 - atomic_add(s, &rdev->corrected_errors);
42476 + atomic_add_unchecked(s, &rdev->corrected_errors);
42477 }
42478 sectors -= s;
42479 sect += s;
42480 @@ -2050,7 +2050,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42481 test_bit(In_sync, &rdev->flags)) {
42482 if (r1_sync_page_io(rdev, sect, s,
42483 conf->tmppage, READ)) {
42484 - atomic_add(s, &rdev->corrected_errors);
42485 + atomic_add_unchecked(s, &rdev->corrected_errors);
42486 printk(KERN_INFO
42487 "md/raid1:%s: read error corrected "
42488 "(%d sectors at %llu on %s)\n",
42489 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42490 index df7b0a0..a257495 100644
42491 --- a/drivers/md/raid10.c
42492 +++ b/drivers/md/raid10.c
42493 @@ -1962,7 +1962,7 @@ static void end_sync_read(struct bio *bio, int error)
42494 /* The write handler will notice the lack of
42495 * R10BIO_Uptodate and record any errors etc
42496 */
42497 - atomic_add(r10_bio->sectors,
42498 + atomic_add_unchecked(r10_bio->sectors,
42499 &conf->mirrors[d].rdev->corrected_errors);
42500
42501 /* for reconstruct, we always reschedule after a read.
42502 @@ -2320,7 +2320,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42503 {
42504 struct timespec cur_time_mon;
42505 unsigned long hours_since_last;
42506 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42507 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42508
42509 ktime_get_ts(&cur_time_mon);
42510
42511 @@ -2342,9 +2342,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42512 * overflowing the shift of read_errors by hours_since_last.
42513 */
42514 if (hours_since_last >= 8 * sizeof(read_errors))
42515 - atomic_set(&rdev->read_errors, 0);
42516 + atomic_set_unchecked(&rdev->read_errors, 0);
42517 else
42518 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42519 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42520 }
42521
42522 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42523 @@ -2398,8 +2398,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42524 return;
42525
42526 check_decay_read_errors(mddev, rdev);
42527 - atomic_inc(&rdev->read_errors);
42528 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42529 + atomic_inc_unchecked(&rdev->read_errors);
42530 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42531 char b[BDEVNAME_SIZE];
42532 bdevname(rdev->bdev, b);
42533
42534 @@ -2407,7 +2407,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42535 "md/raid10:%s: %s: Raid device exceeded "
42536 "read_error threshold [cur %d:max %d]\n",
42537 mdname(mddev), b,
42538 - atomic_read(&rdev->read_errors), max_read_errors);
42539 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42540 printk(KERN_NOTICE
42541 "md/raid10:%s: %s: Failing raid device\n",
42542 mdname(mddev), b);
42543 @@ -2562,7 +2562,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42544 sect +
42545 choose_data_offset(r10_bio, rdev)),
42546 bdevname(rdev->bdev, b));
42547 - atomic_add(s, &rdev->corrected_errors);
42548 + atomic_add_unchecked(s, &rdev->corrected_errors);
42549 }
42550
42551 rdev_dec_pending(rdev, mddev);
42552 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42553 index 78ea443..7d57513 100644
42554 --- a/drivers/md/raid5.c
42555 +++ b/drivers/md/raid5.c
42556 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42557 mdname(conf->mddev), STRIPE_SECTORS,
42558 (unsigned long long)s,
42559 bdevname(rdev->bdev, b));
42560 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42561 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42562 clear_bit(R5_ReadError, &sh->dev[i].flags);
42563 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42564 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42565 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42566
42567 - if (atomic_read(&rdev->read_errors))
42568 - atomic_set(&rdev->read_errors, 0);
42569 + if (atomic_read_unchecked(&rdev->read_errors))
42570 + atomic_set_unchecked(&rdev->read_errors, 0);
42571 } else {
42572 const char *bdn = bdevname(rdev->bdev, b);
42573 int retry = 0;
42574 int set_bad = 0;
42575
42576 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42577 - atomic_inc(&rdev->read_errors);
42578 + atomic_inc_unchecked(&rdev->read_errors);
42579 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42580 printk_ratelimited(
42581 KERN_WARNING
42582 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42583 mdname(conf->mddev),
42584 (unsigned long long)s,
42585 bdn);
42586 - } else if (atomic_read(&rdev->read_errors)
42587 + } else if (atomic_read_unchecked(&rdev->read_errors)
42588 > conf->max_nr_stripes)
42589 printk(KERN_WARNING
42590 "md/raid:%s: Too many read errors, failing device %s.\n",
42591 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42592 index 401ef64..836e563 100644
42593 --- a/drivers/media/dvb-core/dvbdev.c
42594 +++ b/drivers/media/dvb-core/dvbdev.c
42595 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42596 const struct dvb_device *template, void *priv, int type)
42597 {
42598 struct dvb_device *dvbdev;
42599 - struct file_operations *dvbdevfops;
42600 + file_operations_no_const *dvbdevfops;
42601 struct device *clsdev;
42602 int minor;
42603 int id;
42604 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42605 index 9b6c3bb..baeb5c7 100644
42606 --- a/drivers/media/dvb-frontends/dib3000.h
42607 +++ b/drivers/media/dvb-frontends/dib3000.h
42608 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42609 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42610 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42611 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42612 -};
42613 +} __no_const;
42614
42615 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42616 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42617 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42618 index ecf21d9..b992428d 100644
42619 --- a/drivers/media/pci/cx88/cx88-video.c
42620 +++ b/drivers/media/pci/cx88/cx88-video.c
42621 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42622
42623 /* ------------------------------------------------------------------ */
42624
42625 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42626 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42627 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42628 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42629 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42630 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42631
42632 module_param_array(video_nr, int, NULL, 0444);
42633 module_param_array(vbi_nr, int, NULL, 0444);
42634 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42635 index c08ae3e..eb59af1 100644
42636 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42637 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42638 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42639 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42640
42641 /* ivtv instance counter */
42642 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42643 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42644
42645 /* Parameter declarations */
42646 static int cardtype[IVTV_MAX_CARDS];
42647 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42648 index dfd0a21..6bbb465 100644
42649 --- a/drivers/media/platform/omap/omap_vout.c
42650 +++ b/drivers/media/platform/omap/omap_vout.c
42651 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42652 OMAP_VIDEO2,
42653 };
42654
42655 -static struct videobuf_queue_ops video_vbq_ops;
42656 /* Variables configurable through module params*/
42657 static u32 video1_numbuffers = 3;
42658 static u32 video2_numbuffers = 3;
42659 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42660 {
42661 struct videobuf_queue *q;
42662 struct omap_vout_device *vout = NULL;
42663 + static struct videobuf_queue_ops video_vbq_ops = {
42664 + .buf_setup = omap_vout_buffer_setup,
42665 + .buf_prepare = omap_vout_buffer_prepare,
42666 + .buf_release = omap_vout_buffer_release,
42667 + .buf_queue = omap_vout_buffer_queue,
42668 + };
42669
42670 vout = video_drvdata(file);
42671 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42672 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42673 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42674
42675 q = &vout->vbq;
42676 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42677 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42678 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42679 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42680 spin_lock_init(&vout->vbq_lock);
42681
42682 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42683 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42684 index 04e6490..2df65bf 100644
42685 --- a/drivers/media/platform/s5p-tv/mixer.h
42686 +++ b/drivers/media/platform/s5p-tv/mixer.h
42687 @@ -156,7 +156,7 @@ struct mxr_layer {
42688 /** layer index (unique identifier) */
42689 int idx;
42690 /** callbacks for layer methods */
42691 - struct mxr_layer_ops ops;
42692 + struct mxr_layer_ops *ops;
42693 /** format array */
42694 const struct mxr_format **fmt_array;
42695 /** size of format array */
42696 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42697 index b93a21f..2535195 100644
42698 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42699 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42700 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42701 {
42702 struct mxr_layer *layer;
42703 int ret;
42704 - struct mxr_layer_ops ops = {
42705 + static struct mxr_layer_ops ops = {
42706 .release = mxr_graph_layer_release,
42707 .buffer_set = mxr_graph_buffer_set,
42708 .stream_set = mxr_graph_stream_set,
42709 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42710 index b713403..53cb5ad 100644
42711 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42712 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42713 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42714 layer->update_buf = next;
42715 }
42716
42717 - layer->ops.buffer_set(layer, layer->update_buf);
42718 + layer->ops->buffer_set(layer, layer->update_buf);
42719
42720 if (done && done != layer->shadow_buf)
42721 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42722 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42723 index 641b1f0..49cff30 100644
42724 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42725 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42726 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42727 layer->geo.src.height = layer->geo.src.full_height;
42728
42729 mxr_geometry_dump(mdev, &layer->geo);
42730 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42731 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42732 mxr_geometry_dump(mdev, &layer->geo);
42733 }
42734
42735 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42736 layer->geo.dst.full_width = mbus_fmt.width;
42737 layer->geo.dst.full_height = mbus_fmt.height;
42738 layer->geo.dst.field = mbus_fmt.field;
42739 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42740 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42741
42742 mxr_geometry_dump(mdev, &layer->geo);
42743 }
42744 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42745 /* set source size to highest accepted value */
42746 geo->src.full_width = max(geo->dst.full_width, pix->width);
42747 geo->src.full_height = max(geo->dst.full_height, pix->height);
42748 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42749 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42750 mxr_geometry_dump(mdev, &layer->geo);
42751 /* set cropping to total visible screen */
42752 geo->src.width = pix->width;
42753 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42754 geo->src.x_offset = 0;
42755 geo->src.y_offset = 0;
42756 /* assure consistency of geometry */
42757 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42758 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42759 mxr_geometry_dump(mdev, &layer->geo);
42760 /* set full size to lowest possible value */
42761 geo->src.full_width = 0;
42762 geo->src.full_height = 0;
42763 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42764 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42765 mxr_geometry_dump(mdev, &layer->geo);
42766
42767 /* returning results */
42768 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42769 target->width = s->r.width;
42770 target->height = s->r.height;
42771
42772 - layer->ops.fix_geometry(layer, stage, s->flags);
42773 + layer->ops->fix_geometry(layer, stage, s->flags);
42774
42775 /* retrieve update selection rectangle */
42776 res.left = target->x_offset;
42777 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42778 mxr_output_get(mdev);
42779
42780 mxr_layer_update_output(layer);
42781 - layer->ops.format_set(layer);
42782 + layer->ops->format_set(layer);
42783 /* enabling layer in hardware */
42784 spin_lock_irqsave(&layer->enq_slock, flags);
42785 layer->state = MXR_LAYER_STREAMING;
42786 spin_unlock_irqrestore(&layer->enq_slock, flags);
42787
42788 - layer->ops.stream_set(layer, MXR_ENABLE);
42789 + layer->ops->stream_set(layer, MXR_ENABLE);
42790 mxr_streamer_get(mdev);
42791
42792 return 0;
42793 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42794 spin_unlock_irqrestore(&layer->enq_slock, flags);
42795
42796 /* disabling layer in hardware */
42797 - layer->ops.stream_set(layer, MXR_DISABLE);
42798 + layer->ops->stream_set(layer, MXR_DISABLE);
42799 /* remove one streamer */
42800 mxr_streamer_put(mdev);
42801 /* allow changes in output configuration */
42802 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42803
42804 void mxr_layer_release(struct mxr_layer *layer)
42805 {
42806 - if (layer->ops.release)
42807 - layer->ops.release(layer);
42808 + if (layer->ops->release)
42809 + layer->ops->release(layer);
42810 }
42811
42812 void mxr_base_layer_release(struct mxr_layer *layer)
42813 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42814
42815 layer->mdev = mdev;
42816 layer->idx = idx;
42817 - layer->ops = *ops;
42818 + layer->ops = ops;
42819
42820 spin_lock_init(&layer->enq_slock);
42821 INIT_LIST_HEAD(&layer->enq_list);
42822 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42823 index 3d13a63..da31bf1 100644
42824 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42825 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42826 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42827 {
42828 struct mxr_layer *layer;
42829 int ret;
42830 - struct mxr_layer_ops ops = {
42831 + static struct mxr_layer_ops ops = {
42832 .release = mxr_vp_layer_release,
42833 .buffer_set = mxr_vp_buffer_set,
42834 .stream_set = mxr_vp_stream_set,
42835 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42836 index 545c04c..a14bded 100644
42837 --- a/drivers/media/radio/radio-cadet.c
42838 +++ b/drivers/media/radio/radio-cadet.c
42839 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42840 unsigned char readbuf[RDS_BUFFER];
42841 int i = 0;
42842
42843 + if (count > RDS_BUFFER)
42844 + return -EFAULT;
42845 mutex_lock(&dev->lock);
42846 if (dev->rdsstat == 0)
42847 cadet_start_rds(dev);
42848 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42849 while (i < count && dev->rdsin != dev->rdsout)
42850 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42851
42852 - if (i && copy_to_user(data, readbuf, i))
42853 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42854 i = -EFAULT;
42855 unlock:
42856 mutex_unlock(&dev->lock);
42857 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42858 index bd4d3a7..ffc0b9d 100644
42859 --- a/drivers/media/radio/radio-maxiradio.c
42860 +++ b/drivers/media/radio/radio-maxiradio.c
42861 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42862 /* TEA5757 pin mappings */
42863 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42864
42865 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42866 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42867
42868 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42869 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42870 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42871 index 8fa18ab..caee70f 100644
42872 --- a/drivers/media/radio/radio-shark.c
42873 +++ b/drivers/media/radio/radio-shark.c
42874 @@ -79,7 +79,7 @@ struct shark_device {
42875 u32 last_val;
42876 };
42877
42878 -static atomic_t shark_instance = ATOMIC_INIT(0);
42879 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42880
42881 static void shark_write_val(struct snd_tea575x *tea, u32 val)
42882 {
42883 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
42884 index 9fb6697..f167415 100644
42885 --- a/drivers/media/radio/radio-shark2.c
42886 +++ b/drivers/media/radio/radio-shark2.c
42887 @@ -74,7 +74,7 @@ struct shark_device {
42888 u8 *transfer_buffer;
42889 };
42890
42891 -static atomic_t shark_instance = ATOMIC_INIT(0);
42892 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42893
42894 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
42895 {
42896 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
42897 index 9c9084c..a9e8dfb 100644
42898 --- a/drivers/media/radio/radio-si476x.c
42899 +++ b/drivers/media/radio/radio-si476x.c
42900 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
42901 struct si476x_radio *radio;
42902 struct v4l2_ctrl *ctrl;
42903
42904 - static atomic_t instance = ATOMIC_INIT(0);
42905 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
42906
42907 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
42908 if (!radio)
42909 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
42910 index 1cf382a..c22998c 100644
42911 --- a/drivers/media/rc/rc-main.c
42912 +++ b/drivers/media/rc/rc-main.c
42913 @@ -1030,7 +1030,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
42914 int rc_register_device(struct rc_dev *dev)
42915 {
42916 static bool raw_init = false; /* raw decoders loaded? */
42917 - static atomic_t devno = ATOMIC_INIT(0);
42918 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
42919 struct rc_map *rc_map;
42920 const char *path;
42921 int rc;
42922 @@ -1061,7 +1061,7 @@ int rc_register_device(struct rc_dev *dev)
42923 */
42924 mutex_lock(&dev->lock);
42925
42926 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
42927 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
42928 dev_set_name(&dev->dev, "rc%ld", dev->devno);
42929 dev_set_drvdata(&dev->dev, dev);
42930 rc = device_add(&dev->dev);
42931 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
42932 index 3940bb0..fb3952a 100644
42933 --- a/drivers/media/usb/dvb-usb/cxusb.c
42934 +++ b/drivers/media/usb/dvb-usb/cxusb.c
42935 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
42936
42937 struct dib0700_adapter_state {
42938 int (*set_param_save) (struct dvb_frontend *);
42939 -};
42940 +} __no_const;
42941
42942 static int dib7070_set_param_override(struct dvb_frontend *fe)
42943 {
42944 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
42945 index 6e237b6..dc25556 100644
42946 --- a/drivers/media/usb/dvb-usb/dw2102.c
42947 +++ b/drivers/media/usb/dvb-usb/dw2102.c
42948 @@ -118,7 +118,7 @@ struct su3000_state {
42949
42950 struct s6x0_state {
42951 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
42952 -};
42953 +} __no_const;
42954
42955 /* debug */
42956 static int dvb_usb_dw2102_debug;
42957 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42958 index 8f7a6a4..59502dd 100644
42959 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42960 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
42961 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
42962 __u32 reserved;
42963 };
42964
42965 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42966 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42967 enum v4l2_memory memory)
42968 {
42969 void __user *up_pln;
42970 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42971 return 0;
42972 }
42973
42974 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
42975 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
42976 enum v4l2_memory memory)
42977 {
42978 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
42979 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
42980 put_user(kp->start_block, &up->start_block) ||
42981 put_user(kp->blocks, &up->blocks) ||
42982 put_user(tmp, &up->edid) ||
42983 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
42984 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
42985 return -EFAULT;
42986 return 0;
42987 }
42988 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
42989 index 02d1b63..5fd6b16 100644
42990 --- a/drivers/media/v4l2-core/v4l2-device.c
42991 +++ b/drivers/media/v4l2-core/v4l2-device.c
42992 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
42993 EXPORT_SYMBOL_GPL(v4l2_device_put);
42994
42995 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
42996 - atomic_t *instance)
42997 + atomic_unchecked_t *instance)
42998 {
42999 - int num = atomic_inc_return(instance) - 1;
43000 + int num = atomic_inc_return_unchecked(instance) - 1;
43001 int len = strlen(basename);
43002
43003 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43004 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43005 index 68e6b5e..d8b923e 100644
43006 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43007 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43008 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
43009 struct file *file, void *fh, void *p);
43010 } u;
43011 void (*debug)(const void *arg, bool write_only);
43012 -};
43013 +} __do_const;
43014 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43015
43016 /* This control needs a priority check */
43017 #define INFO_FL_PRIO (1 << 0)
43018 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
43019 struct video_device *vfd = video_devdata(file);
43020 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43021 bool write_only = false;
43022 - struct v4l2_ioctl_info default_info;
43023 + v4l2_ioctl_info_no_const default_info;
43024 const struct v4l2_ioctl_info *info;
43025 void *fh = file->private_data;
43026 struct v4l2_fh *vfh = NULL;
43027 @@ -2194,7 +2195,7 @@ done:
43028 }
43029
43030 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43031 - void * __user *user_ptr, void ***kernel_ptr)
43032 + void __user **user_ptr, void ***kernel_ptr)
43033 {
43034 int ret = 0;
43035
43036 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43037 ret = -EINVAL;
43038 break;
43039 }
43040 - *user_ptr = (void __user *)buf->m.planes;
43041 + *user_ptr = (void __force_user *)buf->m.planes;
43042 *kernel_ptr = (void *)&buf->m.planes;
43043 *array_size = sizeof(struct v4l2_plane) * buf->length;
43044 ret = 1;
43045 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43046 ret = -EINVAL;
43047 break;
43048 }
43049 - *user_ptr = (void __user *)ctrls->controls;
43050 + *user_ptr = (void __force_user *)ctrls->controls;
43051 *kernel_ptr = (void *)&ctrls->controls;
43052 *array_size = sizeof(struct v4l2_ext_control)
43053 * ctrls->count;
43054 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43055 index 767ff4d..c69d259 100644
43056 --- a/drivers/message/fusion/mptbase.c
43057 +++ b/drivers/message/fusion/mptbase.c
43058 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43059 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43060 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43061
43062 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43063 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43064 +#else
43065 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43066 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43067 +#endif
43068 +
43069 /*
43070 * Rounding UP to nearest 4-kB boundary here...
43071 */
43072 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43073 ioc->facts.GlobalCredits);
43074
43075 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43076 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43077 + NULL, NULL);
43078 +#else
43079 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43080 +#endif
43081 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43082 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43083 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43084 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43085 index dd239bd..689c4f7 100644
43086 --- a/drivers/message/fusion/mptsas.c
43087 +++ b/drivers/message/fusion/mptsas.c
43088 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43089 return 0;
43090 }
43091
43092 +static inline void
43093 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43094 +{
43095 + if (phy_info->port_details) {
43096 + phy_info->port_details->rphy = rphy;
43097 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43098 + ioc->name, rphy));
43099 + }
43100 +
43101 + if (rphy) {
43102 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43103 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43104 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43105 + ioc->name, rphy, rphy->dev.release));
43106 + }
43107 +}
43108 +
43109 /* no mutex */
43110 static void
43111 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43112 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43113 return NULL;
43114 }
43115
43116 -static inline void
43117 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43118 -{
43119 - if (phy_info->port_details) {
43120 - phy_info->port_details->rphy = rphy;
43121 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43122 - ioc->name, rphy));
43123 - }
43124 -
43125 - if (rphy) {
43126 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43127 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43128 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43129 - ioc->name, rphy, rphy->dev.release));
43130 - }
43131 -}
43132 -
43133 static inline struct sas_port *
43134 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43135 {
43136 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43137 index 727819c..ad74694 100644
43138 --- a/drivers/message/fusion/mptscsih.c
43139 +++ b/drivers/message/fusion/mptscsih.c
43140 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43141
43142 h = shost_priv(SChost);
43143
43144 - if (h) {
43145 - if (h->info_kbuf == NULL)
43146 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43147 - return h->info_kbuf;
43148 - h->info_kbuf[0] = '\0';
43149 + if (!h)
43150 + return NULL;
43151
43152 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43153 - h->info_kbuf[size-1] = '\0';
43154 - }
43155 + if (h->info_kbuf == NULL)
43156 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43157 + return h->info_kbuf;
43158 + h->info_kbuf[0] = '\0';
43159 +
43160 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43161 + h->info_kbuf[size-1] = '\0';
43162
43163 return h->info_kbuf;
43164 }
43165 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43166 index b7d87cd..9890039 100644
43167 --- a/drivers/message/i2o/i2o_proc.c
43168 +++ b/drivers/message/i2o/i2o_proc.c
43169 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43170 "Array Controller Device"
43171 };
43172
43173 -static char *chtostr(char *tmp, u8 *chars, int n)
43174 -{
43175 - tmp[0] = 0;
43176 - return strncat(tmp, (char *)chars, n);
43177 -}
43178 -
43179 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43180 char *group)
43181 {
43182 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43183 } *result;
43184
43185 i2o_exec_execute_ddm_table ddm_table;
43186 - char tmp[28 + 1];
43187
43188 result = kmalloc(sizeof(*result), GFP_KERNEL);
43189 if (!result)
43190 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43191
43192 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43193 seq_printf(seq, "%-#8x", ddm_table.module_id);
43194 - seq_printf(seq, "%-29s",
43195 - chtostr(tmp, ddm_table.module_name_version, 28));
43196 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43197 seq_printf(seq, "%9d ", ddm_table.data_size);
43198 seq_printf(seq, "%8d", ddm_table.code_size);
43199
43200 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43201
43202 i2o_driver_result_table *result;
43203 i2o_driver_store_table *dst;
43204 - char tmp[28 + 1];
43205
43206 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43207 if (result == NULL)
43208 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43209
43210 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43211 seq_printf(seq, "%-#8x", dst->module_id);
43212 - seq_printf(seq, "%-29s",
43213 - chtostr(tmp, dst->module_name_version, 28));
43214 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43215 + seq_printf(seq, "%-.28s", dst->module_name_version);
43216 + seq_printf(seq, "%-.8s", dst->date);
43217 seq_printf(seq, "%8d ", dst->module_size);
43218 seq_printf(seq, "%8d ", dst->mpb_size);
43219 seq_printf(seq, "0x%04x", dst->module_flags);
43220 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43221 // == (allow) 512d bytes (max)
43222 static u16 *work16 = (u16 *) work32;
43223 int token;
43224 - char tmp[16 + 1];
43225
43226 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43227
43228 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43229 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43230 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43231 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43232 - seq_printf(seq, "Vendor info : %s\n",
43233 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43234 - seq_printf(seq, "Product info : %s\n",
43235 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43236 - seq_printf(seq, "Description : %s\n",
43237 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43238 - seq_printf(seq, "Product rev. : %s\n",
43239 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43240 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43241 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43242 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43243 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43244
43245 seq_printf(seq, "Serial number : ");
43246 print_serial_number(seq, (u8 *) (work32 + 16),
43247 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43248 u8 pad[256]; // allow up to 256 byte (max) serial number
43249 } result;
43250
43251 - char tmp[24 + 1];
43252 -
43253 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43254
43255 if (token < 0) {
43256 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43257 }
43258
43259 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43260 - seq_printf(seq, "Module name : %s\n",
43261 - chtostr(tmp, result.module_name, 24));
43262 - seq_printf(seq, "Module revision : %s\n",
43263 - chtostr(tmp, result.module_rev, 8));
43264 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43265 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43266
43267 seq_printf(seq, "Serial number : ");
43268 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43269 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43270 u8 instance_number[4];
43271 } result;
43272
43273 - char tmp[64 + 1];
43274 -
43275 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43276
43277 if (token < 0) {
43278 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43279 return 0;
43280 }
43281
43282 - seq_printf(seq, "Device name : %s\n",
43283 - chtostr(tmp, result.device_name, 64));
43284 - seq_printf(seq, "Service name : %s\n",
43285 - chtostr(tmp, result.service_name, 64));
43286 - seq_printf(seq, "Physical name : %s\n",
43287 - chtostr(tmp, result.physical_location, 64));
43288 - seq_printf(seq, "Instance number : %s\n",
43289 - chtostr(tmp, result.instance_number, 4));
43290 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43291 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43292 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43293 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43294
43295 return 0;
43296 }
43297 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43298 index a8c08f3..155fe3d 100644
43299 --- a/drivers/message/i2o/iop.c
43300 +++ b/drivers/message/i2o/iop.c
43301 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43302
43303 spin_lock_irqsave(&c->context_list_lock, flags);
43304
43305 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43306 - atomic_inc(&c->context_list_counter);
43307 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43308 + atomic_inc_unchecked(&c->context_list_counter);
43309
43310 - entry->context = atomic_read(&c->context_list_counter);
43311 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43312
43313 list_add(&entry->list, &c->context_list);
43314
43315 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43316
43317 #if BITS_PER_LONG == 64
43318 spin_lock_init(&c->context_list_lock);
43319 - atomic_set(&c->context_list_counter, 0);
43320 + atomic_set_unchecked(&c->context_list_counter, 0);
43321 INIT_LIST_HEAD(&c->context_list);
43322 #endif
43323
43324 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43325 index fcbb2e9..2635e11 100644
43326 --- a/drivers/mfd/janz-cmodio.c
43327 +++ b/drivers/mfd/janz-cmodio.c
43328 @@ -13,6 +13,7 @@
43329
43330 #include <linux/kernel.h>
43331 #include <linux/module.h>
43332 +#include <linux/slab.h>
43333 #include <linux/init.h>
43334 #include <linux/pci.h>
43335 #include <linux/interrupt.h>
43336 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43337 index 9aa6d1e..1631bfc 100644
43338 --- a/drivers/mfd/twl4030-irq.c
43339 +++ b/drivers/mfd/twl4030-irq.c
43340 @@ -35,6 +35,7 @@
43341 #include <linux/of.h>
43342 #include <linux/irqdomain.h>
43343 #include <linux/i2c/twl.h>
43344 +#include <asm/pgtable.h>
43345
43346 #include "twl-core.h"
43347
43348 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43349 * Install an irq handler for each of the SIH modules;
43350 * clone dummy irq_chip since PIH can't *do* anything
43351 */
43352 - twl4030_irq_chip = dummy_irq_chip;
43353 - twl4030_irq_chip.name = "twl4030";
43354 + pax_open_kernel();
43355 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43356 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43357
43358 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43359 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43360 + pax_close_kernel();
43361
43362 for (i = irq_base; i < irq_end; i++) {
43363 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43364 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
43365 index 277a8db..0e0b754 100644
43366 --- a/drivers/mfd/twl6030-irq.c
43367 +++ b/drivers/mfd/twl6030-irq.c
43368 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
43369 * install an irq handler for each of the modules;
43370 * clone dummy irq_chip since PIH can't *do* anything
43371 */
43372 - twl6030_irq_chip = dummy_irq_chip;
43373 - twl6030_irq_chip.name = "twl6030";
43374 - twl6030_irq_chip.irq_set_type = NULL;
43375 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43376 + pax_open_kernel();
43377 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
43378 + *(const char **)&twl6030_irq_chip.name = "twl6030";
43379 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
43380 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
43381 + pax_close_kernel();
43382
43383 for (i = irq_base; i < irq_end; i++) {
43384 irq_set_chip_and_handler(i, &twl6030_irq_chip,
43385 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43386 index f32550a..e3e52a2 100644
43387 --- a/drivers/misc/c2port/core.c
43388 +++ b/drivers/misc/c2port/core.c
43389 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
43390 mutex_init(&c2dev->mutex);
43391
43392 /* Create binary file */
43393 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43394 + pax_open_kernel();
43395 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
43396 + pax_close_kernel();
43397 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
43398 if (unlikely(ret))
43399 goto error_device_create_bin_file;
43400 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43401 index 36f5d52..32311c3 100644
43402 --- a/drivers/misc/kgdbts.c
43403 +++ b/drivers/misc/kgdbts.c
43404 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43405 char before[BREAK_INSTR_SIZE];
43406 char after[BREAK_INSTR_SIZE];
43407
43408 - probe_kernel_read(before, (char *)kgdbts_break_test,
43409 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43410 BREAK_INSTR_SIZE);
43411 init_simple_test();
43412 ts.tst = plant_and_detach_test;
43413 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43414 /* Activate test with initial breakpoint */
43415 if (!is_early)
43416 kgdb_breakpoint();
43417 - probe_kernel_read(after, (char *)kgdbts_break_test,
43418 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43419 BREAK_INSTR_SIZE);
43420 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43421 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43422 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43423 index 036effe..b3a6336 100644
43424 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43425 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43426 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43427 * the lid is closed. This leads to interrupts as soon as a little move
43428 * is done.
43429 */
43430 - atomic_inc(&lis3->count);
43431 + atomic_inc_unchecked(&lis3->count);
43432
43433 wake_up_interruptible(&lis3->misc_wait);
43434 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43435 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43436 if (lis3->pm_dev)
43437 pm_runtime_get_sync(lis3->pm_dev);
43438
43439 - atomic_set(&lis3->count, 0);
43440 + atomic_set_unchecked(&lis3->count, 0);
43441 return 0;
43442 }
43443
43444 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43445 add_wait_queue(&lis3->misc_wait, &wait);
43446 while (true) {
43447 set_current_state(TASK_INTERRUPTIBLE);
43448 - data = atomic_xchg(&lis3->count, 0);
43449 + data = atomic_xchg_unchecked(&lis3->count, 0);
43450 if (data)
43451 break;
43452
43453 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43454 struct lis3lv02d, miscdev);
43455
43456 poll_wait(file, &lis3->misc_wait, wait);
43457 - if (atomic_read(&lis3->count))
43458 + if (atomic_read_unchecked(&lis3->count))
43459 return POLLIN | POLLRDNORM;
43460 return 0;
43461 }
43462 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43463 index c439c82..1f20f57 100644
43464 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43465 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43466 @@ -297,7 +297,7 @@ struct lis3lv02d {
43467 struct input_polled_dev *idev; /* input device */
43468 struct platform_device *pdev; /* platform device */
43469 struct regulator_bulk_data regulators[2];
43470 - atomic_t count; /* interrupt count after last read */
43471 + atomic_unchecked_t count; /* interrupt count after last read */
43472 union axis_conversion ac; /* hw -> logical axis */
43473 int mapped_btns[3];
43474
43475 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43476 index 2f30bad..c4c13d0 100644
43477 --- a/drivers/misc/sgi-gru/gruhandles.c
43478 +++ b/drivers/misc/sgi-gru/gruhandles.c
43479 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43480 unsigned long nsec;
43481
43482 nsec = CLKS2NSEC(clks);
43483 - atomic_long_inc(&mcs_op_statistics[op].count);
43484 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43485 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43486 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43487 if (mcs_op_statistics[op].max < nsec)
43488 mcs_op_statistics[op].max = nsec;
43489 }
43490 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43491 index 4f76359..cdfcb2e 100644
43492 --- a/drivers/misc/sgi-gru/gruprocfs.c
43493 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43494 @@ -32,9 +32,9 @@
43495
43496 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43497
43498 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43499 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43500 {
43501 - unsigned long val = atomic_long_read(v);
43502 + unsigned long val = atomic_long_read_unchecked(v);
43503
43504 seq_printf(s, "%16lu %s\n", val, id);
43505 }
43506 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43507
43508 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43509 for (op = 0; op < mcsop_last; op++) {
43510 - count = atomic_long_read(&mcs_op_statistics[op].count);
43511 - total = atomic_long_read(&mcs_op_statistics[op].total);
43512 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43513 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43514 max = mcs_op_statistics[op].max;
43515 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43516 count ? total / count : 0, max);
43517 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43518 index 5c3ce24..4915ccb 100644
43519 --- a/drivers/misc/sgi-gru/grutables.h
43520 +++ b/drivers/misc/sgi-gru/grutables.h
43521 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43522 * GRU statistics.
43523 */
43524 struct gru_stats_s {
43525 - atomic_long_t vdata_alloc;
43526 - atomic_long_t vdata_free;
43527 - atomic_long_t gts_alloc;
43528 - atomic_long_t gts_free;
43529 - atomic_long_t gms_alloc;
43530 - atomic_long_t gms_free;
43531 - atomic_long_t gts_double_allocate;
43532 - atomic_long_t assign_context;
43533 - atomic_long_t assign_context_failed;
43534 - atomic_long_t free_context;
43535 - atomic_long_t load_user_context;
43536 - atomic_long_t load_kernel_context;
43537 - atomic_long_t lock_kernel_context;
43538 - atomic_long_t unlock_kernel_context;
43539 - atomic_long_t steal_user_context;
43540 - atomic_long_t steal_kernel_context;
43541 - atomic_long_t steal_context_failed;
43542 - atomic_long_t nopfn;
43543 - atomic_long_t asid_new;
43544 - atomic_long_t asid_next;
43545 - atomic_long_t asid_wrap;
43546 - atomic_long_t asid_reuse;
43547 - atomic_long_t intr;
43548 - atomic_long_t intr_cbr;
43549 - atomic_long_t intr_tfh;
43550 - atomic_long_t intr_spurious;
43551 - atomic_long_t intr_mm_lock_failed;
43552 - atomic_long_t call_os;
43553 - atomic_long_t call_os_wait_queue;
43554 - atomic_long_t user_flush_tlb;
43555 - atomic_long_t user_unload_context;
43556 - atomic_long_t user_exception;
43557 - atomic_long_t set_context_option;
43558 - atomic_long_t check_context_retarget_intr;
43559 - atomic_long_t check_context_unload;
43560 - atomic_long_t tlb_dropin;
43561 - atomic_long_t tlb_preload_page;
43562 - atomic_long_t tlb_dropin_fail_no_asid;
43563 - atomic_long_t tlb_dropin_fail_upm;
43564 - atomic_long_t tlb_dropin_fail_invalid;
43565 - atomic_long_t tlb_dropin_fail_range_active;
43566 - atomic_long_t tlb_dropin_fail_idle;
43567 - atomic_long_t tlb_dropin_fail_fmm;
43568 - atomic_long_t tlb_dropin_fail_no_exception;
43569 - atomic_long_t tfh_stale_on_fault;
43570 - atomic_long_t mmu_invalidate_range;
43571 - atomic_long_t mmu_invalidate_page;
43572 - atomic_long_t flush_tlb;
43573 - atomic_long_t flush_tlb_gru;
43574 - atomic_long_t flush_tlb_gru_tgh;
43575 - atomic_long_t flush_tlb_gru_zero_asid;
43576 + atomic_long_unchecked_t vdata_alloc;
43577 + atomic_long_unchecked_t vdata_free;
43578 + atomic_long_unchecked_t gts_alloc;
43579 + atomic_long_unchecked_t gts_free;
43580 + atomic_long_unchecked_t gms_alloc;
43581 + atomic_long_unchecked_t gms_free;
43582 + atomic_long_unchecked_t gts_double_allocate;
43583 + atomic_long_unchecked_t assign_context;
43584 + atomic_long_unchecked_t assign_context_failed;
43585 + atomic_long_unchecked_t free_context;
43586 + atomic_long_unchecked_t load_user_context;
43587 + atomic_long_unchecked_t load_kernel_context;
43588 + atomic_long_unchecked_t lock_kernel_context;
43589 + atomic_long_unchecked_t unlock_kernel_context;
43590 + atomic_long_unchecked_t steal_user_context;
43591 + atomic_long_unchecked_t steal_kernel_context;
43592 + atomic_long_unchecked_t steal_context_failed;
43593 + atomic_long_unchecked_t nopfn;
43594 + atomic_long_unchecked_t asid_new;
43595 + atomic_long_unchecked_t asid_next;
43596 + atomic_long_unchecked_t asid_wrap;
43597 + atomic_long_unchecked_t asid_reuse;
43598 + atomic_long_unchecked_t intr;
43599 + atomic_long_unchecked_t intr_cbr;
43600 + atomic_long_unchecked_t intr_tfh;
43601 + atomic_long_unchecked_t intr_spurious;
43602 + atomic_long_unchecked_t intr_mm_lock_failed;
43603 + atomic_long_unchecked_t call_os;
43604 + atomic_long_unchecked_t call_os_wait_queue;
43605 + atomic_long_unchecked_t user_flush_tlb;
43606 + atomic_long_unchecked_t user_unload_context;
43607 + atomic_long_unchecked_t user_exception;
43608 + atomic_long_unchecked_t set_context_option;
43609 + atomic_long_unchecked_t check_context_retarget_intr;
43610 + atomic_long_unchecked_t check_context_unload;
43611 + atomic_long_unchecked_t tlb_dropin;
43612 + atomic_long_unchecked_t tlb_preload_page;
43613 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43614 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43615 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43616 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43617 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43618 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43619 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43620 + atomic_long_unchecked_t tfh_stale_on_fault;
43621 + atomic_long_unchecked_t mmu_invalidate_range;
43622 + atomic_long_unchecked_t mmu_invalidate_page;
43623 + atomic_long_unchecked_t flush_tlb;
43624 + atomic_long_unchecked_t flush_tlb_gru;
43625 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43626 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43627
43628 - atomic_long_t copy_gpa;
43629 - atomic_long_t read_gpa;
43630 + atomic_long_unchecked_t copy_gpa;
43631 + atomic_long_unchecked_t read_gpa;
43632
43633 - atomic_long_t mesq_receive;
43634 - atomic_long_t mesq_receive_none;
43635 - atomic_long_t mesq_send;
43636 - atomic_long_t mesq_send_failed;
43637 - atomic_long_t mesq_noop;
43638 - atomic_long_t mesq_send_unexpected_error;
43639 - atomic_long_t mesq_send_lb_overflow;
43640 - atomic_long_t mesq_send_qlimit_reached;
43641 - atomic_long_t mesq_send_amo_nacked;
43642 - atomic_long_t mesq_send_put_nacked;
43643 - atomic_long_t mesq_page_overflow;
43644 - atomic_long_t mesq_qf_locked;
43645 - atomic_long_t mesq_qf_noop_not_full;
43646 - atomic_long_t mesq_qf_switch_head_failed;
43647 - atomic_long_t mesq_qf_unexpected_error;
43648 - atomic_long_t mesq_noop_unexpected_error;
43649 - atomic_long_t mesq_noop_lb_overflow;
43650 - atomic_long_t mesq_noop_qlimit_reached;
43651 - atomic_long_t mesq_noop_amo_nacked;
43652 - atomic_long_t mesq_noop_put_nacked;
43653 - atomic_long_t mesq_noop_page_overflow;
43654 + atomic_long_unchecked_t mesq_receive;
43655 + atomic_long_unchecked_t mesq_receive_none;
43656 + atomic_long_unchecked_t mesq_send;
43657 + atomic_long_unchecked_t mesq_send_failed;
43658 + atomic_long_unchecked_t mesq_noop;
43659 + atomic_long_unchecked_t mesq_send_unexpected_error;
43660 + atomic_long_unchecked_t mesq_send_lb_overflow;
43661 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43662 + atomic_long_unchecked_t mesq_send_amo_nacked;
43663 + atomic_long_unchecked_t mesq_send_put_nacked;
43664 + atomic_long_unchecked_t mesq_page_overflow;
43665 + atomic_long_unchecked_t mesq_qf_locked;
43666 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43667 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43668 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43669 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43670 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43671 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43672 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43673 + atomic_long_unchecked_t mesq_noop_put_nacked;
43674 + atomic_long_unchecked_t mesq_noop_page_overflow;
43675
43676 };
43677
43678 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43679 tghop_invalidate, mcsop_last};
43680
43681 struct mcs_op_statistic {
43682 - atomic_long_t count;
43683 - atomic_long_t total;
43684 + atomic_long_unchecked_t count;
43685 + atomic_long_unchecked_t total;
43686 unsigned long max;
43687 };
43688
43689 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43690
43691 #define STAT(id) do { \
43692 if (gru_options & OPT_STATS) \
43693 - atomic_long_inc(&gru_stats.id); \
43694 + atomic_long_inc_unchecked(&gru_stats.id); \
43695 } while (0)
43696
43697 #ifdef CONFIG_SGI_GRU_DEBUG
43698 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43699 index c862cd4..0d176fe 100644
43700 --- a/drivers/misc/sgi-xp/xp.h
43701 +++ b/drivers/misc/sgi-xp/xp.h
43702 @@ -288,7 +288,7 @@ struct xpc_interface {
43703 xpc_notify_func, void *);
43704 void (*received) (short, int, void *);
43705 enum xp_retval (*partid_to_nasids) (short, void *);
43706 -};
43707 +} __no_const;
43708
43709 extern struct xpc_interface xpc_interface;
43710
43711 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43712 index b94d5f7..7f494c5 100644
43713 --- a/drivers/misc/sgi-xp/xpc.h
43714 +++ b/drivers/misc/sgi-xp/xpc.h
43715 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43716 void (*received_payload) (struct xpc_channel *, void *);
43717 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43718 };
43719 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43720
43721 /* struct xpc_partition act_state values (for XPC HB) */
43722
43723 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43724 /* found in xpc_main.c */
43725 extern struct device *xpc_part;
43726 extern struct device *xpc_chan;
43727 -extern struct xpc_arch_operations xpc_arch_ops;
43728 +extern xpc_arch_operations_no_const xpc_arch_ops;
43729 extern int xpc_disengage_timelimit;
43730 extern int xpc_disengage_timedout;
43731 extern int xpc_activate_IRQ_rcvd;
43732 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43733 index 82dc574..8539ab2 100644
43734 --- a/drivers/misc/sgi-xp/xpc_main.c
43735 +++ b/drivers/misc/sgi-xp/xpc_main.c
43736 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43737 .notifier_call = xpc_system_die,
43738 };
43739
43740 -struct xpc_arch_operations xpc_arch_ops;
43741 +xpc_arch_operations_no_const xpc_arch_ops;
43742
43743 /*
43744 * Timer function to enforce the timelimit on the partition disengage.
43745 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43746
43747 if (((die_args->trapnr == X86_TRAP_MF) ||
43748 (die_args->trapnr == X86_TRAP_XF)) &&
43749 - !user_mode_vm(die_args->regs))
43750 + !user_mode(die_args->regs))
43751 xpc_die_deactivate();
43752
43753 break;
43754 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43755 index 837fc73..acb5862 100644
43756 --- a/drivers/mmc/core/mmc_ops.c
43757 +++ b/drivers/mmc/core/mmc_ops.c
43758 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43759 void *data_buf;
43760 int is_on_stack;
43761
43762 - is_on_stack = object_is_on_stack(buf);
43763 + is_on_stack = object_starts_on_stack(buf);
43764 if (is_on_stack) {
43765 /*
43766 * dma onto stack is unsafe/nonportable, but callers to this
43767 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43768 index 81b2994..dce857e 100644
43769 --- a/drivers/mmc/host/dw_mmc.h
43770 +++ b/drivers/mmc/host/dw_mmc.h
43771 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43772 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43773 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43774 int (*parse_dt)(struct dw_mci *host);
43775 -};
43776 +} __do_const;
43777 #endif /* _DW_MMC_H_ */
43778 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43779 index c3785ed..1984c44 100644
43780 --- a/drivers/mmc/host/mmci.c
43781 +++ b/drivers/mmc/host/mmci.c
43782 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43783 }
43784
43785 if (variant->busy_detect) {
43786 - mmci_ops.card_busy = mmci_card_busy;
43787 + pax_open_kernel();
43788 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43789 + pax_close_kernel();
43790 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43791 }
43792
43793 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43794 index 926aaf6..8e153e2 100644
43795 --- a/drivers/mmc/host/sdhci-s3c.c
43796 +++ b/drivers/mmc/host/sdhci-s3c.c
43797 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43798 * we can use overriding functions instead of default.
43799 */
43800 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43801 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43802 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43803 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43804 + pax_open_kernel();
43805 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43806 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43807 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43808 + pax_close_kernel();
43809 }
43810
43811 /* It supports additional host capabilities if needed */
43812 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43813 index 0c8bb6b..6f35deb 100644
43814 --- a/drivers/mtd/nand/denali.c
43815 +++ b/drivers/mtd/nand/denali.c
43816 @@ -24,6 +24,7 @@
43817 #include <linux/slab.h>
43818 #include <linux/mtd/mtd.h>
43819 #include <linux/module.h>
43820 +#include <linux/slab.h>
43821
43822 #include "denali.h"
43823
43824 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43825 index 51b9d6a..52af9a7 100644
43826 --- a/drivers/mtd/nftlmount.c
43827 +++ b/drivers/mtd/nftlmount.c
43828 @@ -24,6 +24,7 @@
43829 #include <asm/errno.h>
43830 #include <linux/delay.h>
43831 #include <linux/slab.h>
43832 +#include <linux/sched.h>
43833 #include <linux/mtd/mtd.h>
43834 #include <linux/mtd/nand.h>
43835 #include <linux/mtd/nftl.h>
43836 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
43837 index f9d5615..99dd95f 100644
43838 --- a/drivers/mtd/sm_ftl.c
43839 +++ b/drivers/mtd/sm_ftl.c
43840 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
43841 #define SM_CIS_VENDOR_OFFSET 0x59
43842 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
43843 {
43844 - struct attribute_group *attr_group;
43845 + attribute_group_no_const *attr_group;
43846 struct attribute **attributes;
43847 struct sm_sysfs_attribute *vendor_attribute;
43848
43849 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
43850 index 5e31046..82f8ddc 100644
43851 --- a/drivers/net/bonding/bond_main.c
43852 +++ b/drivers/net/bonding/bond_main.c
43853 @@ -4839,7 +4839,7 @@ static unsigned int bond_get_num_tx_queues(void)
43854 return tx_queues;
43855 }
43856
43857 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
43858 +static struct rtnl_link_ops bond_link_ops = {
43859 .kind = "bond",
43860 .priv_size = sizeof(struct bonding),
43861 .setup = bond_setup,
43862 @@ -4964,8 +4964,8 @@ static void __exit bonding_exit(void)
43863
43864 bond_destroy_debugfs();
43865
43866 - rtnl_link_unregister(&bond_link_ops);
43867 unregister_pernet_subsys(&bond_net_ops);
43868 + rtnl_link_unregister(&bond_link_ops);
43869
43870 #ifdef CONFIG_NET_POLL_CONTROLLER
43871 /*
43872 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
43873 index e1d2643..7f4133b 100644
43874 --- a/drivers/net/ethernet/8390/ax88796.c
43875 +++ b/drivers/net/ethernet/8390/ax88796.c
43876 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
43877 if (ax->plat->reg_offsets)
43878 ei_local->reg_offset = ax->plat->reg_offsets;
43879 else {
43880 + resource_size_t _mem_size = mem_size;
43881 + do_div(_mem_size, 0x18);
43882 ei_local->reg_offset = ax->reg_offsets;
43883 for (ret = 0; ret < 0x18; ret++)
43884 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
43885 + ax->reg_offsets[ret] = _mem_size * ret;
43886 }
43887
43888 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
43889 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43890 index c07a6d0..ca88c45 100644
43891 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43892 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
43893 @@ -1137,7 +1137,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
43894 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
43895 {
43896 /* RX_MODE controlling object */
43897 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
43898 + bnx2x_init_rx_mode_obj(bp);
43899
43900 /* multicast configuration controlling object */
43901 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
43902 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43903 index 8f03c98..dd0ef10 100644
43904 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43905 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
43906 @@ -2345,15 +2345,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
43907 return rc;
43908 }
43909
43910 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43911 - struct bnx2x_rx_mode_obj *o)
43912 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
43913 {
43914 if (CHIP_IS_E1x(bp)) {
43915 - o->wait_comp = bnx2x_empty_rx_mode_wait;
43916 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
43917 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
43918 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
43919 } else {
43920 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
43921 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
43922 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
43923 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
43924 }
43925 }
43926
43927 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43928 index 798dfe9..05d0a44 100644
43929 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43930 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
43931 @@ -1311,8 +1311,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
43932
43933 /********************* RX MODE ****************/
43934
43935 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
43936 - struct bnx2x_rx_mode_obj *o);
43937 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
43938
43939 /**
43940 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
43941 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
43942 index cd63d11..b67dd78 100644
43943 --- a/drivers/net/ethernet/broadcom/tg3.h
43944 +++ b/drivers/net/ethernet/broadcom/tg3.h
43945 @@ -147,6 +147,7 @@
43946 #define CHIPREV_ID_5750_A0 0x4000
43947 #define CHIPREV_ID_5750_A1 0x4001
43948 #define CHIPREV_ID_5750_A3 0x4003
43949 +#define CHIPREV_ID_5750_C1 0x4201
43950 #define CHIPREV_ID_5750_C2 0x4202
43951 #define CHIPREV_ID_5752_A0_HW 0x5000
43952 #define CHIPREV_ID_5752_A0 0x6000
43953 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43954 index 8cffcdf..aadf043 100644
43955 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43956 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
43957 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
43958 */
43959 struct l2t_skb_cb {
43960 arp_failure_handler_func arp_failure_handler;
43961 -};
43962 +} __no_const;
43963
43964 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
43965
43966 diff --git a/drivers/net/ethernet/chelsio/cxgb3/sge.c b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43967 index 9c89dc8..725ecc3 100644
43968 --- a/drivers/net/ethernet/chelsio/cxgb3/sge.c
43969 +++ b/drivers/net/ethernet/chelsio/cxgb3/sge.c
43970 @@ -1599,7 +1599,7 @@ static void write_ofld_wr(struct adapter *adap, struct sk_buff *skb,
43971 flits = skb_transport_offset(skb) / 8;
43972 sgp = ndesc == 1 ? (struct sg_ent *)&d->flit[flits] : sgl;
43973 sgl_flits = make_sgl(skb, sgp, skb_transport_header(skb),
43974 - skb->tail - skb->transport_header,
43975 + skb_tail_pointer(skb) - skb_transport_header(skb),
43976 adap->pdev);
43977 if (need_skb_unmap()) {
43978 setup_deferred_unmapping(skb, adap->pdev, sgp, sgl_flits);
43979 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
43980 index 4c83003..2a2a5b9 100644
43981 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
43982 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
43983 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43984 for (i=0; i<ETH_ALEN; i++) {
43985 tmp.addr[i] = dev->dev_addr[i];
43986 }
43987 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43988 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
43989 break;
43990
43991 case DE4X5_SET_HWADDR: /* Set the hardware address */
43992 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
43993 spin_lock_irqsave(&lp->lock, flags);
43994 memcpy(&statbuf, &lp->pktStats, ioc->len);
43995 spin_unlock_irqrestore(&lp->lock, flags);
43996 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
43997 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
43998 return -EFAULT;
43999 break;
44000 }
44001 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44002 index 3d91a5e..1014702 100644
44003 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44004 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44005 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44006
44007 if (wrapped)
44008 newacc += 65536;
44009 - ACCESS_ONCE(*acc) = newacc;
44010 + ACCESS_ONCE_RW(*acc) = newacc;
44011 }
44012
44013 void populate_erx_stats(struct be_adapter *adapter,
44014 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44015 index 934e1ae..b262e6b 100644
44016 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44017 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44018 @@ -31,6 +31,8 @@
44019 #include <linux/netdevice.h>
44020 #include <linux/phy.h>
44021 #include <linux/platform_device.h>
44022 +#include <linux/interrupt.h>
44023 +#include <linux/irqreturn.h>
44024 #include <net/ip.h>
44025
44026 #include "ftgmac100.h"
44027 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44028 index 4658f4c..407d155 100644
44029 --- a/drivers/net/ethernet/faraday/ftmac100.c
44030 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44031 @@ -31,6 +31,8 @@
44032 #include <linux/module.h>
44033 #include <linux/netdevice.h>
44034 #include <linux/platform_device.h>
44035 +#include <linux/interrupt.h>
44036 +#include <linux/irqreturn.h>
44037
44038 #include "ftmac100.h"
44039
44040 diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
44041 index 85fe7b5..e2da180 100644
44042 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
44043 +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
44044 @@ -2637,6 +2637,8 @@ static int igb_set_eee(struct net_device *netdev,
44045 (hw->phy.media_type != e1000_media_type_copper))
44046 return -EOPNOTSUPP;
44047
44048 + memset(&eee_curr, 0, sizeof(struct ethtool_eee));
44049 +
44050 ret_val = igb_get_eee(netdev, &eee_curr);
44051 if (ret_val)
44052 return ret_val;
44053 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44054 index 331987d..3be1135 100644
44055 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44056 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44057 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44058 }
44059
44060 /* update the base incval used to calculate frequency adjustment */
44061 - ACCESS_ONCE(adapter->base_incval) = incval;
44062 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44063 smp_mb();
44064
44065 /* need lock to prevent incorrect read while modifying cyclecounter */
44066 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44067 index fbe5363..266b4e3 100644
44068 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44069 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44070 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44071 struct __vxge_hw_fifo *fifo;
44072 struct vxge_hw_fifo_config *config;
44073 u32 txdl_size, txdl_per_memblock;
44074 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44075 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44076 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44077 + };
44078 +
44079 struct __vxge_hw_virtualpath *vpath;
44080
44081 if ((vp == NULL) || (attr == NULL)) {
44082 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44083 goto exit;
44084 }
44085
44086 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44087 -
44088 fifo->mempool =
44089 __vxge_hw_mempool_create(vpath->hldev,
44090 fifo->config->memblock_size,
44091 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44092 index 345d987..af69721 100644
44093 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44094 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44095 @@ -2011,7 +2011,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
44096 op_mode = QLC_83XX_DEFAULT_OPMODE;
44097
44098 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
44099 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44100 + pax_open_kernel();
44101 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44102 + pax_close_kernel();
44103 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44104 } else {
44105 return -EIO;
44106 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44107 index 599d1fd..59868fe 100644
44108 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44109 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44110 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44111 case QLCNIC_NON_PRIV_FUNC:
44112 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44113 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44114 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44115 + pax_open_kernel();
44116 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44117 + pax_close_kernel();
44118 break;
44119 case QLCNIC_PRIV_FUNC:
44120 ahw->op_mode = QLCNIC_PRIV_FUNC;
44121 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44122 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44123 + pax_open_kernel();
44124 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44125 + pax_close_kernel();
44126 break;
44127 case QLCNIC_MGMT_FUNC:
44128 ahw->op_mode = QLCNIC_MGMT_FUNC;
44129 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44130 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44131 + pax_open_kernel();
44132 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44133 + pax_close_kernel();
44134 break;
44135 default:
44136 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44137 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44138 index 7ba68e0..618c73d 100644
44139 --- a/drivers/net/ethernet/realtek/r8169.c
44140 +++ b/drivers/net/ethernet/realtek/r8169.c
44141 @@ -759,22 +759,22 @@ struct rtl8169_private {
44142 struct mdio_ops {
44143 void (*write)(struct rtl8169_private *, int, int);
44144 int (*read)(struct rtl8169_private *, int);
44145 - } mdio_ops;
44146 + } __no_const mdio_ops;
44147
44148 struct pll_power_ops {
44149 void (*down)(struct rtl8169_private *);
44150 void (*up)(struct rtl8169_private *);
44151 - } pll_power_ops;
44152 + } __no_const pll_power_ops;
44153
44154 struct jumbo_ops {
44155 void (*enable)(struct rtl8169_private *);
44156 void (*disable)(struct rtl8169_private *);
44157 - } jumbo_ops;
44158 + } __no_const jumbo_ops;
44159
44160 struct csi_ops {
44161 void (*write)(struct rtl8169_private *, int, int);
44162 u32 (*read)(struct rtl8169_private *, int);
44163 - } csi_ops;
44164 + } __no_const csi_ops;
44165
44166 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44167 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44168 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44169 index b495394..0748c54 100644
44170 --- a/drivers/net/ethernet/sfc/ptp.c
44171 +++ b/drivers/net/ethernet/sfc/ptp.c
44172 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44173 (u32)((u64)ptp->start.dma_addr >> 32));
44174
44175 /* Clear flag that signals MC ready */
44176 - ACCESS_ONCE(*start) = 0;
44177 + ACCESS_ONCE_RW(*start) = 0;
44178 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44179 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44180
44181 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44182 index 50617c5..b13724c 100644
44183 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44184 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44185 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44186
44187 writel(value, ioaddr + MMC_CNTRL);
44188
44189 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44190 - MMC_CNTRL, value);
44191 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44192 +// MMC_CNTRL, value);
44193 }
44194
44195 /* To mask all all interrupts.*/
44196 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44197 index e6fe0d8..2b7d752 100644
44198 --- a/drivers/net/hyperv/hyperv_net.h
44199 +++ b/drivers/net/hyperv/hyperv_net.h
44200 @@ -101,7 +101,7 @@ struct rndis_device {
44201
44202 enum rndis_device_state state;
44203 bool link_state;
44204 - atomic_t new_req_id;
44205 + atomic_unchecked_t new_req_id;
44206
44207 spinlock_t request_lock;
44208 struct list_head req_list;
44209 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44210 index 0775f0a..d4fb316 100644
44211 --- a/drivers/net/hyperv/rndis_filter.c
44212 +++ b/drivers/net/hyperv/rndis_filter.c
44213 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44214 * template
44215 */
44216 set = &rndis_msg->msg.set_req;
44217 - set->req_id = atomic_inc_return(&dev->new_req_id);
44218 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44219
44220 /* Add to the request list */
44221 spin_lock_irqsave(&dev->request_lock, flags);
44222 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44223
44224 /* Setup the rndis set */
44225 halt = &request->request_msg.msg.halt_req;
44226 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44227 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44228
44229 /* Ignore return since this msg is optional. */
44230 rndis_filter_send_request(dev, request);
44231 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44232 index bf0d55e..82bcfbd1 100644
44233 --- a/drivers/net/ieee802154/fakehard.c
44234 +++ b/drivers/net/ieee802154/fakehard.c
44235 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44236 phy->transmit_power = 0xbf;
44237
44238 dev->netdev_ops = &fake_ops;
44239 - dev->ml_priv = &fake_mlme;
44240 + dev->ml_priv = (void *)&fake_mlme;
44241
44242 priv = netdev_priv(dev);
44243 priv->phy = phy;
44244 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44245 index 16b43bf..ead0c35 100644
44246 --- a/drivers/net/macvlan.c
44247 +++ b/drivers/net/macvlan.c
44248 @@ -934,13 +934,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44249 int macvlan_link_register(struct rtnl_link_ops *ops)
44250 {
44251 /* common fields */
44252 - ops->priv_size = sizeof(struct macvlan_dev);
44253 - ops->validate = macvlan_validate;
44254 - ops->maxtype = IFLA_MACVLAN_MAX;
44255 - ops->policy = macvlan_policy;
44256 - ops->changelink = macvlan_changelink;
44257 - ops->get_size = macvlan_get_size;
44258 - ops->fill_info = macvlan_fill_info;
44259 + pax_open_kernel();
44260 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44261 + *(void **)&ops->validate = macvlan_validate;
44262 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44263 + *(const void **)&ops->policy = macvlan_policy;
44264 + *(void **)&ops->changelink = macvlan_changelink;
44265 + *(void **)&ops->get_size = macvlan_get_size;
44266 + *(void **)&ops->fill_info = macvlan_fill_info;
44267 + pax_close_kernel();
44268
44269 return rtnl_link_register(ops);
44270 };
44271 @@ -996,7 +998,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44272 return NOTIFY_DONE;
44273 }
44274
44275 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44276 +static struct notifier_block macvlan_notifier_block = {
44277 .notifier_call = macvlan_device_event,
44278 };
44279
44280 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44281 index ea53abb..2e4d087 100644
44282 --- a/drivers/net/macvtap.c
44283 +++ b/drivers/net/macvtap.c
44284 @@ -1286,7 +1286,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44285 return NOTIFY_DONE;
44286 }
44287
44288 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44289 +static struct notifier_block macvtap_notifier_block = {
44290 .notifier_call = macvtap_device_event,
44291 };
44292
44293 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44294 index daec9b0..6428fcb 100644
44295 --- a/drivers/net/phy/mdio-bitbang.c
44296 +++ b/drivers/net/phy/mdio-bitbang.c
44297 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44298 struct mdiobb_ctrl *ctrl = bus->priv;
44299
44300 module_put(ctrl->ops->owner);
44301 + mdiobus_unregister(bus);
44302 mdiobus_free(bus);
44303 }
44304 EXPORT_SYMBOL(free_mdio_bitbang);
44305 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44306 index 72ff14b..11d442d 100644
44307 --- a/drivers/net/ppp/ppp_generic.c
44308 +++ b/drivers/net/ppp/ppp_generic.c
44309 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44310 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44311 struct ppp_stats stats;
44312 struct ppp_comp_stats cstats;
44313 - char *vers;
44314
44315 switch (cmd) {
44316 case SIOCGPPPSTATS:
44317 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44318 break;
44319
44320 case SIOCGPPPVER:
44321 - vers = PPP_VERSION;
44322 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44323 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44324 break;
44325 err = 0;
44326 break;
44327 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44328 index 1252d9c..80e660b 100644
44329 --- a/drivers/net/slip/slhc.c
44330 +++ b/drivers/net/slip/slhc.c
44331 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44332 register struct tcphdr *thp;
44333 register struct iphdr *ip;
44334 register struct cstate *cs;
44335 - int len, hdrlen;
44336 + long len, hdrlen;
44337 unsigned char *cp = icp;
44338
44339 /* We've got a compressed packet; read the change byte */
44340 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44341 index bff7e0b..7315137 100644
44342 --- a/drivers/net/team/team.c
44343 +++ b/drivers/net/team/team.c
44344 @@ -2702,7 +2702,7 @@ static int team_device_event(struct notifier_block *unused,
44345 return NOTIFY_DONE;
44346 }
44347
44348 -static struct notifier_block team_notifier_block __read_mostly = {
44349 +static struct notifier_block team_notifier_block = {
44350 .notifier_call = team_device_event,
44351 };
44352
44353 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44354 index 68b9aa3..b3c20f3 100644
44355 --- a/drivers/net/tun.c
44356 +++ b/drivers/net/tun.c
44357 @@ -1874,7 +1874,7 @@ unlock:
44358 }
44359
44360 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44361 - unsigned long arg, int ifreq_len)
44362 + unsigned long arg, size_t ifreq_len)
44363 {
44364 struct tun_file *tfile = file->private_data;
44365 struct tun_struct *tun;
44366 @@ -1886,6 +1886,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44367 int vnet_hdr_sz;
44368 int ret;
44369
44370 + if (ifreq_len > sizeof ifr)
44371 + return -EFAULT;
44372 +
44373 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44374 if (copy_from_user(&ifr, argp, ifreq_len))
44375 return -EFAULT;
44376 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44377 index 86292e6..8d34433 100644
44378 --- a/drivers/net/usb/hso.c
44379 +++ b/drivers/net/usb/hso.c
44380 @@ -71,7 +71,7 @@
44381 #include <asm/byteorder.h>
44382 #include <linux/serial_core.h>
44383 #include <linux/serial.h>
44384 -
44385 +#include <asm/local.h>
44386
44387 #define MOD_AUTHOR "Option Wireless"
44388 #define MOD_DESCRIPTION "USB High Speed Option driver"
44389 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44390 struct urb *urb;
44391
44392 urb = serial->rx_urb[0];
44393 - if (serial->port.count > 0) {
44394 + if (atomic_read(&serial->port.count) > 0) {
44395 count = put_rxbuf_data(urb, serial);
44396 if (count == -1)
44397 return;
44398 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44399 DUMP1(urb->transfer_buffer, urb->actual_length);
44400
44401 /* Anyone listening? */
44402 - if (serial->port.count == 0)
44403 + if (atomic_read(&serial->port.count) == 0)
44404 return;
44405
44406 if (status == 0) {
44407 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44408 tty_port_tty_set(&serial->port, tty);
44409
44410 /* check for port already opened, if not set the termios */
44411 - serial->port.count++;
44412 - if (serial->port.count == 1) {
44413 + if (atomic_inc_return(&serial->port.count) == 1) {
44414 serial->rx_state = RX_IDLE;
44415 /* Force default termio settings */
44416 _hso_serial_set_termios(tty, NULL);
44417 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44418 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44419 if (result) {
44420 hso_stop_serial_device(serial->parent);
44421 - serial->port.count--;
44422 + atomic_dec(&serial->port.count);
44423 kref_put(&serial->parent->ref, hso_serial_ref_free);
44424 }
44425 } else {
44426 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44427
44428 /* reset the rts and dtr */
44429 /* do the actual close */
44430 - serial->port.count--;
44431 + atomic_dec(&serial->port.count);
44432
44433 - if (serial->port.count <= 0) {
44434 - serial->port.count = 0;
44435 + if (atomic_read(&serial->port.count) <= 0) {
44436 + atomic_set(&serial->port.count, 0);
44437 tty_port_tty_set(&serial->port, NULL);
44438 if (!usb_gone)
44439 hso_stop_serial_device(serial->parent);
44440 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44441
44442 /* the actual setup */
44443 spin_lock_irqsave(&serial->serial_lock, flags);
44444 - if (serial->port.count)
44445 + if (atomic_read(&serial->port.count))
44446 _hso_serial_set_termios(tty, old);
44447 else
44448 tty->termios = *old;
44449 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44450 D1("Pending read interrupt on port %d\n", i);
44451 spin_lock(&serial->serial_lock);
44452 if (serial->rx_state == RX_IDLE &&
44453 - serial->port.count > 0) {
44454 + atomic_read(&serial->port.count) > 0) {
44455 /* Setup and send a ctrl req read on
44456 * port i */
44457 if (!serial->rx_urb_filled[0]) {
44458 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44459 /* Start all serial ports */
44460 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44461 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44462 - if (dev2ser(serial_table[i])->port.count) {
44463 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44464 result =
44465 hso_start_serial_device(serial_table[i], GFP_NOIO);
44466 hso_kick_transmit(dev2ser(serial_table[i]));
44467 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44468 index a79e9d3..78cd4fa 100644
44469 --- a/drivers/net/usb/sierra_net.c
44470 +++ b/drivers/net/usb/sierra_net.c
44471 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44472 /* atomic counter partially included in MAC address to make sure 2 devices
44473 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44474 */
44475 -static atomic_t iface_counter = ATOMIC_INIT(0);
44476 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44477
44478 /*
44479 * SYNC Timer Delay definition used to set the expiry time
44480 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44481 dev->net->netdev_ops = &sierra_net_device_ops;
44482
44483 /* change MAC addr to include, ifacenum, and to be unique */
44484 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44485 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44486 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44487
44488 /* we will have to manufacture ethernet headers, prepare template */
44489 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44490 index 8a05d77..ba8b9c5 100644
44491 --- a/drivers/net/vxlan.c
44492 +++ b/drivers/net/vxlan.c
44493 @@ -1870,7 +1870,7 @@ nla_put_failure:
44494 return -EMSGSIZE;
44495 }
44496
44497 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44498 +static struct rtnl_link_ops vxlan_link_ops = {
44499 .kind = "vxlan",
44500 .maxtype = IFLA_VXLAN_MAX,
44501 .policy = vxlan_policy,
44502 diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
44503 index 3f0c4f2..bcfff0d 100644
44504 --- a/drivers/net/wan/farsync.c
44505 +++ b/drivers/net/wan/farsync.c
44506 @@ -1972,6 +1972,7 @@ fst_get_iface(struct fst_card_info *card, struct fst_port_info *port,
44507 }
44508
44509 i = port->index;
44510 + memset(&sync, 0, sizeof(sync));
44511 sync.clock_rate = FST_RDL(card, portConfig[i].lineSpeed);
44512 /* Lucky card and linux use same encoding here */
44513 sync.clock_type = FST_RDB(card, portConfig[i].internalClock) ==
44514 diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
44515 index 6a24a5a..4c0a697 100644
44516 --- a/drivers/net/wan/wanxl.c
44517 +++ b/drivers/net/wan/wanxl.c
44518 @@ -355,6 +355,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44519 ifr->ifr_settings.size = size; /* data size wanted */
44520 return -ENOBUFS;
44521 }
44522 + memset(&line, 0, sizeof(line));
44523 line.clock_type = get_status(port)->clocking;
44524 line.clock_rate = 0;
44525 line.loopback = 0;
44526 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44527 index 0b60295..b8bfa5b 100644
44528 --- a/drivers/net/wimax/i2400m/rx.c
44529 +++ b/drivers/net/wimax/i2400m/rx.c
44530 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44531 if (i2400m->rx_roq == NULL)
44532 goto error_roq_alloc;
44533
44534 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44535 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44536 GFP_KERNEL);
44537 if (rd == NULL) {
44538 result = -ENOMEM;
44539 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44540 index 34c8a33..3261fdc 100644
44541 --- a/drivers/net/wireless/at76c50x-usb.c
44542 +++ b/drivers/net/wireless/at76c50x-usb.c
44543 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44544 }
44545
44546 /* Convert timeout from the DFU status to jiffies */
44547 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44548 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44549 {
44550 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44551 | (s->poll_timeout[1] << 8)
44552 diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
44553 index 2b3426b..1f564be 100644
44554 --- a/drivers/net/wireless/ath/ath10k/core.c
44555 +++ b/drivers/net/wireless/ath/ath10k/core.c
44556 @@ -507,7 +507,9 @@ EXPORT_SYMBOL(ath10k_core_destroy);
44557
44558 int ath10k_core_register(struct ath10k *ar)
44559 {
44560 - struct ath10k_htc_ops htc_ops;
44561 + static struct ath10k_htc_ops htc_ops = {
44562 + .target_send_suspend_complete = ath10k_send_suspend_complete,
44563 + };
44564 struct bmi_target_info target_info;
44565 int status;
44566
44567 @@ -536,8 +538,6 @@ int ath10k_core_register(struct ath10k *ar)
44568 if (status)
44569 goto err;
44570
44571 - htc_ops.target_send_suspend_complete = ath10k_send_suspend_complete;
44572 -
44573 ar->htc = ath10k_htc_create(ar, &htc_ops);
44574 if (IS_ERR(ar->htc)) {
44575 status = PTR_ERR(ar->htc);
44576 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44577 index 74363c9..237b926 100644
44578 --- a/drivers/net/wireless/ath/ath10k/htc.c
44579 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44580 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44581 struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44582 struct ath10k_htc_ops *htc_ops)
44583 {
44584 - struct ath10k_hif_cb htc_callbacks;
44585 + static struct ath10k_hif_cb htc_callbacks = {
44586 + .rx_completion = ath10k_htc_rx_completion_handler,
44587 + .tx_completion = ath10k_htc_tx_completion_handler,
44588 + };
44589 struct ath10k_htc_ep *ep = NULL;
44590 struct ath10k_htc *htc = NULL;
44591
44592 @@ -979,8 +982,6 @@ struct ath10k_htc *ath10k_htc_create(struct ath10k *ar,
44593 ath10k_htc_reset_endpoint_states(htc);
44594
44595 /* setup HIF layer callbacks */
44596 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44597 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44598 htc->ar = ar;
44599
44600 /* Get HIF default pipe for HTC message exchange */
44601 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44602 index 8d78253..bebbb68 100644
44603 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44604 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44605 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44606 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44607 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44608
44609 - ACCESS_ONCE(ads->ds_link) = i->link;
44610 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44611 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44612 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44613
44614 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44615 ctl6 = SM(i->keytype, AR_EncrType);
44616 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44617
44618 if ((i->is_first || i->is_last) &&
44619 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44620 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44621 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44622 | set11nTries(i->rates, 1)
44623 | set11nTries(i->rates, 2)
44624 | set11nTries(i->rates, 3)
44625 | (i->dur_update ? AR_DurUpdateEna : 0)
44626 | SM(0, AR_BurstDur);
44627
44628 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44629 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44630 | set11nRate(i->rates, 1)
44631 | set11nRate(i->rates, 2)
44632 | set11nRate(i->rates, 3);
44633 } else {
44634 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44635 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44636 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44637 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44638 }
44639
44640 if (!i->is_first) {
44641 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44642 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44643 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44644 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44645 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44646 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44647 return;
44648 }
44649
44650 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44651 break;
44652 }
44653
44654 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44655 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44656 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44657 | SM(i->txpower, AR_XmitPower)
44658 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44659 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44660 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44661 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44662
44663 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44664 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44665 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44666 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44667
44668 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44669 return;
44670
44671 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44672 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44673 | set11nPktDurRTSCTS(i->rates, 1);
44674
44675 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44676 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44677 | set11nPktDurRTSCTS(i->rates, 3);
44678
44679 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44680 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44681 | set11nRateFlags(i->rates, 1)
44682 | set11nRateFlags(i->rates, 2)
44683 | set11nRateFlags(i->rates, 3)
44684 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44685 index 5163abd..3ada4c2 100644
44686 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44687 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44688 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44689 (i->qcu << AR_TxQcuNum_S) | desc_len;
44690
44691 checksum += val;
44692 - ACCESS_ONCE(ads->info) = val;
44693 + ACCESS_ONCE_RW(ads->info) = val;
44694
44695 checksum += i->link;
44696 - ACCESS_ONCE(ads->link) = i->link;
44697 + ACCESS_ONCE_RW(ads->link) = i->link;
44698
44699 checksum += i->buf_addr[0];
44700 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44701 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44702 checksum += i->buf_addr[1];
44703 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44704 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44705 checksum += i->buf_addr[2];
44706 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44707 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44708 checksum += i->buf_addr[3];
44709 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44710 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44711
44712 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44713 - ACCESS_ONCE(ads->ctl3) = val;
44714 + ACCESS_ONCE_RW(ads->ctl3) = val;
44715 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44716 - ACCESS_ONCE(ads->ctl5) = val;
44717 + ACCESS_ONCE_RW(ads->ctl5) = val;
44718 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44719 - ACCESS_ONCE(ads->ctl7) = val;
44720 + ACCESS_ONCE_RW(ads->ctl7) = val;
44721 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44722 - ACCESS_ONCE(ads->ctl9) = val;
44723 + ACCESS_ONCE_RW(ads->ctl9) = val;
44724
44725 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44726 - ACCESS_ONCE(ads->ctl10) = checksum;
44727 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44728
44729 if (i->is_first || i->is_last) {
44730 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44731 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44732 | set11nTries(i->rates, 1)
44733 | set11nTries(i->rates, 2)
44734 | set11nTries(i->rates, 3)
44735 | (i->dur_update ? AR_DurUpdateEna : 0)
44736 | SM(0, AR_BurstDur);
44737
44738 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44739 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44740 | set11nRate(i->rates, 1)
44741 | set11nRate(i->rates, 2)
44742 | set11nRate(i->rates, 3);
44743 } else {
44744 - ACCESS_ONCE(ads->ctl13) = 0;
44745 - ACCESS_ONCE(ads->ctl14) = 0;
44746 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44747 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44748 }
44749
44750 ads->ctl20 = 0;
44751 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44752
44753 ctl17 = SM(i->keytype, AR_EncrType);
44754 if (!i->is_first) {
44755 - ACCESS_ONCE(ads->ctl11) = 0;
44756 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44757 - ACCESS_ONCE(ads->ctl15) = 0;
44758 - ACCESS_ONCE(ads->ctl16) = 0;
44759 - ACCESS_ONCE(ads->ctl17) = ctl17;
44760 - ACCESS_ONCE(ads->ctl18) = 0;
44761 - ACCESS_ONCE(ads->ctl19) = 0;
44762 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44763 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44764 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44765 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44766 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44767 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44768 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44769 return;
44770 }
44771
44772 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44773 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44774 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44775 | SM(i->txpower, AR_XmitPower)
44776 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44777 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44778 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44779 ctl12 |= SM(val, AR_PAPRDChainMask);
44780
44781 - ACCESS_ONCE(ads->ctl12) = ctl12;
44782 - ACCESS_ONCE(ads->ctl17) = ctl17;
44783 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44784 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44785
44786 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44787 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44788 | set11nPktDurRTSCTS(i->rates, 1);
44789
44790 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44791 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44792 | set11nPktDurRTSCTS(i->rates, 3);
44793
44794 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44795 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44796 | set11nRateFlags(i->rates, 1)
44797 | set11nRateFlags(i->rates, 2)
44798 | set11nRateFlags(i->rates, 3)
44799 | SM(i->rtscts_rate, AR_RTSCTSRate);
44800
44801 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44802 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44803 }
44804
44805 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44806 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44807 index cd74b3a..6a28d24 100644
44808 --- a/drivers/net/wireless/ath/ath9k/hw.h
44809 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44810 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
44811
44812 /* ANI */
44813 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44814 -};
44815 +} __no_const;
44816
44817 /**
44818 * struct ath_spec_scan - parameters for Atheros spectral scan
44819 @@ -721,7 +721,7 @@ struct ath_hw_ops {
44820 struct ath_spec_scan *param);
44821 void (*spectral_scan_trigger)(struct ath_hw *ah);
44822 void (*spectral_scan_wait)(struct ath_hw *ah);
44823 -};
44824 +} __no_const;
44825
44826 struct ath_nf_limits {
44827 s16 max;
44828 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
44829 index 9581d07..84f6a76 100644
44830 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
44831 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
44832 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
44833 */
44834 if (il3945_mod_params.disable_hw_scan) {
44835 D_INFO("Disabling hw_scan\n");
44836 - il3945_mac_ops.hw_scan = NULL;
44837 + pax_open_kernel();
44838 + *(void **)&il3945_mac_ops.hw_scan = NULL;
44839 + pax_close_kernel();
44840 }
44841
44842 D_INFO("*** LOAD DRIVER ***\n");
44843 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44844 index d532948..e0d8bb1 100644
44845 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44846 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
44847 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
44848 {
44849 struct iwl_priv *priv = file->private_data;
44850 char buf[64];
44851 - int buf_size;
44852 + size_t buf_size;
44853 u32 offset, len;
44854
44855 memset(buf, 0, sizeof(buf));
44856 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
44857 struct iwl_priv *priv = file->private_data;
44858
44859 char buf[8];
44860 - int buf_size;
44861 + size_t buf_size;
44862 u32 reset_flag;
44863
44864 memset(buf, 0, sizeof(buf));
44865 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
44866 {
44867 struct iwl_priv *priv = file->private_data;
44868 char buf[8];
44869 - int buf_size;
44870 + size_t buf_size;
44871 int ht40;
44872
44873 memset(buf, 0, sizeof(buf));
44874 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
44875 {
44876 struct iwl_priv *priv = file->private_data;
44877 char buf[8];
44878 - int buf_size;
44879 + size_t buf_size;
44880 int value;
44881
44882 memset(buf, 0, sizeof(buf));
44883 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
44884 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
44885 DEBUGFS_READ_FILE_OPS(current_sleep_command);
44886
44887 -static const char *fmt_value = " %-30s %10u\n";
44888 -static const char *fmt_hex = " %-30s 0x%02X\n";
44889 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
44890 -static const char *fmt_header =
44891 +static const char fmt_value[] = " %-30s %10u\n";
44892 +static const char fmt_hex[] = " %-30s 0x%02X\n";
44893 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
44894 +static const char fmt_header[] =
44895 "%-32s current cumulative delta max\n";
44896
44897 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
44898 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
44899 {
44900 struct iwl_priv *priv = file->private_data;
44901 char buf[8];
44902 - int buf_size;
44903 + size_t buf_size;
44904 int clear;
44905
44906 memset(buf, 0, sizeof(buf));
44907 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
44908 {
44909 struct iwl_priv *priv = file->private_data;
44910 char buf[8];
44911 - int buf_size;
44912 + size_t buf_size;
44913 int trace;
44914
44915 memset(buf, 0, sizeof(buf));
44916 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
44917 {
44918 struct iwl_priv *priv = file->private_data;
44919 char buf[8];
44920 - int buf_size;
44921 + size_t buf_size;
44922 int missed;
44923
44924 memset(buf, 0, sizeof(buf));
44925 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
44926
44927 struct iwl_priv *priv = file->private_data;
44928 char buf[8];
44929 - int buf_size;
44930 + size_t buf_size;
44931 int plcp;
44932
44933 memset(buf, 0, sizeof(buf));
44934 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
44935
44936 struct iwl_priv *priv = file->private_data;
44937 char buf[8];
44938 - int buf_size;
44939 + size_t buf_size;
44940 int flush;
44941
44942 memset(buf, 0, sizeof(buf));
44943 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
44944
44945 struct iwl_priv *priv = file->private_data;
44946 char buf[8];
44947 - int buf_size;
44948 + size_t buf_size;
44949 int rts;
44950
44951 if (!priv->cfg->ht_params)
44952 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
44953 {
44954 struct iwl_priv *priv = file->private_data;
44955 char buf[8];
44956 - int buf_size;
44957 + size_t buf_size;
44958
44959 memset(buf, 0, sizeof(buf));
44960 buf_size = min(count, sizeof(buf) - 1);
44961 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
44962 struct iwl_priv *priv = file->private_data;
44963 u32 event_log_flag;
44964 char buf[8];
44965 - int buf_size;
44966 + size_t buf_size;
44967
44968 /* check that the interface is up */
44969 if (!iwl_is_ready(priv))
44970 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
44971 struct iwl_priv *priv = file->private_data;
44972 char buf[8];
44973 u32 calib_disabled;
44974 - int buf_size;
44975 + size_t buf_size;
44976
44977 memset(buf, 0, sizeof(buf));
44978 buf_size = min(count, sizeof(buf) - 1);
44979 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
44980 index 1531a4f..21d2641 100644
44981 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
44982 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
44983 @@ -1180,7 +1180,7 @@ static void iwl_option_config(struct iwl_priv *priv)
44984 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44985 {
44986 struct iwl_nvm_data *data = priv->nvm_data;
44987 - char *debug_msg;
44988 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44989
44990 if (data->sku_cap_11n_enable &&
44991 !priv->cfg->ht_params) {
44992 @@ -1194,7 +1194,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
44993 return -EINVAL;
44994 }
44995
44996 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
44997 IWL_DEBUG_INFO(priv, debug_msg,
44998 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
44999 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45000 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45001 index 390e2f0..75cfbaf 100644
45002 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45003 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45004 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45005 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45006
45007 char buf[8];
45008 - int buf_size;
45009 + size_t buf_size;
45010 u32 reset_flag;
45011
45012 memset(buf, 0, sizeof(buf));
45013 @@ -1371,7 +1371,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45014 {
45015 struct iwl_trans *trans = file->private_data;
45016 char buf[8];
45017 - int buf_size;
45018 + size_t buf_size;
45019 int csr;
45020
45021 memset(buf, 0, sizeof(buf));
45022 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45023 index cb34c78..9fec0dc 100644
45024 --- a/drivers/net/wireless/mac80211_hwsim.c
45025 +++ b/drivers/net/wireless/mac80211_hwsim.c
45026 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
45027
45028 if (channels > 1) {
45029 hwsim_if_comb.num_different_channels = channels;
45030 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45031 - mac80211_hwsim_ops.cancel_hw_scan =
45032 - mac80211_hwsim_cancel_hw_scan;
45033 - mac80211_hwsim_ops.sw_scan_start = NULL;
45034 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45035 - mac80211_hwsim_ops.remain_on_channel =
45036 - mac80211_hwsim_roc;
45037 - mac80211_hwsim_ops.cancel_remain_on_channel =
45038 - mac80211_hwsim_croc;
45039 - mac80211_hwsim_ops.add_chanctx =
45040 - mac80211_hwsim_add_chanctx;
45041 - mac80211_hwsim_ops.remove_chanctx =
45042 - mac80211_hwsim_remove_chanctx;
45043 - mac80211_hwsim_ops.change_chanctx =
45044 - mac80211_hwsim_change_chanctx;
45045 - mac80211_hwsim_ops.assign_vif_chanctx =
45046 - mac80211_hwsim_assign_vif_chanctx;
45047 - mac80211_hwsim_ops.unassign_vif_chanctx =
45048 - mac80211_hwsim_unassign_vif_chanctx;
45049 + pax_open_kernel();
45050 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45051 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45052 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45053 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45054 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45055 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45056 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45057 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45058 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45059 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45060 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45061 + pax_close_kernel();
45062 }
45063
45064 spin_lock_init(&hwsim_radio_lock);
45065 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45066 index 8169a85..7fa3b47 100644
45067 --- a/drivers/net/wireless/rndis_wlan.c
45068 +++ b/drivers/net/wireless/rndis_wlan.c
45069 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45070
45071 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45072
45073 - if (rts_threshold < 0 || rts_threshold > 2347)
45074 + if (rts_threshold > 2347)
45075 rts_threshold = 2347;
45076
45077 tmp = cpu_to_le32(rts_threshold);
45078 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45079 index ee3fc57..ed5ddc9 100644
45080 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45081 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45082 @@ -386,7 +386,7 @@ struct rt2x00_intf {
45083 * for hardware which doesn't support hardware
45084 * sequence counting.
45085 */
45086 - atomic_t seqno;
45087 + atomic_unchecked_t seqno;
45088 };
45089
45090 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45091 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45092 index aa95c6c..a59dd67 100644
45093 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45094 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45095 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45096 * sequence counter given by mac80211.
45097 */
45098 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45099 - seqno = atomic_add_return(0x10, &intf->seqno);
45100 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45101 else
45102 - seqno = atomic_read(&intf->seqno);
45103 + seqno = atomic_read_unchecked(&intf->seqno);
45104
45105 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45106 hdr->seq_ctrl |= cpu_to_le16(seqno);
45107 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45108 index e2b3d9c..67a5184 100644
45109 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45110 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45111 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45112
45113 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45114
45115 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45116 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45117 + pax_open_kernel();
45118 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45119 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45120 + pax_close_kernel();
45121
45122 wl1251_info("using dedicated interrupt line");
45123 } else {
45124 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45125 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45126 + pax_open_kernel();
45127 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45128 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45129 + pax_close_kernel();
45130
45131 wl1251_info("using SDIO interrupt");
45132 }
45133 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45134 index 1c627da..69f7d17 100644
45135 --- a/drivers/net/wireless/ti/wl12xx/main.c
45136 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45137 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45138 sizeof(wl->conf.mem));
45139
45140 /* read data preparation is only needed by wl127x */
45141 - wl->ops->prepare_read = wl127x_prepare_read;
45142 + pax_open_kernel();
45143 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45144 + pax_close_kernel();
45145
45146 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45147 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45148 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45149 sizeof(wl->conf.mem));
45150
45151 /* read data preparation is only needed by wl127x */
45152 - wl->ops->prepare_read = wl127x_prepare_read;
45153 + pax_open_kernel();
45154 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45155 + pax_close_kernel();
45156
45157 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45158 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45159 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45160 index 7aa0eb8..5a9ef38 100644
45161 --- a/drivers/net/wireless/ti/wl18xx/main.c
45162 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45163 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45164 }
45165
45166 if (!checksum_param) {
45167 - wl18xx_ops.set_rx_csum = NULL;
45168 - wl18xx_ops.init_vif = NULL;
45169 + pax_open_kernel();
45170 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45171 + *(void **)&wl18xx_ops.init_vif = NULL;
45172 + pax_close_kernel();
45173 }
45174
45175 /* Enable 11a Band only if we have 5G antennas */
45176 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45177 index 7ef0b4a..ff65c28 100644
45178 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45179 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45180 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45181 {
45182 struct zd_usb *usb = urb->context;
45183 struct zd_usb_interrupt *intr = &usb->intr;
45184 - int len;
45185 + unsigned int len;
45186 u16 int_num;
45187
45188 ZD_ASSERT(in_interrupt());
45189 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45190 index d93b2b6..ae50401 100644
45191 --- a/drivers/oprofile/buffer_sync.c
45192 +++ b/drivers/oprofile/buffer_sync.c
45193 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45194 if (cookie == NO_COOKIE)
45195 offset = pc;
45196 if (cookie == INVALID_COOKIE) {
45197 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45198 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45199 offset = pc;
45200 }
45201 if (cookie != last_cookie) {
45202 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45203 /* add userspace sample */
45204
45205 if (!mm) {
45206 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45207 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45208 return 0;
45209 }
45210
45211 cookie = lookup_dcookie(mm, s->eip, &offset);
45212
45213 if (cookie == INVALID_COOKIE) {
45214 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45215 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45216 return 0;
45217 }
45218
45219 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45220 /* ignore backtraces if failed to add a sample */
45221 if (state == sb_bt_start) {
45222 state = sb_bt_ignore;
45223 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45224 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45225 }
45226 }
45227 release_mm(mm);
45228 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45229 index c0cc4e7..44d4e54 100644
45230 --- a/drivers/oprofile/event_buffer.c
45231 +++ b/drivers/oprofile/event_buffer.c
45232 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45233 }
45234
45235 if (buffer_pos == buffer_size) {
45236 - atomic_inc(&oprofile_stats.event_lost_overflow);
45237 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45238 return;
45239 }
45240
45241 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45242 index ed2c3ec..deda85a 100644
45243 --- a/drivers/oprofile/oprof.c
45244 +++ b/drivers/oprofile/oprof.c
45245 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45246 if (oprofile_ops.switch_events())
45247 return;
45248
45249 - atomic_inc(&oprofile_stats.multiplex_counter);
45250 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45251 start_switch_worker();
45252 }
45253
45254 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45255 index 84a208d..d61b0a1 100644
45256 --- a/drivers/oprofile/oprofile_files.c
45257 +++ b/drivers/oprofile/oprofile_files.c
45258 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45259
45260 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45261
45262 -static ssize_t timeout_read(struct file *file, char __user *buf,
45263 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45264 size_t count, loff_t *offset)
45265 {
45266 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45267 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45268 index 917d28e..d62d981 100644
45269 --- a/drivers/oprofile/oprofile_stats.c
45270 +++ b/drivers/oprofile/oprofile_stats.c
45271 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45272 cpu_buf->sample_invalid_eip = 0;
45273 }
45274
45275 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45276 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45277 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45278 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45279 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45280 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45281 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45282 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45283 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45284 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45285 }
45286
45287
45288 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45289 index 38b6fc0..b5cbfce 100644
45290 --- a/drivers/oprofile/oprofile_stats.h
45291 +++ b/drivers/oprofile/oprofile_stats.h
45292 @@ -13,11 +13,11 @@
45293 #include <linux/atomic.h>
45294
45295 struct oprofile_stat_struct {
45296 - atomic_t sample_lost_no_mm;
45297 - atomic_t sample_lost_no_mapping;
45298 - atomic_t bt_lost_no_mapping;
45299 - atomic_t event_lost_overflow;
45300 - atomic_t multiplex_counter;
45301 + atomic_unchecked_t sample_lost_no_mm;
45302 + atomic_unchecked_t sample_lost_no_mapping;
45303 + atomic_unchecked_t bt_lost_no_mapping;
45304 + atomic_unchecked_t event_lost_overflow;
45305 + atomic_unchecked_t multiplex_counter;
45306 };
45307
45308 extern struct oprofile_stat_struct oprofile_stats;
45309 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45310 index 7c12d9c..558bf3bb 100644
45311 --- a/drivers/oprofile/oprofilefs.c
45312 +++ b/drivers/oprofile/oprofilefs.c
45313 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
45314
45315
45316 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
45317 - char const *name, atomic_t *val)
45318 + char const *name, atomic_unchecked_t *val)
45319 {
45320 return __oprofilefs_create_file(sb, root, name,
45321 &atomic_ro_fops, 0444, val);
45322 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45323 index 61be1d9..dec05d7 100644
45324 --- a/drivers/oprofile/timer_int.c
45325 +++ b/drivers/oprofile/timer_int.c
45326 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45327 return NOTIFY_OK;
45328 }
45329
45330 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45331 +static struct notifier_block oprofile_cpu_notifier = {
45332 .notifier_call = oprofile_cpu_notify,
45333 };
45334
45335 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45336 index 92ed045..62d39bd7 100644
45337 --- a/drivers/parport/procfs.c
45338 +++ b/drivers/parport/procfs.c
45339 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45340
45341 *ppos += len;
45342
45343 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45344 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45345 }
45346
45347 #ifdef CONFIG_PARPORT_1284
45348 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45349
45350 *ppos += len;
45351
45352 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45353 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45354 }
45355 #endif /* IEEE1284.3 support. */
45356
45357 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45358 index c35e8ad..fc33beb 100644
45359 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45360 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45361 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
45362 goto init_cleanup;
45363 }
45364
45365 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45366 + pax_open_kernel();
45367 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45368 + pax_close_kernel();
45369 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45370
45371 return retval;
45372 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45373 index a6a71c4..c91097b 100644
45374 --- a/drivers/pci/hotplug/cpcihp_generic.c
45375 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45376 @@ -73,7 +73,6 @@ static u16 port;
45377 static unsigned int enum_bit;
45378 static u8 enum_mask;
45379
45380 -static struct cpci_hp_controller_ops generic_hpc_ops;
45381 static struct cpci_hp_controller generic_hpc;
45382
45383 static int __init validate_parameters(void)
45384 @@ -139,6 +138,10 @@ static int query_enum(void)
45385 return ((value & enum_mask) == enum_mask);
45386 }
45387
45388 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45389 + .query_enum = query_enum,
45390 +};
45391 +
45392 static int __init cpcihp_generic_init(void)
45393 {
45394 int status;
45395 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45396 pci_dev_put(dev);
45397
45398 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45399 - generic_hpc_ops.query_enum = query_enum;
45400 generic_hpc.ops = &generic_hpc_ops;
45401
45402 status = cpci_hp_register_controller(&generic_hpc);
45403 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45404 index 449b4bb..257e2e8 100644
45405 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45406 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45407 @@ -59,7 +59,6 @@
45408 /* local variables */
45409 static bool debug;
45410 static bool poll;
45411 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45412 static struct cpci_hp_controller zt5550_hpc;
45413
45414 /* Primary cPCI bus bridge device */
45415 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45416 return 0;
45417 }
45418
45419 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45420 + .query_enum = zt5550_hc_query_enum,
45421 +};
45422 +
45423 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45424 {
45425 int status;
45426 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45427 dbg("returned from zt5550_hc_config");
45428
45429 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45430 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45431 zt5550_hpc.ops = &zt5550_hpc_ops;
45432 if(!poll) {
45433 zt5550_hpc.irq = hc_dev->irq;
45434 zt5550_hpc.irq_flags = IRQF_SHARED;
45435 zt5550_hpc.dev_id = hc_dev;
45436
45437 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45438 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45439 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45440 + pax_open_kernel();
45441 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45442 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45443 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45444 + pax_open_kernel();
45445 } else {
45446 info("using ENUM# polling mode");
45447 }
45448 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45449 index 76ba8a1..20ca857 100644
45450 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45451 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45452 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45453
45454 void compaq_nvram_init (void __iomem *rom_start)
45455 {
45456 +
45457 +#ifndef CONFIG_PAX_KERNEXEC
45458 if (rom_start) {
45459 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45460 }
45461 +#endif
45462 +
45463 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45464
45465 /* initialize our int15 lock */
45466 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45467 index ec20f74..c1d961e 100644
45468 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45469 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45470 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45471 return -EINVAL;
45472 }
45473
45474 - slot->ops->owner = owner;
45475 - slot->ops->mod_name = mod_name;
45476 + pax_open_kernel();
45477 + *(struct module **)&slot->ops->owner = owner;
45478 + *(const char **)&slot->ops->mod_name = mod_name;
45479 + pax_close_kernel();
45480
45481 mutex_lock(&pci_hp_mutex);
45482 /*
45483 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45484 index 7d72c5e..edce02c 100644
45485 --- a/drivers/pci/hotplug/pciehp_core.c
45486 +++ b/drivers/pci/hotplug/pciehp_core.c
45487 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
45488 struct slot *slot = ctrl->slot;
45489 struct hotplug_slot *hotplug = NULL;
45490 struct hotplug_slot_info *info = NULL;
45491 - struct hotplug_slot_ops *ops = NULL;
45492 + hotplug_slot_ops_no_const *ops = NULL;
45493 char name[SLOT_NAME_SIZE];
45494 int retval = -ENOMEM;
45495
45496 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45497 index c0dbe1f..94cf3d8 100644
45498 --- a/drivers/pci/pci-sysfs.c
45499 +++ b/drivers/pci/pci-sysfs.c
45500 @@ -1073,7 +1073,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45501 {
45502 /* allocate attribute structure, piggyback attribute name */
45503 int name_len = write_combine ? 13 : 10;
45504 - struct bin_attribute *res_attr;
45505 + bin_attribute_no_const *res_attr;
45506 int retval;
45507
45508 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45509 @@ -1258,7 +1258,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45510 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45511 {
45512 int retval;
45513 - struct bin_attribute *attr;
45514 + bin_attribute_no_const *attr;
45515
45516 /* If the device has VPD, try to expose it in sysfs. */
45517 if (dev->vpd) {
45518 @@ -1305,7 +1305,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45519 {
45520 int retval;
45521 int rom_size = 0;
45522 - struct bin_attribute *attr;
45523 + bin_attribute_no_const *attr;
45524
45525 if (!sysfs_initialized)
45526 return -EACCES;
45527 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45528 index d1182c4..2a138ec 100644
45529 --- a/drivers/pci/pci.h
45530 +++ b/drivers/pci/pci.h
45531 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
45532 struct pci_vpd {
45533 unsigned int len;
45534 const struct pci_vpd_ops *ops;
45535 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45536 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45537 };
45538
45539 int pci_vpd_pci22_init(struct pci_dev *dev);
45540 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45541 index 403a443..034e050 100644
45542 --- a/drivers/pci/pcie/aspm.c
45543 +++ b/drivers/pci/pcie/aspm.c
45544 @@ -27,9 +27,9 @@
45545 #define MODULE_PARAM_PREFIX "pcie_aspm."
45546
45547 /* Note: those are not register definitions */
45548 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45549 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45550 -#define ASPM_STATE_L1 (4) /* L1 state */
45551 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45552 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45553 +#define ASPM_STATE_L1 (4U) /* L1 state */
45554 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45555 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45556
45557 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45558 index 46ada5c..20da716 100644
45559 --- a/drivers/pci/probe.c
45560 +++ b/drivers/pci/probe.c
45561 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45562 struct pci_bus_region region, inverted_region;
45563 bool bar_too_big = false, bar_disabled = false;
45564
45565 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45566 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45567
45568 /* No printks while decoding is disabled! */
45569 if (!dev->mmio_always_on) {
45570 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45571 index cdc7836..528635c 100644
45572 --- a/drivers/pci/proc.c
45573 +++ b/drivers/pci/proc.c
45574 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45575 static int __init pci_proc_init(void)
45576 {
45577 struct pci_dev *dev = NULL;
45578 +
45579 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45580 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45581 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45582 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45583 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45584 +#endif
45585 +#else
45586 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45587 +#endif
45588 proc_create("devices", 0, proc_bus_pci_dir,
45589 &proc_bus_pci_dev_operations);
45590 proc_initialized = 1;
45591 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45592 index 3e5b4497..dcdfb70 100644
45593 --- a/drivers/platform/x86/chromeos_laptop.c
45594 +++ b/drivers/platform/x86/chromeos_laptop.c
45595 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45596 return 0;
45597 }
45598
45599 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45600 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45601 {
45602 .ident = "Samsung Series 5 550 - Touchpad",
45603 .matches = {
45604 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45605 index 62f8030..c7f2a45 100644
45606 --- a/drivers/platform/x86/msi-laptop.c
45607 +++ b/drivers/platform/x86/msi-laptop.c
45608 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45609
45610 if (!quirks->ec_read_only) {
45611 /* allow userland write sysfs file */
45612 - dev_attr_bluetooth.store = store_bluetooth;
45613 - dev_attr_wlan.store = store_wlan;
45614 - dev_attr_threeg.store = store_threeg;
45615 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45616 - dev_attr_wlan.attr.mode |= S_IWUSR;
45617 - dev_attr_threeg.attr.mode |= S_IWUSR;
45618 + pax_open_kernel();
45619 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45620 + *(void **)&dev_attr_wlan.store = store_wlan;
45621 + *(void **)&dev_attr_threeg.store = store_threeg;
45622 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45623 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45624 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45625 + pax_close_kernel();
45626 }
45627
45628 /* disable hardware control by fn key */
45629 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45630 index 3a1b6bf..b453930 100644
45631 --- a/drivers/platform/x86/sony-laptop.c
45632 +++ b/drivers/platform/x86/sony-laptop.c
45633 @@ -2486,7 +2486,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45634 }
45635
45636 /* High speed charging function */
45637 -static struct device_attribute *hsc_handle;
45638 +static device_attribute_no_const *hsc_handle;
45639
45640 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45641 struct device_attribute *attr,
45642 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45643 index 54d31c0..3f896d3 100644
45644 --- a/drivers/platform/x86/thinkpad_acpi.c
45645 +++ b/drivers/platform/x86/thinkpad_acpi.c
45646 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
45647 return 0;
45648 }
45649
45650 -void static hotkey_mask_warn_incomplete_mask(void)
45651 +static void hotkey_mask_warn_incomplete_mask(void)
45652 {
45653 /* log only what the user can fix... */
45654 const u32 wantedmask = hotkey_driver_mask &
45655 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45656 }
45657 }
45658
45659 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45660 - struct tp_nvram_state *newn,
45661 - const u32 event_mask)
45662 -{
45663 -
45664 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45665 do { \
45666 if ((event_mask & (1 << __scancode)) && \
45667 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45668 tpacpi_hotkey_send_key(__scancode); \
45669 } while (0)
45670
45671 - void issue_volchange(const unsigned int oldvol,
45672 - const unsigned int newvol)
45673 - {
45674 - unsigned int i = oldvol;
45675 +static void issue_volchange(const unsigned int oldvol,
45676 + const unsigned int newvol,
45677 + const u32 event_mask)
45678 +{
45679 + unsigned int i = oldvol;
45680
45681 - while (i > newvol) {
45682 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45683 - i--;
45684 - }
45685 - while (i < newvol) {
45686 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45687 - i++;
45688 - }
45689 + while (i > newvol) {
45690 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45691 + i--;
45692 }
45693 + while (i < newvol) {
45694 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45695 + i++;
45696 + }
45697 +}
45698
45699 - void issue_brightnesschange(const unsigned int oldbrt,
45700 - const unsigned int newbrt)
45701 - {
45702 - unsigned int i = oldbrt;
45703 +static void issue_brightnesschange(const unsigned int oldbrt,
45704 + const unsigned int newbrt,
45705 + const u32 event_mask)
45706 +{
45707 + unsigned int i = oldbrt;
45708
45709 - while (i > newbrt) {
45710 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45711 - i--;
45712 - }
45713 - while (i < newbrt) {
45714 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45715 - i++;
45716 - }
45717 + while (i > newbrt) {
45718 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45719 + i--;
45720 + }
45721 + while (i < newbrt) {
45722 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45723 + i++;
45724 }
45725 +}
45726
45727 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45728 + struct tp_nvram_state *newn,
45729 + const u32 event_mask)
45730 +{
45731 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45732 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45733 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45734 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45735 oldn->volume_level != newn->volume_level) {
45736 /* recently muted, or repeated mute keypress, or
45737 * multiple presses ending in mute */
45738 - issue_volchange(oldn->volume_level, newn->volume_level);
45739 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45740 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45741 }
45742 } else {
45743 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45744 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45745 }
45746 if (oldn->volume_level != newn->volume_level) {
45747 - issue_volchange(oldn->volume_level, newn->volume_level);
45748 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45749 } else if (oldn->volume_toggle != newn->volume_toggle) {
45750 /* repeated vol up/down keypress at end of scale ? */
45751 if (newn->volume_level == 0)
45752 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45753 /* handle brightness */
45754 if (oldn->brightness_level != newn->brightness_level) {
45755 issue_brightnesschange(oldn->brightness_level,
45756 - newn->brightness_level);
45757 + newn->brightness_level,
45758 + event_mask);
45759 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
45760 /* repeated key presses that didn't change state */
45761 if (newn->brightness_level == 0)
45762 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45763 && !tp_features.bright_unkfw)
45764 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45765 }
45766 +}
45767
45768 #undef TPACPI_COMPARE_KEY
45769 #undef TPACPI_MAY_SEND_KEY
45770 -}
45771
45772 /*
45773 * Polling driver
45774 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
45775 index 769d265..a3a05ca 100644
45776 --- a/drivers/pnp/pnpbios/bioscalls.c
45777 +++ b/drivers/pnp/pnpbios/bioscalls.c
45778 @@ -58,7 +58,7 @@ do { \
45779 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
45780 } while(0)
45781
45782 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
45783 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
45784 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
45785
45786 /*
45787 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45788
45789 cpu = get_cpu();
45790 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
45791 +
45792 + pax_open_kernel();
45793 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
45794 + pax_close_kernel();
45795
45796 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
45797 spin_lock_irqsave(&pnp_bios_lock, flags);
45798 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
45799 :"memory");
45800 spin_unlock_irqrestore(&pnp_bios_lock, flags);
45801
45802 + pax_open_kernel();
45803 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
45804 + pax_close_kernel();
45805 +
45806 put_cpu();
45807
45808 /* If we get here and this is set then the PnP BIOS faulted on us. */
45809 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
45810 return status;
45811 }
45812
45813 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
45814 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
45815 {
45816 int i;
45817
45818 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45819 pnp_bios_callpoint.offset = header->fields.pm16offset;
45820 pnp_bios_callpoint.segment = PNP_CS16;
45821
45822 + pax_open_kernel();
45823 +
45824 for_each_possible_cpu(i) {
45825 struct desc_struct *gdt = get_cpu_gdt_table(i);
45826 if (!gdt)
45827 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
45828 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
45829 (unsigned long)__va(header->fields.pm16dseg));
45830 }
45831 +
45832 + pax_close_kernel();
45833 }
45834 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
45835 index d95e101..67f0c3f 100644
45836 --- a/drivers/pnp/resource.c
45837 +++ b/drivers/pnp/resource.c
45838 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
45839 return 1;
45840
45841 /* check if the resource is valid */
45842 - if (*irq < 0 || *irq > 15)
45843 + if (*irq > 15)
45844 return 0;
45845
45846 /* check if the resource is reserved */
45847 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
45848 return 1;
45849
45850 /* check if the resource is valid */
45851 - if (*dma < 0 || *dma == 4 || *dma > 7)
45852 + if (*dma == 4 || *dma > 7)
45853 return 0;
45854
45855 /* check if the resource is reserved */
45856 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
45857 index 0c52e2a..3421ab7 100644
45858 --- a/drivers/power/pda_power.c
45859 +++ b/drivers/power/pda_power.c
45860 @@ -37,7 +37,11 @@ static int polling;
45861
45862 #if IS_ENABLED(CONFIG_USB_PHY)
45863 static struct usb_phy *transceiver;
45864 -static struct notifier_block otg_nb;
45865 +static int otg_handle_notification(struct notifier_block *nb,
45866 + unsigned long event, void *unused);
45867 +static struct notifier_block otg_nb = {
45868 + .notifier_call = otg_handle_notification
45869 +};
45870 #endif
45871
45872 static struct regulator *ac_draw;
45873 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
45874
45875 #if IS_ENABLED(CONFIG_USB_PHY)
45876 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
45877 - otg_nb.notifier_call = otg_handle_notification;
45878 ret = usb_register_notifier(transceiver, &otg_nb);
45879 if (ret) {
45880 dev_err(dev, "failure to register otg notifier\n");
45881 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
45882 index cc439fd..8fa30df 100644
45883 --- a/drivers/power/power_supply.h
45884 +++ b/drivers/power/power_supply.h
45885 @@ -16,12 +16,12 @@ struct power_supply;
45886
45887 #ifdef CONFIG_SYSFS
45888
45889 -extern void power_supply_init_attrs(struct device_type *dev_type);
45890 +extern void power_supply_init_attrs(void);
45891 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
45892
45893 #else
45894
45895 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
45896 +static inline void power_supply_init_attrs(void) {}
45897 #define power_supply_uevent NULL
45898
45899 #endif /* CONFIG_SYSFS */
45900 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
45901 index 3b2d5df..3207114 100644
45902 --- a/drivers/power/power_supply_core.c
45903 +++ b/drivers/power/power_supply_core.c
45904 @@ -24,7 +24,10 @@
45905 struct class *power_supply_class;
45906 EXPORT_SYMBOL_GPL(power_supply_class);
45907
45908 -static struct device_type power_supply_dev_type;
45909 +extern const struct attribute_group *power_supply_attr_groups[];
45910 +static struct device_type power_supply_dev_type = {
45911 + .groups = power_supply_attr_groups,
45912 +};
45913
45914 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
45915 struct power_supply *supply)
45916 @@ -558,7 +561,7 @@ static int __init power_supply_class_init(void)
45917 return PTR_ERR(power_supply_class);
45918
45919 power_supply_class->dev_uevent = power_supply_uevent;
45920 - power_supply_init_attrs(&power_supply_dev_type);
45921 + power_supply_init_attrs();
45922
45923 return 0;
45924 }
45925 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
45926 index 29178f7..c65f324 100644
45927 --- a/drivers/power/power_supply_sysfs.c
45928 +++ b/drivers/power/power_supply_sysfs.c
45929 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
45930 .is_visible = power_supply_attr_is_visible,
45931 };
45932
45933 -static const struct attribute_group *power_supply_attr_groups[] = {
45934 +const struct attribute_group *power_supply_attr_groups[] = {
45935 &power_supply_attr_group,
45936 NULL,
45937 };
45938
45939 -void power_supply_init_attrs(struct device_type *dev_type)
45940 +void power_supply_init_attrs(void)
45941 {
45942 int i;
45943
45944 - dev_type->groups = power_supply_attr_groups;
45945 -
45946 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
45947 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
45948 }
45949 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
45950 index 288c75a..065bc84 100644
45951 --- a/drivers/regulator/core.c
45952 +++ b/drivers/regulator/core.c
45953 @@ -3544,7 +3544,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45954 {
45955 const struct regulation_constraints *constraints = NULL;
45956 const struct regulator_init_data *init_data;
45957 - static atomic_t regulator_no = ATOMIC_INIT(0);
45958 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
45959 struct regulator_dev *rdev;
45960 struct device *dev;
45961 int ret, i;
45962 @@ -3614,7 +3614,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
45963 rdev->dev.of_node = config->of_node;
45964 rdev->dev.parent = dev;
45965 dev_set_name(&rdev->dev, "regulator.%d",
45966 - atomic_inc_return(&regulator_no) - 1);
45967 + atomic_inc_return_unchecked(&regulator_no) - 1);
45968 ret = device_register(&rdev->dev);
45969 if (ret != 0) {
45970 put_device(&rdev->dev);
45971 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
45972 index d428ef9..fdc0357 100644
45973 --- a/drivers/regulator/max8660.c
45974 +++ b/drivers/regulator/max8660.c
45975 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
45976 max8660->shadow_regs[MAX8660_OVER1] = 5;
45977 } else {
45978 /* Otherwise devices can be toggled via software */
45979 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
45980 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
45981 + pax_open_kernel();
45982 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
45983 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
45984 + pax_close_kernel();
45985 }
45986
45987 /*
45988 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
45989 index 0c5195a..637a453d 100644
45990 --- a/drivers/regulator/max8973-regulator.c
45991 +++ b/drivers/regulator/max8973-regulator.c
45992 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
45993 if (!pdata || !pdata->enable_ext_control) {
45994 max->desc.enable_reg = MAX8973_VOUT;
45995 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
45996 - max->ops.enable = regulator_enable_regmap;
45997 - max->ops.disable = regulator_disable_regmap;
45998 - max->ops.is_enabled = regulator_is_enabled_regmap;
45999 + pax_open_kernel();
46000 + *(void **)&max->ops.enable = regulator_enable_regmap;
46001 + *(void **)&max->ops.disable = regulator_disable_regmap;
46002 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
46003 + pax_close_kernel();
46004 }
46005
46006 if (pdata) {
46007 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46008 index 1037e07..e64dea1 100644
46009 --- a/drivers/regulator/mc13892-regulator.c
46010 +++ b/drivers/regulator/mc13892-regulator.c
46011 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46012 }
46013 mc13xxx_unlock(mc13892);
46014
46015 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46016 + pax_open_kernel();
46017 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46018 = mc13892_vcam_set_mode;
46019 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46020 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46021 = mc13892_vcam_get_mode;
46022 + pax_close_kernel();
46023
46024 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46025 ARRAY_SIZE(mc13892_regulators));
46026 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46027 index be06d71..264aee9 100644
46028 --- a/drivers/rtc/rtc-cmos.c
46029 +++ b/drivers/rtc/rtc-cmos.c
46030 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46031 hpet_rtc_timer_init();
46032
46033 /* export at least the first block of NVRAM */
46034 - nvram.size = address_space - NVRAM_OFFSET;
46035 + pax_open_kernel();
46036 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46037 + pax_close_kernel();
46038 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46039 if (retval < 0) {
46040 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46041 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46042 index d049393..bb20be0 100644
46043 --- a/drivers/rtc/rtc-dev.c
46044 +++ b/drivers/rtc/rtc-dev.c
46045 @@ -16,6 +16,7 @@
46046 #include <linux/module.h>
46047 #include <linux/rtc.h>
46048 #include <linux/sched.h>
46049 +#include <linux/grsecurity.h>
46050 #include "rtc-core.h"
46051
46052 static dev_t rtc_devt;
46053 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46054 if (copy_from_user(&tm, uarg, sizeof(tm)))
46055 return -EFAULT;
46056
46057 + gr_log_timechange();
46058 +
46059 return rtc_set_time(rtc, &tm);
46060
46061 case RTC_PIE_ON:
46062 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46063 index ca18fd1..055e42d 100644
46064 --- a/drivers/rtc/rtc-ds1307.c
46065 +++ b/drivers/rtc/rtc-ds1307.c
46066 @@ -107,7 +107,7 @@ struct ds1307 {
46067 u8 offset; /* register's offset */
46068 u8 regs[11];
46069 u16 nvram_offset;
46070 - struct bin_attribute *nvram;
46071 + bin_attribute_no_const *nvram;
46072 enum ds_type type;
46073 unsigned long flags;
46074 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46075 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46076 index fcb0329..d77b7f2 100644
46077 --- a/drivers/rtc/rtc-m48t59.c
46078 +++ b/drivers/rtc/rtc-m48t59.c
46079 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46080 if (IS_ERR(m48t59->rtc))
46081 return PTR_ERR(m48t59->rtc);
46082
46083 - m48t59_nvram_attr.size = pdata->offset;
46084 + pax_open_kernel();
46085 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46086 + pax_close_kernel();
46087
46088 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46089 if (ret)
46090 diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
46091 index 408a42e..f0d432c 100644
46092 --- a/drivers/scsi/aacraid/linit.c
46093 +++ b/drivers/scsi/aacraid/linit.c
46094 @@ -771,6 +771,8 @@ static long aac_compat_do_ioctl(struct aac_dev *dev, unsigned cmd, unsigned long
46095 static int aac_compat_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
46096 {
46097 struct aac_dev *dev = (struct aac_dev *)sdev->host->hostdata;
46098 + if (!capable(CAP_SYS_RAWIO))
46099 + return -EPERM;
46100 return aac_compat_do_ioctl(dev, cmd, (unsigned long)arg);
46101 }
46102
46103 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46104 index e693af6..2e525b6 100644
46105 --- a/drivers/scsi/bfa/bfa_fcpim.h
46106 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46107 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46108
46109 struct bfa_itn_s {
46110 bfa_isr_func_t isr;
46111 -};
46112 +} __no_const;
46113
46114 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46115 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46116 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46117 index 90814fe..4384138 100644
46118 --- a/drivers/scsi/bfa/bfa_ioc.h
46119 +++ b/drivers/scsi/bfa/bfa_ioc.h
46120 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46121 bfa_ioc_disable_cbfn_t disable_cbfn;
46122 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46123 bfa_ioc_reset_cbfn_t reset_cbfn;
46124 -};
46125 +} __no_const;
46126
46127 /*
46128 * IOC event notification mechanism.
46129 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46130 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46131 enum bfi_ioc_state fwstate);
46132 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46133 -};
46134 +} __no_const;
46135
46136 /*
46137 * Queue element to wait for room in request queue. FIFO order is
46138 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46139 index c9382d6..6619864 100644
46140 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46141 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46142 @@ -33,8 +33,8 @@
46143 */
46144 #include "libfcoe.h"
46145
46146 -static atomic_t ctlr_num;
46147 -static atomic_t fcf_num;
46148 +static atomic_unchecked_t ctlr_num;
46149 +static atomic_unchecked_t fcf_num;
46150
46151 /*
46152 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46153 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46154 if (!ctlr)
46155 goto out;
46156
46157 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46158 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46159 ctlr->f = f;
46160 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46161 INIT_LIST_HEAD(&ctlr->fcfs);
46162 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46163 fcf->dev.parent = &ctlr->dev;
46164 fcf->dev.bus = &fcoe_bus_type;
46165 fcf->dev.type = &fcoe_fcf_device_type;
46166 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46167 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46168 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46169
46170 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46171 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46172 {
46173 int error;
46174
46175 - atomic_set(&ctlr_num, 0);
46176 - atomic_set(&fcf_num, 0);
46177 + atomic_set_unchecked(&ctlr_num, 0);
46178 + atomic_set_unchecked(&fcf_num, 0);
46179
46180 error = bus_register(&fcoe_bus_type);
46181 if (error)
46182 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46183 index df0c3c7..b00e1d0 100644
46184 --- a/drivers/scsi/hosts.c
46185 +++ b/drivers/scsi/hosts.c
46186 @@ -42,7 +42,7 @@
46187 #include "scsi_logging.h"
46188
46189
46190 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46191 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46192
46193
46194 static void scsi_host_cls_release(struct device *dev)
46195 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46196 * subtract one because we increment first then return, but we need to
46197 * know what the next host number was before increment
46198 */
46199 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46200 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46201 shost->dma_channel = 0xff;
46202
46203 /* These three are default values which can be overridden */
46204 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46205 index 7f4f790..b75b92a 100644
46206 --- a/drivers/scsi/hpsa.c
46207 +++ b/drivers/scsi/hpsa.c
46208 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46209 unsigned long flags;
46210
46211 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46212 - return h->access.command_completed(h, q);
46213 + return h->access->command_completed(h, q);
46214
46215 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46216 a = rq->head[rq->current_entry];
46217 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
46218 while (!list_empty(&h->reqQ)) {
46219 c = list_entry(h->reqQ.next, struct CommandList, list);
46220 /* can't do anything if fifo is full */
46221 - if ((h->access.fifo_full(h))) {
46222 + if ((h->access->fifo_full(h))) {
46223 dev_warn(&h->pdev->dev, "fifo full\n");
46224 break;
46225 }
46226 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
46227
46228 /* Tell the controller execute command */
46229 spin_unlock_irqrestore(&h->lock, flags);
46230 - h->access.submit_command(h, c);
46231 + h->access->submit_command(h, c);
46232 spin_lock_irqsave(&h->lock, flags);
46233 }
46234 spin_unlock_irqrestore(&h->lock, flags);
46235 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
46236
46237 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46238 {
46239 - return h->access.command_completed(h, q);
46240 + return h->access->command_completed(h, q);
46241 }
46242
46243 static inline bool interrupt_pending(struct ctlr_info *h)
46244 {
46245 - return h->access.intr_pending(h);
46246 + return h->access->intr_pending(h);
46247 }
46248
46249 static inline long interrupt_not_for_us(struct ctlr_info *h)
46250 {
46251 - return (h->access.intr_pending(h) == 0) ||
46252 + return (h->access->intr_pending(h) == 0) ||
46253 (h->interrupts_enabled == 0);
46254 }
46255
46256 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46257 if (prod_index < 0)
46258 return -ENODEV;
46259 h->product_name = products[prod_index].product_name;
46260 - h->access = *(products[prod_index].access);
46261 + h->access = products[prod_index].access;
46262
46263 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46264 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46265 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46266
46267 assert_spin_locked(&lockup_detector_lock);
46268 remove_ctlr_from_lockup_detector_list(h);
46269 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46270 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46271 spin_lock_irqsave(&h->lock, flags);
46272 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46273 spin_unlock_irqrestore(&h->lock, flags);
46274 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
46275 }
46276
46277 /* make sure the board interrupts are off */
46278 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46279 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46280
46281 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46282 goto clean2;
46283 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
46284 * fake ones to scoop up any residual completions.
46285 */
46286 spin_lock_irqsave(&h->lock, flags);
46287 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46288 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46289 spin_unlock_irqrestore(&h->lock, flags);
46290 free_irqs(h);
46291 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46292 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
46293 dev_info(&h->pdev->dev, "Board READY.\n");
46294 dev_info(&h->pdev->dev,
46295 "Waiting for stale completions to drain.\n");
46296 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46297 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46298 msleep(10000);
46299 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46300 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46301
46302 rc = controller_reset_failed(h->cfgtable);
46303 if (rc)
46304 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
46305 }
46306
46307 /* Turn the interrupts on so we can service requests */
46308 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46309 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46310
46311 hpsa_hba_inquiry(h);
46312 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46313 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46314 * To write all data in the battery backed cache to disks
46315 */
46316 hpsa_flush_cache(h);
46317 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46318 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46319 hpsa_free_irqs_and_disable_msix(h);
46320 }
46321
46322 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46323 return;
46324 }
46325 /* Change the access methods to the performant access methods */
46326 - h->access = SA5_performant_access;
46327 + h->access = &SA5_performant_access;
46328 h->transMethod = CFGTBL_Trans_Performant;
46329 }
46330
46331 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46332 index 9816479..c5d4e97 100644
46333 --- a/drivers/scsi/hpsa.h
46334 +++ b/drivers/scsi/hpsa.h
46335 @@ -79,7 +79,7 @@ struct ctlr_info {
46336 unsigned int msix_vector;
46337 unsigned int msi_vector;
46338 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46339 - struct access_method access;
46340 + struct access_method *access;
46341
46342 /* queue and queue Info */
46343 struct list_head reqQ;
46344 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46345 index 5879929..32b241d 100644
46346 --- a/drivers/scsi/libfc/fc_exch.c
46347 +++ b/drivers/scsi/libfc/fc_exch.c
46348 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46349 u16 pool_max_index;
46350
46351 struct {
46352 - atomic_t no_free_exch;
46353 - atomic_t no_free_exch_xid;
46354 - atomic_t xid_not_found;
46355 - atomic_t xid_busy;
46356 - atomic_t seq_not_found;
46357 - atomic_t non_bls_resp;
46358 + atomic_unchecked_t no_free_exch;
46359 + atomic_unchecked_t no_free_exch_xid;
46360 + atomic_unchecked_t xid_not_found;
46361 + atomic_unchecked_t xid_busy;
46362 + atomic_unchecked_t seq_not_found;
46363 + atomic_unchecked_t non_bls_resp;
46364 } stats;
46365 };
46366
46367 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46368 /* allocate memory for exchange */
46369 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46370 if (!ep) {
46371 - atomic_inc(&mp->stats.no_free_exch);
46372 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46373 goto out;
46374 }
46375 memset(ep, 0, sizeof(*ep));
46376 @@ -797,7 +797,7 @@ out:
46377 return ep;
46378 err:
46379 spin_unlock_bh(&pool->lock);
46380 - atomic_inc(&mp->stats.no_free_exch_xid);
46381 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46382 mempool_free(ep, mp->ep_pool);
46383 return NULL;
46384 }
46385 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46386 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46387 ep = fc_exch_find(mp, xid);
46388 if (!ep) {
46389 - atomic_inc(&mp->stats.xid_not_found);
46390 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46391 reject = FC_RJT_OX_ID;
46392 goto out;
46393 }
46394 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46395 ep = fc_exch_find(mp, xid);
46396 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46397 if (ep) {
46398 - atomic_inc(&mp->stats.xid_busy);
46399 + atomic_inc_unchecked(&mp->stats.xid_busy);
46400 reject = FC_RJT_RX_ID;
46401 goto rel;
46402 }
46403 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46404 }
46405 xid = ep->xid; /* get our XID */
46406 } else if (!ep) {
46407 - atomic_inc(&mp->stats.xid_not_found);
46408 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46409 reject = FC_RJT_RX_ID; /* XID not found */
46410 goto out;
46411 }
46412 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46413 } else {
46414 sp = &ep->seq;
46415 if (sp->id != fh->fh_seq_id) {
46416 - atomic_inc(&mp->stats.seq_not_found);
46417 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46418 if (f_ctl & FC_FC_END_SEQ) {
46419 /*
46420 * Update sequence_id based on incoming last
46421 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46422
46423 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46424 if (!ep) {
46425 - atomic_inc(&mp->stats.xid_not_found);
46426 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46427 goto out;
46428 }
46429 if (ep->esb_stat & ESB_ST_COMPLETE) {
46430 - atomic_inc(&mp->stats.xid_not_found);
46431 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46432 goto rel;
46433 }
46434 if (ep->rxid == FC_XID_UNKNOWN)
46435 ep->rxid = ntohs(fh->fh_rx_id);
46436 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46437 - atomic_inc(&mp->stats.xid_not_found);
46438 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46439 goto rel;
46440 }
46441 if (ep->did != ntoh24(fh->fh_s_id) &&
46442 ep->did != FC_FID_FLOGI) {
46443 - atomic_inc(&mp->stats.xid_not_found);
46444 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46445 goto rel;
46446 }
46447 sof = fr_sof(fp);
46448 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46449 sp->ssb_stat |= SSB_ST_RESP;
46450 sp->id = fh->fh_seq_id;
46451 } else if (sp->id != fh->fh_seq_id) {
46452 - atomic_inc(&mp->stats.seq_not_found);
46453 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46454 goto rel;
46455 }
46456
46457 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46458 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46459
46460 if (!sp)
46461 - atomic_inc(&mp->stats.xid_not_found);
46462 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46463 else
46464 - atomic_inc(&mp->stats.non_bls_resp);
46465 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46466
46467 fc_frame_free(fp);
46468 }
46469 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46470
46471 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46472 mp = ema->mp;
46473 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46474 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46475 st->fc_no_free_exch_xid +=
46476 - atomic_read(&mp->stats.no_free_exch_xid);
46477 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46478 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46479 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46480 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46481 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46482 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46483 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46484 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46485 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46486 }
46487 }
46488 EXPORT_SYMBOL(fc_exch_update_stats);
46489 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46490 index 161c98e..6d563b3 100644
46491 --- a/drivers/scsi/libsas/sas_ata.c
46492 +++ b/drivers/scsi/libsas/sas_ata.c
46493 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46494 .postreset = ata_std_postreset,
46495 .error_handler = ata_std_error_handler,
46496 .post_internal_cmd = sas_ata_post_internal,
46497 - .qc_defer = ata_std_qc_defer,
46498 + .qc_defer = ata_std_qc_defer,
46499 .qc_prep = ata_noop_qc_prep,
46500 .qc_issue = sas_ata_qc_issue,
46501 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46502 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46503 index 93f222d..73e977b 100644
46504 --- a/drivers/scsi/lpfc/lpfc.h
46505 +++ b/drivers/scsi/lpfc/lpfc.h
46506 @@ -431,7 +431,7 @@ struct lpfc_vport {
46507 struct dentry *debug_nodelist;
46508 struct dentry *vport_debugfs_root;
46509 struct lpfc_debugfs_trc *disc_trc;
46510 - atomic_t disc_trc_cnt;
46511 + atomic_unchecked_t disc_trc_cnt;
46512 #endif
46513 uint8_t stat_data_enabled;
46514 uint8_t stat_data_blocked;
46515 @@ -865,8 +865,8 @@ struct lpfc_hba {
46516 struct timer_list fabric_block_timer;
46517 unsigned long bit_flags;
46518 #define FABRIC_COMANDS_BLOCKED 0
46519 - atomic_t num_rsrc_err;
46520 - atomic_t num_cmd_success;
46521 + atomic_unchecked_t num_rsrc_err;
46522 + atomic_unchecked_t num_cmd_success;
46523 unsigned long last_rsrc_error_time;
46524 unsigned long last_ramp_down_time;
46525 unsigned long last_ramp_up_time;
46526 @@ -902,7 +902,7 @@ struct lpfc_hba {
46527
46528 struct dentry *debug_slow_ring_trc;
46529 struct lpfc_debugfs_trc *slow_ring_trc;
46530 - atomic_t slow_ring_trc_cnt;
46531 + atomic_unchecked_t slow_ring_trc_cnt;
46532 /* iDiag debugfs sub-directory */
46533 struct dentry *idiag_root;
46534 struct dentry *idiag_pci_cfg;
46535 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46536 index 60084e6..0e2e700 100644
46537 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46538 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46539 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46540
46541 #include <linux/debugfs.h>
46542
46543 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46544 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46545 static unsigned long lpfc_debugfs_start_time = 0L;
46546
46547 /* iDiag */
46548 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46549 lpfc_debugfs_enable = 0;
46550
46551 len = 0;
46552 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46553 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46554 (lpfc_debugfs_max_disc_trc - 1);
46555 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46556 dtp = vport->disc_trc + i;
46557 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46558 lpfc_debugfs_enable = 0;
46559
46560 len = 0;
46561 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46562 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46563 (lpfc_debugfs_max_slow_ring_trc - 1);
46564 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46565 dtp = phba->slow_ring_trc + i;
46566 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46567 !vport || !vport->disc_trc)
46568 return;
46569
46570 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46571 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46572 (lpfc_debugfs_max_disc_trc - 1);
46573 dtp = vport->disc_trc + index;
46574 dtp->fmt = fmt;
46575 dtp->data1 = data1;
46576 dtp->data2 = data2;
46577 dtp->data3 = data3;
46578 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46579 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46580 dtp->jif = jiffies;
46581 #endif
46582 return;
46583 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46584 !phba || !phba->slow_ring_trc)
46585 return;
46586
46587 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46588 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46589 (lpfc_debugfs_max_slow_ring_trc - 1);
46590 dtp = phba->slow_ring_trc + index;
46591 dtp->fmt = fmt;
46592 dtp->data1 = data1;
46593 dtp->data2 = data2;
46594 dtp->data3 = data3;
46595 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46596 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46597 dtp->jif = jiffies;
46598 #endif
46599 return;
46600 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46601 "slow_ring buffer\n");
46602 goto debug_failed;
46603 }
46604 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46605 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46606 memset(phba->slow_ring_trc, 0,
46607 (sizeof(struct lpfc_debugfs_trc) *
46608 lpfc_debugfs_max_slow_ring_trc));
46609 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46610 "buffer\n");
46611 goto debug_failed;
46612 }
46613 - atomic_set(&vport->disc_trc_cnt, 0);
46614 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46615
46616 snprintf(name, sizeof(name), "discovery_trace");
46617 vport->debug_disc_trc =
46618 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46619 index e0b20fa..30c2c0d 100644
46620 --- a/drivers/scsi/lpfc/lpfc_init.c
46621 +++ b/drivers/scsi/lpfc/lpfc_init.c
46622 @@ -10936,8 +10936,10 @@ lpfc_init(void)
46623 "misc_register returned with status %d", error);
46624
46625 if (lpfc_enable_npiv) {
46626 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46627 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46628 + pax_open_kernel();
46629 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46630 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46631 + pax_close_kernel();
46632 }
46633 lpfc_transport_template =
46634 fc_attach_transport(&lpfc_transport_functions);
46635 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46636 index 243de1d..f40e3e5 100644
46637 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46638 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46639 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46640 uint32_t evt_posted;
46641
46642 spin_lock_irqsave(&phba->hbalock, flags);
46643 - atomic_inc(&phba->num_rsrc_err);
46644 + atomic_inc_unchecked(&phba->num_rsrc_err);
46645 phba->last_rsrc_error_time = jiffies;
46646
46647 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46648 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46649 unsigned long flags;
46650 struct lpfc_hba *phba = vport->phba;
46651 uint32_t evt_posted;
46652 - atomic_inc(&phba->num_cmd_success);
46653 + atomic_inc_unchecked(&phba->num_cmd_success);
46654
46655 if (vport->cfg_lun_queue_depth <= queue_depth)
46656 return;
46657 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46658 unsigned long num_rsrc_err, num_cmd_success;
46659 int i;
46660
46661 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46662 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46663 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46664 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46665
46666 /*
46667 * The error and success command counters are global per
46668 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46669 }
46670 }
46671 lpfc_destroy_vport_work_array(phba, vports);
46672 - atomic_set(&phba->num_rsrc_err, 0);
46673 - atomic_set(&phba->num_cmd_success, 0);
46674 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46675 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46676 }
46677
46678 /**
46679 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46680 }
46681 }
46682 lpfc_destroy_vport_work_array(phba, vports);
46683 - atomic_set(&phba->num_rsrc_err, 0);
46684 - atomic_set(&phba->num_cmd_success, 0);
46685 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46686 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46687 }
46688
46689 /**
46690 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
46691 index 1eb7b028..b2a6080 100644
46692 --- a/drivers/scsi/pmcraid.c
46693 +++ b/drivers/scsi/pmcraid.c
46694 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
46695 res->scsi_dev = scsi_dev;
46696 scsi_dev->hostdata = res;
46697 res->change_detected = 0;
46698 - atomic_set(&res->read_failures, 0);
46699 - atomic_set(&res->write_failures, 0);
46700 + atomic_set_unchecked(&res->read_failures, 0);
46701 + atomic_set_unchecked(&res->write_failures, 0);
46702 rc = 0;
46703 }
46704 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
46705 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
46706
46707 /* If this was a SCSI read/write command keep count of errors */
46708 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
46709 - atomic_inc(&res->read_failures);
46710 + atomic_inc_unchecked(&res->read_failures);
46711 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
46712 - atomic_inc(&res->write_failures);
46713 + atomic_inc_unchecked(&res->write_failures);
46714
46715 if (!RES_IS_GSCSI(res->cfg_entry) &&
46716 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
46717 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
46718 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46719 * hrrq_id assigned here in queuecommand
46720 */
46721 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46722 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46723 pinstance->num_hrrq;
46724 cmd->cmd_done = pmcraid_io_done;
46725
46726 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
46727 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
46728 * hrrq_id assigned here in queuecommand
46729 */
46730 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
46731 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
46732 pinstance->num_hrrq;
46733
46734 if (request_size) {
46735 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
46736
46737 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
46738 /* add resources only after host is added into system */
46739 - if (!atomic_read(&pinstance->expose_resources))
46740 + if (!atomic_read_unchecked(&pinstance->expose_resources))
46741 return;
46742
46743 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
46744 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
46745 init_waitqueue_head(&pinstance->reset_wait_q);
46746
46747 atomic_set(&pinstance->outstanding_cmds, 0);
46748 - atomic_set(&pinstance->last_message_id, 0);
46749 - atomic_set(&pinstance->expose_resources, 0);
46750 + atomic_set_unchecked(&pinstance->last_message_id, 0);
46751 + atomic_set_unchecked(&pinstance->expose_resources, 0);
46752
46753 INIT_LIST_HEAD(&pinstance->free_res_q);
46754 INIT_LIST_HEAD(&pinstance->used_res_q);
46755 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
46756 /* Schedule worker thread to handle CCN and take care of adding and
46757 * removing devices to OS
46758 */
46759 - atomic_set(&pinstance->expose_resources, 1);
46760 + atomic_set_unchecked(&pinstance->expose_resources, 1);
46761 schedule_work(&pinstance->worker_q);
46762 return rc;
46763
46764 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
46765 index e1d150f..6c6df44 100644
46766 --- a/drivers/scsi/pmcraid.h
46767 +++ b/drivers/scsi/pmcraid.h
46768 @@ -748,7 +748,7 @@ struct pmcraid_instance {
46769 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
46770
46771 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
46772 - atomic_t last_message_id;
46773 + atomic_unchecked_t last_message_id;
46774
46775 /* configuration table */
46776 struct pmcraid_config_table *cfg_table;
46777 @@ -777,7 +777,7 @@ struct pmcraid_instance {
46778 atomic_t outstanding_cmds;
46779
46780 /* should add/delete resources to mid-layer now ?*/
46781 - atomic_t expose_resources;
46782 + atomic_unchecked_t expose_resources;
46783
46784
46785
46786 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
46787 struct pmcraid_config_table_entry_ext cfg_entry_ext;
46788 };
46789 struct scsi_device *scsi_dev; /* Link scsi_device structure */
46790 - atomic_t read_failures; /* count of failed READ commands */
46791 - atomic_t write_failures; /* count of failed WRITE commands */
46792 + atomic_unchecked_t read_failures; /* count of failed READ commands */
46793 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
46794
46795 /* To indicate add/delete/modify during CCN */
46796 u8 change_detected;
46797 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
46798 index d7a99ae..801df70 100644
46799 --- a/drivers/scsi/qla2xxx/qla_attr.c
46800 +++ b/drivers/scsi/qla2xxx/qla_attr.c
46801 @@ -2004,7 +2004,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
46802 return 0;
46803 }
46804
46805 -struct fc_function_template qla2xxx_transport_functions = {
46806 +fc_function_template_no_const qla2xxx_transport_functions = {
46807
46808 .show_host_node_name = 1,
46809 .show_host_port_name = 1,
46810 @@ -2051,7 +2051,7 @@ struct fc_function_template qla2xxx_transport_functions = {
46811 .bsg_timeout = qla24xx_bsg_timeout,
46812 };
46813
46814 -struct fc_function_template qla2xxx_transport_vport_functions = {
46815 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
46816
46817 .show_host_node_name = 1,
46818 .show_host_port_name = 1,
46819 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
46820 index 2d98232..a84298e 100644
46821 --- a/drivers/scsi/qla2xxx/qla_gbl.h
46822 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
46823 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
46824 struct device_attribute;
46825 extern struct device_attribute *qla2x00_host_attrs[];
46826 struct fc_function_template;
46827 -extern struct fc_function_template qla2xxx_transport_functions;
46828 -extern struct fc_function_template qla2xxx_transport_vport_functions;
46829 +extern fc_function_template_no_const qla2xxx_transport_functions;
46830 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
46831 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
46832 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
46833 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
46834 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
46835 index 3e21e9f..426ba79 100644
46836 --- a/drivers/scsi/qla2xxx/qla_os.c
46837 +++ b/drivers/scsi/qla2xxx/qla_os.c
46838 @@ -1570,8 +1570,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
46839 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
46840 /* Ok, a 64bit DMA mask is applicable. */
46841 ha->flags.enable_64bit_addressing = 1;
46842 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46843 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46844 + pax_open_kernel();
46845 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
46846 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
46847 + pax_close_kernel();
46848 return;
46849 }
46850 }
46851 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
46852 index ddf16a8..80f4dd0 100644
46853 --- a/drivers/scsi/qla4xxx/ql4_def.h
46854 +++ b/drivers/scsi/qla4xxx/ql4_def.h
46855 @@ -291,7 +291,7 @@ struct ddb_entry {
46856 * (4000 only) */
46857 atomic_t relogin_timer; /* Max Time to wait for
46858 * relogin to complete */
46859 - atomic_t relogin_retry_count; /* Num of times relogin has been
46860 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
46861 * retried */
46862 uint32_t default_time2wait; /* Default Min time between
46863 * relogins (+aens) */
46864 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
46865 index b246b3c..897004d 100644
46866 --- a/drivers/scsi/qla4xxx/ql4_os.c
46867 +++ b/drivers/scsi/qla4xxx/ql4_os.c
46868 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
46869 */
46870 if (!iscsi_is_session_online(cls_sess)) {
46871 /* Reset retry relogin timer */
46872 - atomic_inc(&ddb_entry->relogin_retry_count);
46873 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
46874 DEBUG2(ql4_printk(KERN_INFO, ha,
46875 "%s: index[%d] relogin timed out-retrying"
46876 " relogin (%d), retry (%d)\n", __func__,
46877 ddb_entry->fw_ddb_index,
46878 - atomic_read(&ddb_entry->relogin_retry_count),
46879 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
46880 ddb_entry->default_time2wait + 4));
46881 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
46882 atomic_set(&ddb_entry->retry_relogin_timer,
46883 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
46884
46885 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
46886 atomic_set(&ddb_entry->relogin_timer, 0);
46887 - atomic_set(&ddb_entry->relogin_retry_count, 0);
46888 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
46889 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
46890 ddb_entry->default_relogin_timeout =
46891 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
46892 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
46893 index eaa808e..95f8841 100644
46894 --- a/drivers/scsi/scsi.c
46895 +++ b/drivers/scsi/scsi.c
46896 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
46897 unsigned long timeout;
46898 int rtn = 0;
46899
46900 - atomic_inc(&cmd->device->iorequest_cnt);
46901 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46902
46903 /* check if the device is still usable */
46904 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
46905 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
46906 index 124392f..75eb43e 100644
46907 --- a/drivers/scsi/scsi_lib.c
46908 +++ b/drivers/scsi/scsi_lib.c
46909 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
46910 shost = sdev->host;
46911 scsi_init_cmd_errh(cmd);
46912 cmd->result = DID_NO_CONNECT << 16;
46913 - atomic_inc(&cmd->device->iorequest_cnt);
46914 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
46915
46916 /*
46917 * SCSI request completion path will do scsi_device_unbusy(),
46918 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
46919
46920 INIT_LIST_HEAD(&cmd->eh_entry);
46921
46922 - atomic_inc(&cmd->device->iodone_cnt);
46923 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
46924 if (cmd->result)
46925 - atomic_inc(&cmd->device->ioerr_cnt);
46926 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
46927
46928 disposition = scsi_decide_disposition(cmd);
46929 if (disposition != SUCCESS &&
46930 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
46931 index 7e50061..71db7a6 100644
46932 --- a/drivers/scsi/scsi_sysfs.c
46933 +++ b/drivers/scsi/scsi_sysfs.c
46934 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
46935 char *buf) \
46936 { \
46937 struct scsi_device *sdev = to_scsi_device(dev); \
46938 - unsigned long long count = atomic_read(&sdev->field); \
46939 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
46940 return snprintf(buf, 20, "0x%llx\n", count); \
46941 } \
46942 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
46943 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
46944 index 84a1fdf..693b0d6 100644
46945 --- a/drivers/scsi/scsi_tgt_lib.c
46946 +++ b/drivers/scsi/scsi_tgt_lib.c
46947 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
46948 int err;
46949
46950 dprintk("%lx %u\n", uaddr, len);
46951 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
46952 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
46953 if (err) {
46954 /*
46955 * TODO: need to fixup sg_tablesize, max_segment_size,
46956 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
46957 index 4628fd5..a94a1c2 100644
46958 --- a/drivers/scsi/scsi_transport_fc.c
46959 +++ b/drivers/scsi/scsi_transport_fc.c
46960 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
46961 * Netlink Infrastructure
46962 */
46963
46964 -static atomic_t fc_event_seq;
46965 +static atomic_unchecked_t fc_event_seq;
46966
46967 /**
46968 * fc_get_event_number - Obtain the next sequential FC event number
46969 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
46970 u32
46971 fc_get_event_number(void)
46972 {
46973 - return atomic_add_return(1, &fc_event_seq);
46974 + return atomic_add_return_unchecked(1, &fc_event_seq);
46975 }
46976 EXPORT_SYMBOL(fc_get_event_number);
46977
46978 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
46979 {
46980 int error;
46981
46982 - atomic_set(&fc_event_seq, 0);
46983 + atomic_set_unchecked(&fc_event_seq, 0);
46984
46985 error = transport_class_register(&fc_host_class);
46986 if (error)
46987 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
46988 char *cp;
46989
46990 *val = simple_strtoul(buf, &cp, 0);
46991 - if ((*cp && (*cp != '\n')) || (*val < 0))
46992 + if (*cp && (*cp != '\n'))
46993 return -EINVAL;
46994 /*
46995 * Check for overflow; dev_loss_tmo is u32
46996 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
46997 index abf7c40..c3240ed 100644
46998 --- a/drivers/scsi/scsi_transport_iscsi.c
46999 +++ b/drivers/scsi/scsi_transport_iscsi.c
47000 @@ -80,7 +80,7 @@ struct iscsi_internal {
47001 struct transport_container session_cont;
47002 };
47003
47004 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47005 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47006 static struct workqueue_struct *iscsi_eh_timer_workq;
47007
47008 static DEFINE_IDA(iscsi_sess_ida);
47009 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47010 int err;
47011
47012 ihost = shost->shost_data;
47013 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47014 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47015
47016 if (target_id == ISCSI_MAX_TARGET) {
47017 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47018 @@ -3956,7 +3956,7 @@ static __init int iscsi_transport_init(void)
47019 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47020 ISCSI_TRANSPORT_VERSION);
47021
47022 - atomic_set(&iscsi_session_nr, 0);
47023 + atomic_set_unchecked(&iscsi_session_nr, 0);
47024
47025 err = class_register(&iscsi_transport_class);
47026 if (err)
47027 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47028 index f379c7f..e8fc69c 100644
47029 --- a/drivers/scsi/scsi_transport_srp.c
47030 +++ b/drivers/scsi/scsi_transport_srp.c
47031 @@ -33,7 +33,7 @@
47032 #include "scsi_transport_srp_internal.h"
47033
47034 struct srp_host_attrs {
47035 - atomic_t next_port_id;
47036 + atomic_unchecked_t next_port_id;
47037 };
47038 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47039
47040 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47041 struct Scsi_Host *shost = dev_to_shost(dev);
47042 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47043
47044 - atomic_set(&srp_host->next_port_id, 0);
47045 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47046 return 0;
47047 }
47048
47049 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47050 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47051 rport->roles = ids->roles;
47052
47053 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47054 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47055 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47056
47057 transport_setup_device(&rport->dev);
47058 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47059 index 2783dd7..d20395b 100644
47060 --- a/drivers/scsi/sd.c
47061 +++ b/drivers/scsi/sd.c
47062 @@ -2933,7 +2933,7 @@ static int sd_probe(struct device *dev)
47063 sdkp->disk = gd;
47064 sdkp->index = index;
47065 atomic_set(&sdkp->openers, 0);
47066 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47067 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47068
47069 if (!sdp->request_queue->rq_timeout) {
47070 if (sdp->type != TYPE_MOD)
47071 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47072 index df5e961..df6b97f 100644
47073 --- a/drivers/scsi/sg.c
47074 +++ b/drivers/scsi/sg.c
47075 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47076 sdp->disk->disk_name,
47077 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47078 NULL,
47079 - (char *)arg);
47080 + (char __user *)arg);
47081 case BLKTRACESTART:
47082 return blk_trace_startstop(sdp->device->request_queue, 1);
47083 case BLKTRACESTOP:
47084 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47085 index 978dda2..cb19aa0 100644
47086 --- a/drivers/spi/spi.c
47087 +++ b/drivers/spi/spi.c
47088 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
47089 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47090
47091 /* portable code must never pass more than 32 bytes */
47092 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47093 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47094
47095 static u8 *buf;
47096
47097 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47098 index ee3a57f..18368c1 100644
47099 --- a/drivers/staging/android/timed_output.c
47100 +++ b/drivers/staging/android/timed_output.c
47101 @@ -25,7 +25,7 @@
47102 #include "timed_output.h"
47103
47104 static struct class *timed_output_class;
47105 -static atomic_t device_count;
47106 +static atomic_unchecked_t device_count;
47107
47108 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47109 char *buf)
47110 @@ -59,7 +59,7 @@ static int create_timed_output_class(void)
47111 timed_output_class = class_create(THIS_MODULE, "timed_output");
47112 if (IS_ERR(timed_output_class))
47113 return PTR_ERR(timed_output_class);
47114 - atomic_set(&device_count, 0);
47115 + atomic_set_unchecked(&device_count, 0);
47116 }
47117
47118 return 0;
47119 @@ -76,7 +76,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47120 if (ret < 0)
47121 return ret;
47122
47123 - tdev->index = atomic_inc_return(&device_count);
47124 + tdev->index = atomic_inc_return_unchecked(&device_count);
47125 tdev->dev = device_create(timed_output_class, NULL,
47126 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47127 if (IS_ERR(tdev->dev))
47128 diff --git a/drivers/staging/bcm/Bcmchar.c b/drivers/staging/bcm/Bcmchar.c
47129 index f67a225..756b634 100644
47130 --- a/drivers/staging/bcm/Bcmchar.c
47131 +++ b/drivers/staging/bcm/Bcmchar.c
47132 @@ -1960,6 +1960,7 @@ cntrlEnd:
47133
47134 BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, OSAL_DBG, DBG_LVL_ALL, "Called IOCTL_BCM_GET_DEVICE_DRIVER_INFO\n");
47135
47136 + memset(&DevInfo, 0, sizeof(DevInfo));
47137 DevInfo.MaxRDMBufferSize = BUFFER_4K;
47138 DevInfo.u32DSDStartOffset = EEPROM_CALPARAM_START;
47139 DevInfo.u32RxAlignmentCorrection = 0;
47140 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47141 index 3675020..e80d92c 100644
47142 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47143 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47144 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47145
47146 static int solo_sysfs_init(struct solo_dev *solo_dev)
47147 {
47148 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47149 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47150 struct device *dev = &solo_dev->dev;
47151 const char *driver;
47152 int i;
47153 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47154 index 3335941..2b26186 100644
47155 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47156 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47157 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47158
47159 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47160 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47161 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47162 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47163 if (p2m_id < 0)
47164 p2m_id = -p2m_id;
47165 }
47166 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47167 index 6f91d2e..3f011d2 100644
47168 --- a/drivers/staging/media/solo6x10/solo6x10.h
47169 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47170 @@ -238,7 +238,7 @@ struct solo_dev {
47171
47172 /* P2M DMA Engine */
47173 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47174 - atomic_t p2m_count;
47175 + atomic_unchecked_t p2m_count;
47176 int p2m_jiffies;
47177 unsigned int p2m_timeouts;
47178
47179 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47180 index 34afc16..ffe44dd 100644
47181 --- a/drivers/staging/octeon/ethernet-rx.c
47182 +++ b/drivers/staging/octeon/ethernet-rx.c
47183 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47184 /* Increment RX stats for virtual ports */
47185 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47186 #ifdef CONFIG_64BIT
47187 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47188 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47189 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47190 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47191 #else
47192 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47193 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47194 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47195 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47196 #endif
47197 }
47198 netif_receive_skb(skb);
47199 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47200 dev->name);
47201 */
47202 #ifdef CONFIG_64BIT
47203 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47204 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47205 #else
47206 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47207 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47208 #endif
47209 dev_kfree_skb_irq(skb);
47210 }
47211 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47212 index c3a90e7..023619a 100644
47213 --- a/drivers/staging/octeon/ethernet.c
47214 +++ b/drivers/staging/octeon/ethernet.c
47215 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47216 * since the RX tasklet also increments it.
47217 */
47218 #ifdef CONFIG_64BIT
47219 - atomic64_add(rx_status.dropped_packets,
47220 - (atomic64_t *)&priv->stats.rx_dropped);
47221 + atomic64_add_unchecked(rx_status.dropped_packets,
47222 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47223 #else
47224 - atomic_add(rx_status.dropped_packets,
47225 - (atomic_t *)&priv->stats.rx_dropped);
47226 + atomic_add_unchecked(rx_status.dropped_packets,
47227 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47228 #endif
47229 }
47230
47231 diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
47232 index 374fdc3..ea5f9f3 100644
47233 --- a/drivers/staging/ozwpan/ozcdev.c
47234 +++ b/drivers/staging/ozwpan/ozcdev.c
47235 @@ -152,6 +152,9 @@ static ssize_t oz_cdev_write(struct file *filp, const char __user *buf,
47236 struct oz_app_hdr *app_hdr;
47237 struct oz_serial_ctx *ctx;
47238
47239 + if (count > sizeof(ei->data) - sizeof(*elt) - sizeof(*app_hdr))
47240 + return -EINVAL;
47241 +
47242 spin_lock_bh(&g_cdev.lock);
47243 pd = g_cdev.active_pd;
47244 if (pd)
47245 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47246 index dc23395..cf7e9b1 100644
47247 --- a/drivers/staging/rtl8712/rtl871x_io.h
47248 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47249 @@ -108,7 +108,7 @@ struct _io_ops {
47250 u8 *pmem);
47251 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47252 u8 *pmem);
47253 -};
47254 +} __no_const;
47255
47256 struct io_req {
47257 struct list_head list;
47258 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47259 index 1f5088b..0e59820 100644
47260 --- a/drivers/staging/sbe-2t3e3/netdev.c
47261 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47262 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47263 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47264
47265 if (rlen)
47266 - if (copy_to_user(data, &resp, rlen))
47267 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47268 return -EFAULT;
47269
47270 return 0;
47271 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47272 index a863a98..d272795 100644
47273 --- a/drivers/staging/usbip/vhci.h
47274 +++ b/drivers/staging/usbip/vhci.h
47275 @@ -83,7 +83,7 @@ struct vhci_hcd {
47276 unsigned resuming:1;
47277 unsigned long re_timeout;
47278
47279 - atomic_t seqnum;
47280 + atomic_unchecked_t seqnum;
47281
47282 /*
47283 * NOTE:
47284 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47285 index d7974cb..d78076b 100644
47286 --- a/drivers/staging/usbip/vhci_hcd.c
47287 +++ b/drivers/staging/usbip/vhci_hcd.c
47288 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47289
47290 spin_lock(&vdev->priv_lock);
47291
47292 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47293 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47294 if (priv->seqnum == 0xffff)
47295 dev_info(&urb->dev->dev, "seqnum max\n");
47296
47297 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47298 return -ENOMEM;
47299 }
47300
47301 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47302 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47303 if (unlink->seqnum == 0xffff)
47304 pr_info("seqnum max\n");
47305
47306 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47307 vdev->rhport = rhport;
47308 }
47309
47310 - atomic_set(&vhci->seqnum, 0);
47311 + atomic_set_unchecked(&vhci->seqnum, 0);
47312 spin_lock_init(&vhci->lock);
47313
47314 hcd->power_budget = 0; /* no limit */
47315 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47316 index d07fcb5..358e1e1 100644
47317 --- a/drivers/staging/usbip/vhci_rx.c
47318 +++ b/drivers/staging/usbip/vhci_rx.c
47319 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47320 if (!urb) {
47321 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47322 pr_info("max seqnum %d\n",
47323 - atomic_read(&the_controller->seqnum));
47324 + atomic_read_unchecked(&the_controller->seqnum));
47325 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47326 return;
47327 }
47328 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47329 index 57a08c5..5b4bb7c 100644
47330 --- a/drivers/staging/vt6655/hostap.c
47331 +++ b/drivers/staging/vt6655/hostap.c
47332 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47333 *
47334 */
47335
47336 +static net_device_ops_no_const apdev_netdev_ops;
47337 +
47338 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47339 {
47340 PSDevice apdev_priv;
47341 struct net_device *dev = pDevice->dev;
47342 int ret;
47343 - const struct net_device_ops apdev_netdev_ops = {
47344 - .ndo_start_xmit = pDevice->tx_80211,
47345 - };
47346
47347 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47348
47349 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47350 *apdev_priv = *pDevice;
47351 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47352
47353 + /* only half broken now */
47354 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47355 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47356
47357 pDevice->apdev->type = ARPHRD_IEEE80211;
47358 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47359 index c699a30..b90a5fd 100644
47360 --- a/drivers/staging/vt6656/hostap.c
47361 +++ b/drivers/staging/vt6656/hostap.c
47362 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47363 *
47364 */
47365
47366 +static net_device_ops_no_const apdev_netdev_ops;
47367 +
47368 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47369 {
47370 struct vnt_private *apdev_priv;
47371 struct net_device *dev = pDevice->dev;
47372 int ret;
47373 - const struct net_device_ops apdev_netdev_ops = {
47374 - .ndo_start_xmit = pDevice->tx_80211,
47375 - };
47376
47377 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47378
47379 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47380 *apdev_priv = *pDevice;
47381 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47382
47383 + /* only half broken now */
47384 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47385 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47386
47387 pDevice->apdev->type = ARPHRD_IEEE80211;
47388 diff --git a/drivers/staging/wlags49_h2/wl_priv.c b/drivers/staging/wlags49_h2/wl_priv.c
47389 index c97e0e1..7e10dcd 100644
47390 --- a/drivers/staging/wlags49_h2/wl_priv.c
47391 +++ b/drivers/staging/wlags49_h2/wl_priv.c
47392 @@ -570,6 +570,7 @@ int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp)
47393 ltv_t *pLtv;
47394 bool_t ltvAllocated = FALSE;
47395 ENCSTRCT sEncryption;
47396 + size_t len;
47397
47398 #ifdef USE_WDS
47399 hcf_16 hcfPort = HCF_PORT_0;
47400 @@ -686,7 +687,8 @@ int wvlan_uil_put_info(struct uilreq *urq, struct wl_private *lp)
47401 break;
47402 case CFG_CNF_OWN_NAME:
47403 memset(lp->StationName, 0, sizeof(lp->StationName));
47404 - memcpy((void *)lp->StationName, (void *)&pLtv->u.u8[2], (size_t)pLtv->u.u16[0]);
47405 + len = min_t(size_t, pLtv->u.u16[0], sizeof(lp->StationName));
47406 + strlcpy(lp->StationName, &pLtv->u.u8[2], len);
47407 pLtv->u.u16[0] = CNV_INT_TO_LITTLE(pLtv->u.u16[0]);
47408 break;
47409 case CFG_CNF_LOAD_BALANCING:
47410 @@ -1783,6 +1785,7 @@ int wvlan_set_station_nickname(struct net_device *dev,
47411 {
47412 struct wl_private *lp = wl_priv(dev);
47413 unsigned long flags;
47414 + size_t len;
47415 int ret = 0;
47416 /*------------------------------------------------------------------------*/
47417
47418 @@ -1793,8 +1796,8 @@ int wvlan_set_station_nickname(struct net_device *dev,
47419 wl_lock(lp, &flags);
47420
47421 memset(lp->StationName, 0, sizeof(lp->StationName));
47422 -
47423 - memcpy(lp->StationName, extra, wrqu->data.length);
47424 + len = min_t(size_t, wrqu->data.length, sizeof(lp->StationName));
47425 + strlcpy(lp->StationName, extra, len);
47426
47427 /* Commit the adapter parameters */
47428 wl_apply(lp);
47429 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
47430 index d128ce2..fc1f9a1 100644
47431 --- a/drivers/staging/zcache/tmem.h
47432 +++ b/drivers/staging/zcache/tmem.h
47433 @@ -225,7 +225,7 @@ struct tmem_pamops {
47434 bool (*is_remote)(void *);
47435 int (*replace_in_obj)(void *, struct tmem_obj *);
47436 #endif
47437 -};
47438 +} __no_const;
47439 extern void tmem_register_pamops(struct tmem_pamops *m);
47440
47441 /* memory allocation methods provided by the host implementation */
47442 @@ -234,7 +234,7 @@ struct tmem_hostops {
47443 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
47444 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
47445 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
47446 -};
47447 +} __no_const;
47448 extern void tmem_register_hostops(struct tmem_hostops *m);
47449
47450 /* core tmem accessor functions */
47451 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47452 index e51b09a..5ebac31 100644
47453 --- a/drivers/target/sbp/sbp_target.c
47454 +++ b/drivers/target/sbp/sbp_target.c
47455 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47456
47457 #define SESSION_MAINTENANCE_INTERVAL HZ
47458
47459 -static atomic_t login_id = ATOMIC_INIT(0);
47460 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47461
47462 static void session_maintenance_work(struct work_struct *);
47463 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47464 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47465 login->lun = se_lun;
47466 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47467 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47468 - login->login_id = atomic_inc_return(&login_id);
47469 + login->login_id = atomic_inc_return_unchecked(&login_id);
47470
47471 login->tgt_agt = sbp_target_agent_register(login);
47472 if (IS_ERR(login->tgt_agt)) {
47473 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47474 index 8f4142f..b127f7d 100644
47475 --- a/drivers/target/target_core_device.c
47476 +++ b/drivers/target/target_core_device.c
47477 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47478 spin_lock_init(&dev->se_port_lock);
47479 spin_lock_init(&dev->se_tmr_lock);
47480 spin_lock_init(&dev->qf_cmd_lock);
47481 - atomic_set(&dev->dev_ordered_id, 0);
47482 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47483 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47484 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47485 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47486 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47487 index d8e49d7..6fcfdec 100644
47488 --- a/drivers/target/target_core_transport.c
47489 +++ b/drivers/target/target_core_transport.c
47490 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47491 * Used to determine when ORDERED commands should go from
47492 * Dormant to Active status.
47493 */
47494 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47495 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47496 smp_mb__after_atomic_inc();
47497 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47498 cmd->se_ordered_id, cmd->sam_task_attr,
47499 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47500 index 33f83fe..d80f8e1 100644
47501 --- a/drivers/tty/cyclades.c
47502 +++ b/drivers/tty/cyclades.c
47503 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47504 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47505 info->port.count);
47506 #endif
47507 - info->port.count++;
47508 + atomic_inc(&info->port.count);
47509 #ifdef CY_DEBUG_COUNT
47510 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47511 - current->pid, info->port.count);
47512 + current->pid, atomic_read(&info->port.count));
47513 #endif
47514
47515 /*
47516 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47517 for (j = 0; j < cy_card[i].nports; j++) {
47518 info = &cy_card[i].ports[j];
47519
47520 - if (info->port.count) {
47521 + if (atomic_read(&info->port.count)) {
47522 /* XXX is the ldisc num worth this? */
47523 struct tty_struct *tty;
47524 struct tty_ldisc *ld;
47525 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47526 index eb255e8..f637a57 100644
47527 --- a/drivers/tty/hvc/hvc_console.c
47528 +++ b/drivers/tty/hvc/hvc_console.c
47529 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47530
47531 spin_lock_irqsave(&hp->port.lock, flags);
47532 /* Check and then increment for fast path open. */
47533 - if (hp->port.count++ > 0) {
47534 + if (atomic_inc_return(&hp->port.count) > 1) {
47535 spin_unlock_irqrestore(&hp->port.lock, flags);
47536 hvc_kick();
47537 return 0;
47538 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47539
47540 spin_lock_irqsave(&hp->port.lock, flags);
47541
47542 - if (--hp->port.count == 0) {
47543 + if (atomic_dec_return(&hp->port.count) == 0) {
47544 spin_unlock_irqrestore(&hp->port.lock, flags);
47545 /* We are done with the tty pointer now. */
47546 tty_port_tty_set(&hp->port, NULL);
47547 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47548 */
47549 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47550 } else {
47551 - if (hp->port.count < 0)
47552 + if (atomic_read(&hp->port.count) < 0)
47553 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47554 - hp->vtermno, hp->port.count);
47555 + hp->vtermno, atomic_read(&hp->port.count));
47556 spin_unlock_irqrestore(&hp->port.lock, flags);
47557 }
47558 }
47559 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
47560 * open->hangup case this can be called after the final close so prevent
47561 * that from happening for now.
47562 */
47563 - if (hp->port.count <= 0) {
47564 + if (atomic_read(&hp->port.count) <= 0) {
47565 spin_unlock_irqrestore(&hp->port.lock, flags);
47566 return;
47567 }
47568
47569 - hp->port.count = 0;
47570 + atomic_set(&hp->port.count, 0);
47571 spin_unlock_irqrestore(&hp->port.lock, flags);
47572 tty_port_tty_set(&hp->port, NULL);
47573
47574 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47575 return -EPIPE;
47576
47577 /* FIXME what's this (unprotected) check for? */
47578 - if (hp->port.count <= 0)
47579 + if (atomic_read(&hp->port.count) <= 0)
47580 return -EIO;
47581
47582 spin_lock_irqsave(&hp->lock, flags);
47583 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47584 index 81e939e..95ead10 100644
47585 --- a/drivers/tty/hvc/hvcs.c
47586 +++ b/drivers/tty/hvc/hvcs.c
47587 @@ -83,6 +83,7 @@
47588 #include <asm/hvcserver.h>
47589 #include <asm/uaccess.h>
47590 #include <asm/vio.h>
47591 +#include <asm/local.h>
47592
47593 /*
47594 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
47595 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
47596
47597 spin_lock_irqsave(&hvcsd->lock, flags);
47598
47599 - if (hvcsd->port.count > 0) {
47600 + if (atomic_read(&hvcsd->port.count) > 0) {
47601 spin_unlock_irqrestore(&hvcsd->lock, flags);
47602 printk(KERN_INFO "HVCS: vterm state unchanged. "
47603 "The hvcs device node is still in use.\n");
47604 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
47605 }
47606 }
47607
47608 - hvcsd->port.count = 0;
47609 + atomic_set(&hvcsd->port.count, 0);
47610 hvcsd->port.tty = tty;
47611 tty->driver_data = hvcsd;
47612
47613 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
47614 unsigned long flags;
47615
47616 spin_lock_irqsave(&hvcsd->lock, flags);
47617 - hvcsd->port.count++;
47618 + atomic_inc(&hvcsd->port.count);
47619 hvcsd->todo_mask |= HVCS_SCHED_READ;
47620 spin_unlock_irqrestore(&hvcsd->lock, flags);
47621
47622 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47623 hvcsd = tty->driver_data;
47624
47625 spin_lock_irqsave(&hvcsd->lock, flags);
47626 - if (--hvcsd->port.count == 0) {
47627 + if (atomic_dec_and_test(&hvcsd->port.count)) {
47628
47629 vio_disable_interrupts(hvcsd->vdev);
47630
47631 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
47632
47633 free_irq(irq, hvcsd);
47634 return;
47635 - } else if (hvcsd->port.count < 0) {
47636 + } else if (atomic_read(&hvcsd->port.count) < 0) {
47637 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
47638 " is missmanaged.\n",
47639 - hvcsd->vdev->unit_address, hvcsd->port.count);
47640 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
47641 }
47642
47643 spin_unlock_irqrestore(&hvcsd->lock, flags);
47644 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47645
47646 spin_lock_irqsave(&hvcsd->lock, flags);
47647 /* Preserve this so that we know how many kref refs to put */
47648 - temp_open_count = hvcsd->port.count;
47649 + temp_open_count = atomic_read(&hvcsd->port.count);
47650
47651 /*
47652 * Don't kref put inside the spinlock because the destruction
47653 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
47654 tty->driver_data = NULL;
47655 hvcsd->port.tty = NULL;
47656
47657 - hvcsd->port.count = 0;
47658 + atomic_set(&hvcsd->port.count, 0);
47659
47660 /* This will drop any buffered data on the floor which is OK in a hangup
47661 * scenario. */
47662 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
47663 * the middle of a write operation? This is a crummy place to do this
47664 * but we want to keep it all in the spinlock.
47665 */
47666 - if (hvcsd->port.count <= 0) {
47667 + if (atomic_read(&hvcsd->port.count) <= 0) {
47668 spin_unlock_irqrestore(&hvcsd->lock, flags);
47669 return -ENODEV;
47670 }
47671 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
47672 {
47673 struct hvcs_struct *hvcsd = tty->driver_data;
47674
47675 - if (!hvcsd || hvcsd->port.count <= 0)
47676 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
47677 return 0;
47678
47679 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
47680 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
47681 index 4190199..48f2920 100644
47682 --- a/drivers/tty/hvc/hvsi.c
47683 +++ b/drivers/tty/hvc/hvsi.c
47684 @@ -85,7 +85,7 @@ struct hvsi_struct {
47685 int n_outbuf;
47686 uint32_t vtermno;
47687 uint32_t virq;
47688 - atomic_t seqno; /* HVSI packet sequence number */
47689 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
47690 uint16_t mctrl;
47691 uint8_t state; /* HVSI protocol state */
47692 uint8_t flags;
47693 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
47694
47695 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
47696 packet.hdr.len = sizeof(struct hvsi_query_response);
47697 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47698 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47699 packet.verb = VSV_SEND_VERSION_NUMBER;
47700 packet.u.version = HVSI_VERSION;
47701 packet.query_seqno = query_seqno+1;
47702 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
47703
47704 packet.hdr.type = VS_QUERY_PACKET_HEADER;
47705 packet.hdr.len = sizeof(struct hvsi_query);
47706 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47707 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47708 packet.verb = verb;
47709
47710 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
47711 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
47712 int wrote;
47713
47714 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
47715 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47716 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47717 packet.hdr.len = sizeof(struct hvsi_control);
47718 packet.verb = VSV_SET_MODEM_CTL;
47719 packet.mask = HVSI_TSDTR;
47720 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
47721 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
47722
47723 packet.hdr.type = VS_DATA_PACKET_HEADER;
47724 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47725 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47726 packet.hdr.len = count + sizeof(struct hvsi_header);
47727 memcpy(&packet.data, buf, count);
47728
47729 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
47730 struct hvsi_control packet __ALIGNED__;
47731
47732 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
47733 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
47734 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
47735 packet.hdr.len = 6;
47736 packet.verb = VSV_CLOSE_PROTOCOL;
47737
47738 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
47739 index ac27671..0f627ee 100644
47740 --- a/drivers/tty/hvc/hvsi_lib.c
47741 +++ b/drivers/tty/hvc/hvsi_lib.c
47742 @@ -9,7 +9,7 @@
47743
47744 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
47745 {
47746 - packet->seqno = atomic_inc_return(&pv->seqno);
47747 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
47748
47749 /* Assumes that always succeeds, works in practice */
47750 return pv->put_chars(pv->termno, (char *)packet, packet->len);
47751 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
47752
47753 /* Reset state */
47754 pv->established = 0;
47755 - atomic_set(&pv->seqno, 0);
47756 + atomic_set_unchecked(&pv->seqno, 0);
47757
47758 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
47759
47760 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
47761 pv->mctrl_update = 0;
47762 q.hdr.type = VS_QUERY_PACKET_HEADER;
47763 q.hdr.len = sizeof(struct hvsi_query);
47764 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
47765 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
47766 q.verb = VSV_SEND_MODEM_CTL_STATUS;
47767 rc = hvsi_send_packet(pv, &q.hdr);
47768 if (rc <= 0) {
47769 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
47770 index 8fd72ff..34a0bed 100644
47771 --- a/drivers/tty/ipwireless/tty.c
47772 +++ b/drivers/tty/ipwireless/tty.c
47773 @@ -29,6 +29,7 @@
47774 #include <linux/tty_driver.h>
47775 #include <linux/tty_flip.h>
47776 #include <linux/uaccess.h>
47777 +#include <asm/local.h>
47778
47779 #include "tty.h"
47780 #include "network.h"
47781 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47782 mutex_unlock(&tty->ipw_tty_mutex);
47783 return -ENODEV;
47784 }
47785 - if (tty->port.count == 0)
47786 + if (atomic_read(&tty->port.count) == 0)
47787 tty->tx_bytes_queued = 0;
47788
47789 - tty->port.count++;
47790 + atomic_inc(&tty->port.count);
47791
47792 tty->port.tty = linux_tty;
47793 linux_tty->driver_data = tty;
47794 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
47795
47796 static void do_ipw_close(struct ipw_tty *tty)
47797 {
47798 - tty->port.count--;
47799 -
47800 - if (tty->port.count == 0) {
47801 + if (atomic_dec_return(&tty->port.count) == 0) {
47802 struct tty_struct *linux_tty = tty->port.tty;
47803
47804 if (linux_tty != NULL) {
47805 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
47806 return;
47807
47808 mutex_lock(&tty->ipw_tty_mutex);
47809 - if (tty->port.count == 0) {
47810 + if (atomic_read(&tty->port.count) == 0) {
47811 mutex_unlock(&tty->ipw_tty_mutex);
47812 return;
47813 }
47814 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
47815
47816 mutex_lock(&tty->ipw_tty_mutex);
47817
47818 - if (!tty->port.count) {
47819 + if (!atomic_read(&tty->port.count)) {
47820 mutex_unlock(&tty->ipw_tty_mutex);
47821 return;
47822 }
47823 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
47824 return -ENODEV;
47825
47826 mutex_lock(&tty->ipw_tty_mutex);
47827 - if (!tty->port.count) {
47828 + if (!atomic_read(&tty->port.count)) {
47829 mutex_unlock(&tty->ipw_tty_mutex);
47830 return -EINVAL;
47831 }
47832 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
47833 if (!tty)
47834 return -ENODEV;
47835
47836 - if (!tty->port.count)
47837 + if (!atomic_read(&tty->port.count))
47838 return -EINVAL;
47839
47840 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
47841 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
47842 if (!tty)
47843 return 0;
47844
47845 - if (!tty->port.count)
47846 + if (!atomic_read(&tty->port.count))
47847 return 0;
47848
47849 return tty->tx_bytes_queued;
47850 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
47851 if (!tty)
47852 return -ENODEV;
47853
47854 - if (!tty->port.count)
47855 + if (!atomic_read(&tty->port.count))
47856 return -EINVAL;
47857
47858 return get_control_lines(tty);
47859 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
47860 if (!tty)
47861 return -ENODEV;
47862
47863 - if (!tty->port.count)
47864 + if (!atomic_read(&tty->port.count))
47865 return -EINVAL;
47866
47867 return set_control_lines(tty, set, clear);
47868 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
47869 if (!tty)
47870 return -ENODEV;
47871
47872 - if (!tty->port.count)
47873 + if (!atomic_read(&tty->port.count))
47874 return -EINVAL;
47875
47876 /* FIXME: Exactly how is the tty object locked here .. */
47877 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
47878 * are gone */
47879 mutex_lock(&ttyj->ipw_tty_mutex);
47880 }
47881 - while (ttyj->port.count)
47882 + while (atomic_read(&ttyj->port.count))
47883 do_ipw_close(ttyj);
47884 ipwireless_disassociate_network_ttys(network,
47885 ttyj->channel_idx);
47886 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
47887 index 1deaca4..c8582d4 100644
47888 --- a/drivers/tty/moxa.c
47889 +++ b/drivers/tty/moxa.c
47890 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
47891 }
47892
47893 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
47894 - ch->port.count++;
47895 + atomic_inc(&ch->port.count);
47896 tty->driver_data = ch;
47897 tty_port_tty_set(&ch->port, tty);
47898 mutex_lock(&ch->port.mutex);
47899 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
47900 index 6422390..49003ac8 100644
47901 --- a/drivers/tty/n_gsm.c
47902 +++ b/drivers/tty/n_gsm.c
47903 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
47904 spin_lock_init(&dlci->lock);
47905 mutex_init(&dlci->mutex);
47906 dlci->fifo = &dlci->_fifo;
47907 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
47908 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
47909 kfree(dlci);
47910 return NULL;
47911 }
47912 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
47913 struct gsm_dlci *dlci = tty->driver_data;
47914 struct tty_port *port = &dlci->port;
47915
47916 - port->count++;
47917 + atomic_inc(&port->count);
47918 dlci_get(dlci);
47919 dlci_get(dlci->gsm->dlci[0]);
47920 mux_get(dlci->gsm);
47921 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
47922 index 4bf0fc0..433bd58 100644
47923 --- a/drivers/tty/n_tty.c
47924 +++ b/drivers/tty/n_tty.c
47925 @@ -2217,6 +2217,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
47926 {
47927 *ops = tty_ldisc_N_TTY;
47928 ops->owner = NULL;
47929 - ops->refcount = ops->flags = 0;
47930 + atomic_set(&ops->refcount, 0);
47931 + ops->flags = 0;
47932 }
47933 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
47934 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
47935 index abfd990..5ab5da9 100644
47936 --- a/drivers/tty/pty.c
47937 +++ b/drivers/tty/pty.c
47938 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
47939 panic("Couldn't register Unix98 pts driver");
47940
47941 /* Now create the /dev/ptmx special device */
47942 + pax_open_kernel();
47943 tty_default_fops(&ptmx_fops);
47944 - ptmx_fops.open = ptmx_open;
47945 + *(void **)&ptmx_fops.open = ptmx_open;
47946 + pax_close_kernel();
47947
47948 cdev_init(&ptmx_cdev, &ptmx_fops);
47949 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
47950 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
47951 index 354564e..fe50d9a 100644
47952 --- a/drivers/tty/rocket.c
47953 +++ b/drivers/tty/rocket.c
47954 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47955 tty->driver_data = info;
47956 tty_port_tty_set(port, tty);
47957
47958 - if (port->count++ == 0) {
47959 + if (atomic_inc_return(&port->count) == 1) {
47960 atomic_inc(&rp_num_ports_open);
47961
47962 #ifdef ROCKET_DEBUG_OPEN
47963 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
47964 #endif
47965 }
47966 #ifdef ROCKET_DEBUG_OPEN
47967 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
47968 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
47969 #endif
47970
47971 /*
47972 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
47973 spin_unlock_irqrestore(&info->port.lock, flags);
47974 return;
47975 }
47976 - if (info->port.count)
47977 + if (atomic_read(&info->port.count))
47978 atomic_dec(&rp_num_ports_open);
47979 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
47980 spin_unlock_irqrestore(&info->port.lock, flags);
47981 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
47982 index e2520ab..034e20b 100644
47983 --- a/drivers/tty/serial/ioc4_serial.c
47984 +++ b/drivers/tty/serial/ioc4_serial.c
47985 @@ -437,7 +437,7 @@ struct ioc4_soft {
47986 } is_intr_info[MAX_IOC4_INTR_ENTS];
47987
47988 /* Number of entries active in the above array */
47989 - atomic_t is_num_intrs;
47990 + atomic_unchecked_t is_num_intrs;
47991 } is_intr_type[IOC4_NUM_INTR_TYPES];
47992
47993 /* is_ir_lock must be held while
47994 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
47995 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
47996 || (type == IOC4_OTHER_INTR_TYPE)));
47997
47998 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
47999 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
48000 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
48001
48002 /* Save off the lower level interrupt handler */
48003 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
48004
48005 soft = arg;
48006 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
48007 - num_intrs = (int)atomic_read(
48008 + num_intrs = (int)atomic_read_unchecked(
48009 &soft->is_intr_type[intr_type].is_num_intrs);
48010
48011 this_mir = this_ir = pending_intrs(soft, intr_type);
48012 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
48013 index 1002054..dd644a8 100644
48014 --- a/drivers/tty/serial/kgdboc.c
48015 +++ b/drivers/tty/serial/kgdboc.c
48016 @@ -24,8 +24,9 @@
48017 #define MAX_CONFIG_LEN 40
48018
48019 static struct kgdb_io kgdboc_io_ops;
48020 +static struct kgdb_io kgdboc_io_ops_console;
48021
48022 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48023 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48024 static int configured = -1;
48025
48026 static char config[MAX_CONFIG_LEN];
48027 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48028 kgdboc_unregister_kbd();
48029 if (configured == 1)
48030 kgdb_unregister_io_module(&kgdboc_io_ops);
48031 + else if (configured == 2)
48032 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48033 }
48034
48035 static int configure_kgdboc(void)
48036 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48037 int err;
48038 char *cptr = config;
48039 struct console *cons;
48040 + int is_console = 0;
48041
48042 err = kgdboc_option_setup(config);
48043 if (err || !strlen(config) || isspace(config[0]))
48044 goto noconfig;
48045
48046 err = -ENODEV;
48047 - kgdboc_io_ops.is_console = 0;
48048 kgdb_tty_driver = NULL;
48049
48050 kgdboc_use_kms = 0;
48051 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48052 int idx;
48053 if (cons->device && cons->device(cons, &idx) == p &&
48054 idx == tty_line) {
48055 - kgdboc_io_ops.is_console = 1;
48056 + is_console = 1;
48057 break;
48058 }
48059 cons = cons->next;
48060 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48061 kgdb_tty_line = tty_line;
48062
48063 do_register:
48064 - err = kgdb_register_io_module(&kgdboc_io_ops);
48065 + if (is_console) {
48066 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48067 + configured = 2;
48068 + } else {
48069 + err = kgdb_register_io_module(&kgdboc_io_ops);
48070 + configured = 1;
48071 + }
48072 if (err)
48073 goto noconfig;
48074
48075 @@ -205,8 +214,6 @@ do_register:
48076 if (err)
48077 goto nmi_con_failed;
48078
48079 - configured = 1;
48080 -
48081 return 0;
48082
48083 nmi_con_failed:
48084 @@ -223,7 +230,7 @@ noconfig:
48085 static int __init init_kgdboc(void)
48086 {
48087 /* Already configured? */
48088 - if (configured == 1)
48089 + if (configured >= 1)
48090 return 0;
48091
48092 return configure_kgdboc();
48093 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48094 if (config[len - 1] == '\n')
48095 config[len - 1] = '\0';
48096
48097 - if (configured == 1)
48098 + if (configured >= 1)
48099 cleanup_kgdboc();
48100
48101 /* Go and configure with the new params. */
48102 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48103 .post_exception = kgdboc_post_exp_handler,
48104 };
48105
48106 +static struct kgdb_io kgdboc_io_ops_console = {
48107 + .name = "kgdboc",
48108 + .read_char = kgdboc_get_char,
48109 + .write_char = kgdboc_put_char,
48110 + .pre_exception = kgdboc_pre_exp_handler,
48111 + .post_exception = kgdboc_post_exp_handler,
48112 + .is_console = 1
48113 +};
48114 +
48115 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48116 /* This is only available if kgdboc is a built in for early debugging */
48117 static int __init kgdboc_early_init(char *opt)
48118 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48119 index 2c6cfb3..048274e 100644
48120 --- a/drivers/tty/serial/msm_serial.c
48121 +++ b/drivers/tty/serial/msm_serial.c
48122 @@ -857,7 +857,7 @@ static struct uart_driver msm_uart_driver = {
48123 .cons = MSM_CONSOLE,
48124 };
48125
48126 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48127 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48128
48129 static int __init msm_serial_probe(struct platform_device *pdev)
48130 {
48131 @@ -867,7 +867,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48132 int irq;
48133
48134 if (pdev->id == -1)
48135 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48136 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48137
48138 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48139 return -ENXIO;
48140 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48141 index 376079b..d8de7aa 100644
48142 --- a/drivers/tty/serial/samsung.c
48143 +++ b/drivers/tty/serial/samsung.c
48144 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48145 }
48146 }
48147
48148 +static int s3c64xx_serial_startup(struct uart_port *port);
48149 static int s3c24xx_serial_startup(struct uart_port *port)
48150 {
48151 struct s3c24xx_uart_port *ourport = to_ourport(port);
48152 int ret;
48153
48154 + /* Startup sequence is different for s3c64xx and higher SoC's */
48155 + if (s3c24xx_serial_has_interrupt_mask(port))
48156 + return s3c64xx_serial_startup(port);
48157 +
48158 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48159 port->mapbase, port->membase);
48160
48161 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48162 /* setup info for port */
48163 port->dev = &platdev->dev;
48164
48165 - /* Startup sequence is different for s3c64xx and higher SoC's */
48166 - if (s3c24xx_serial_has_interrupt_mask(port))
48167 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48168 -
48169 port->uartclk = 1;
48170
48171 if (cfg->uart_flags & UPF_CONS_FLOW) {
48172 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48173 index 28cdd28..56f1d60 100644
48174 --- a/drivers/tty/serial/serial_core.c
48175 +++ b/drivers/tty/serial/serial_core.c
48176 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48177 uart_flush_buffer(tty);
48178 uart_shutdown(tty, state);
48179 spin_lock_irqsave(&port->lock, flags);
48180 - port->count = 0;
48181 + atomic_set(&port->count, 0);
48182 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48183 spin_unlock_irqrestore(&port->lock, flags);
48184 tty_port_tty_set(port, NULL);
48185 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48186 goto end;
48187 }
48188
48189 - port->count++;
48190 + atomic_inc(&port->count);
48191 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48192 retval = -ENXIO;
48193 goto err_dec_count;
48194 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48195 /*
48196 * Make sure the device is in D0 state.
48197 */
48198 - if (port->count == 1)
48199 + if (atomic_read(&port->count) == 1)
48200 uart_change_pm(state, UART_PM_STATE_ON);
48201
48202 /*
48203 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48204 end:
48205 return retval;
48206 err_dec_count:
48207 - port->count--;
48208 + atomic_inc(&port->count);
48209 mutex_unlock(&port->mutex);
48210 goto end;
48211 }
48212 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48213 index 8eaf1ab..85c030d 100644
48214 --- a/drivers/tty/synclink.c
48215 +++ b/drivers/tty/synclink.c
48216 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48217
48218 if (debug_level >= DEBUG_LEVEL_INFO)
48219 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48220 - __FILE__,__LINE__, info->device_name, info->port.count);
48221 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48222
48223 if (tty_port_close_start(&info->port, tty, filp) == 0)
48224 goto cleanup;
48225 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48226 cleanup:
48227 if (debug_level >= DEBUG_LEVEL_INFO)
48228 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48229 - tty->driver->name, info->port.count);
48230 + tty->driver->name, atomic_read(&info->port.count));
48231
48232 } /* end of mgsl_close() */
48233
48234 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48235
48236 mgsl_flush_buffer(tty);
48237 shutdown(info);
48238 -
48239 - info->port.count = 0;
48240 +
48241 + atomic_set(&info->port.count, 0);
48242 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48243 info->port.tty = NULL;
48244
48245 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48246
48247 if (debug_level >= DEBUG_LEVEL_INFO)
48248 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48249 - __FILE__,__LINE__, tty->driver->name, port->count );
48250 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48251
48252 spin_lock_irqsave(&info->irq_spinlock, flags);
48253 if (!tty_hung_up_p(filp)) {
48254 extra_count = true;
48255 - port->count--;
48256 + atomic_dec(&port->count);
48257 }
48258 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48259 port->blocked_open++;
48260 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48261
48262 if (debug_level >= DEBUG_LEVEL_INFO)
48263 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48264 - __FILE__,__LINE__, tty->driver->name, port->count );
48265 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48266
48267 tty_unlock(tty);
48268 schedule();
48269 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48270
48271 /* FIXME: Racy on hangup during close wait */
48272 if (extra_count)
48273 - port->count++;
48274 + atomic_inc(&port->count);
48275 port->blocked_open--;
48276
48277 if (debug_level >= DEBUG_LEVEL_INFO)
48278 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48279 - __FILE__,__LINE__, tty->driver->name, port->count );
48280 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48281
48282 if (!retval)
48283 port->flags |= ASYNC_NORMAL_ACTIVE;
48284 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48285
48286 if (debug_level >= DEBUG_LEVEL_INFO)
48287 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48288 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48289 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48290
48291 /* If port is closing, signal caller to try again */
48292 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48293 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48294 spin_unlock_irqrestore(&info->netlock, flags);
48295 goto cleanup;
48296 }
48297 - info->port.count++;
48298 + atomic_inc(&info->port.count);
48299 spin_unlock_irqrestore(&info->netlock, flags);
48300
48301 - if (info->port.count == 1) {
48302 + if (atomic_read(&info->port.count) == 1) {
48303 /* 1st open on this device, init hardware */
48304 retval = startup(info);
48305 if (retval < 0)
48306 @@ -3446,8 +3446,8 @@ cleanup:
48307 if (retval) {
48308 if (tty->count == 1)
48309 info->port.tty = NULL; /* tty layer will release tty struct */
48310 - if(info->port.count)
48311 - info->port.count--;
48312 + if (atomic_read(&info->port.count))
48313 + atomic_dec(&info->port.count);
48314 }
48315
48316 return retval;
48317 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48318 unsigned short new_crctype;
48319
48320 /* return error if TTY interface open */
48321 - if (info->port.count)
48322 + if (atomic_read(&info->port.count))
48323 return -EBUSY;
48324
48325 switch (encoding)
48326 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48327
48328 /* arbitrate between network and tty opens */
48329 spin_lock_irqsave(&info->netlock, flags);
48330 - if (info->port.count != 0 || info->netcount != 0) {
48331 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48332 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48333 spin_unlock_irqrestore(&info->netlock, flags);
48334 return -EBUSY;
48335 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48336 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48337
48338 /* return error if TTY interface open */
48339 - if (info->port.count)
48340 + if (atomic_read(&info->port.count))
48341 return -EBUSY;
48342
48343 if (cmd != SIOCWANDEV)
48344 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48345 index 1abf946..1ee34fc 100644
48346 --- a/drivers/tty/synclink_gt.c
48347 +++ b/drivers/tty/synclink_gt.c
48348 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48349 tty->driver_data = info;
48350 info->port.tty = tty;
48351
48352 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48353 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48354
48355 /* If port is closing, signal caller to try again */
48356 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48357 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48358 mutex_unlock(&info->port.mutex);
48359 goto cleanup;
48360 }
48361 - info->port.count++;
48362 + atomic_inc(&info->port.count);
48363 spin_unlock_irqrestore(&info->netlock, flags);
48364
48365 - if (info->port.count == 1) {
48366 + if (atomic_read(&info->port.count) == 1) {
48367 /* 1st open on this device, init hardware */
48368 retval = startup(info);
48369 if (retval < 0) {
48370 @@ -715,8 +715,8 @@ cleanup:
48371 if (retval) {
48372 if (tty->count == 1)
48373 info->port.tty = NULL; /* tty layer will release tty struct */
48374 - if(info->port.count)
48375 - info->port.count--;
48376 + if(atomic_read(&info->port.count))
48377 + atomic_dec(&info->port.count);
48378 }
48379
48380 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48381 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48382
48383 if (sanity_check(info, tty->name, "close"))
48384 return;
48385 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48386 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48387
48388 if (tty_port_close_start(&info->port, tty, filp) == 0)
48389 goto cleanup;
48390 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48391 tty_port_close_end(&info->port, tty);
48392 info->port.tty = NULL;
48393 cleanup:
48394 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48395 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48396 }
48397
48398 static void hangup(struct tty_struct *tty)
48399 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48400 shutdown(info);
48401
48402 spin_lock_irqsave(&info->port.lock, flags);
48403 - info->port.count = 0;
48404 + atomic_set(&info->port.count, 0);
48405 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48406 info->port.tty = NULL;
48407 spin_unlock_irqrestore(&info->port.lock, flags);
48408 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48409 unsigned short new_crctype;
48410
48411 /* return error if TTY interface open */
48412 - if (info->port.count)
48413 + if (atomic_read(&info->port.count))
48414 return -EBUSY;
48415
48416 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48417 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48418
48419 /* arbitrate between network and tty opens */
48420 spin_lock_irqsave(&info->netlock, flags);
48421 - if (info->port.count != 0 || info->netcount != 0) {
48422 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48423 DBGINFO(("%s hdlc_open busy\n", dev->name));
48424 spin_unlock_irqrestore(&info->netlock, flags);
48425 return -EBUSY;
48426 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48427 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48428
48429 /* return error if TTY interface open */
48430 - if (info->port.count)
48431 + if (atomic_read(&info->port.count))
48432 return -EBUSY;
48433
48434 if (cmd != SIOCWANDEV)
48435 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48436 if (port == NULL)
48437 continue;
48438 spin_lock(&port->lock);
48439 - if ((port->port.count || port->netcount) &&
48440 + if ((atomic_read(&port->port.count) || port->netcount) &&
48441 port->pending_bh && !port->bh_running &&
48442 !port->bh_requested) {
48443 DBGISR(("%s bh queued\n", port->device_name));
48444 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48445 spin_lock_irqsave(&info->lock, flags);
48446 if (!tty_hung_up_p(filp)) {
48447 extra_count = true;
48448 - port->count--;
48449 + atomic_dec(&port->count);
48450 }
48451 spin_unlock_irqrestore(&info->lock, flags);
48452 port->blocked_open++;
48453 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48454 remove_wait_queue(&port->open_wait, &wait);
48455
48456 if (extra_count)
48457 - port->count++;
48458 + atomic_inc(&port->count);
48459 port->blocked_open--;
48460
48461 if (!retval)
48462 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48463 index dc6e969..5dc8786 100644
48464 --- a/drivers/tty/synclinkmp.c
48465 +++ b/drivers/tty/synclinkmp.c
48466 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48467
48468 if (debug_level >= DEBUG_LEVEL_INFO)
48469 printk("%s(%d):%s open(), old ref count = %d\n",
48470 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48471 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48472
48473 /* If port is closing, signal caller to try again */
48474 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48475 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48476 spin_unlock_irqrestore(&info->netlock, flags);
48477 goto cleanup;
48478 }
48479 - info->port.count++;
48480 + atomic_inc(&info->port.count);
48481 spin_unlock_irqrestore(&info->netlock, flags);
48482
48483 - if (info->port.count == 1) {
48484 + if (atomic_read(&info->port.count) == 1) {
48485 /* 1st open on this device, init hardware */
48486 retval = startup(info);
48487 if (retval < 0)
48488 @@ -796,8 +796,8 @@ cleanup:
48489 if (retval) {
48490 if (tty->count == 1)
48491 info->port.tty = NULL; /* tty layer will release tty struct */
48492 - if(info->port.count)
48493 - info->port.count--;
48494 + if(atomic_read(&info->port.count))
48495 + atomic_dec(&info->port.count);
48496 }
48497
48498 return retval;
48499 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48500
48501 if (debug_level >= DEBUG_LEVEL_INFO)
48502 printk("%s(%d):%s close() entry, count=%d\n",
48503 - __FILE__,__LINE__, info->device_name, info->port.count);
48504 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48505
48506 if (tty_port_close_start(&info->port, tty, filp) == 0)
48507 goto cleanup;
48508 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48509 cleanup:
48510 if (debug_level >= DEBUG_LEVEL_INFO)
48511 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48512 - tty->driver->name, info->port.count);
48513 + tty->driver->name, atomic_read(&info->port.count));
48514 }
48515
48516 /* Called by tty_hangup() when a hangup is signaled.
48517 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48518 shutdown(info);
48519
48520 spin_lock_irqsave(&info->port.lock, flags);
48521 - info->port.count = 0;
48522 + atomic_set(&info->port.count, 0);
48523 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48524 info->port.tty = NULL;
48525 spin_unlock_irqrestore(&info->port.lock, flags);
48526 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48527 unsigned short new_crctype;
48528
48529 /* return error if TTY interface open */
48530 - if (info->port.count)
48531 + if (atomic_read(&info->port.count))
48532 return -EBUSY;
48533
48534 switch (encoding)
48535 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48536
48537 /* arbitrate between network and tty opens */
48538 spin_lock_irqsave(&info->netlock, flags);
48539 - if (info->port.count != 0 || info->netcount != 0) {
48540 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48541 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48542 spin_unlock_irqrestore(&info->netlock, flags);
48543 return -EBUSY;
48544 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48545 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48546
48547 /* return error if TTY interface open */
48548 - if (info->port.count)
48549 + if (atomic_read(&info->port.count))
48550 return -EBUSY;
48551
48552 if (cmd != SIOCWANDEV)
48553 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48554 * do not request bottom half processing if the
48555 * device is not open in a normal mode.
48556 */
48557 - if ( port && (port->port.count || port->netcount) &&
48558 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48559 port->pending_bh && !port->bh_running &&
48560 !port->bh_requested ) {
48561 if ( debug_level >= DEBUG_LEVEL_ISR )
48562 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48563
48564 if (debug_level >= DEBUG_LEVEL_INFO)
48565 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48566 - __FILE__,__LINE__, tty->driver->name, port->count );
48567 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48568
48569 spin_lock_irqsave(&info->lock, flags);
48570 if (!tty_hung_up_p(filp)) {
48571 extra_count = true;
48572 - port->count--;
48573 + atomic_dec(&port->count);
48574 }
48575 spin_unlock_irqrestore(&info->lock, flags);
48576 port->blocked_open++;
48577 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48578
48579 if (debug_level >= DEBUG_LEVEL_INFO)
48580 printk("%s(%d):%s block_til_ready() count=%d\n",
48581 - __FILE__,__LINE__, tty->driver->name, port->count );
48582 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48583
48584 tty_unlock(tty);
48585 schedule();
48586 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48587 remove_wait_queue(&port->open_wait, &wait);
48588
48589 if (extra_count)
48590 - port->count++;
48591 + atomic_inc(&port->count);
48592 port->blocked_open--;
48593
48594 if (debug_level >= DEBUG_LEVEL_INFO)
48595 printk("%s(%d):%s block_til_ready() after, count=%d\n",
48596 - __FILE__,__LINE__, tty->driver->name, port->count );
48597 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48598
48599 if (!retval)
48600 port->flags |= ASYNC_NORMAL_ACTIVE;
48601 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
48602 index d5cc3ac..3263411 100644
48603 --- a/drivers/tty/sysrq.c
48604 +++ b/drivers/tty/sysrq.c
48605 @@ -1033,7 +1033,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
48606 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
48607 size_t count, loff_t *ppos)
48608 {
48609 - if (count) {
48610 + if (count && capable(CAP_SYS_ADMIN)) {
48611 char c;
48612
48613 if (get_user(c, buf))
48614 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
48615 index 20689b9..7fd3a31 100644
48616 --- a/drivers/tty/tty_io.c
48617 +++ b/drivers/tty/tty_io.c
48618 @@ -3468,7 +3468,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
48619
48620 void tty_default_fops(struct file_operations *fops)
48621 {
48622 - *fops = tty_fops;
48623 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
48624 }
48625
48626 /*
48627 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
48628 index 1afe192..73d2c20 100644
48629 --- a/drivers/tty/tty_ldisc.c
48630 +++ b/drivers/tty/tty_ldisc.c
48631 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
48632 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48633 tty_ldiscs[disc] = new_ldisc;
48634 new_ldisc->num = disc;
48635 - new_ldisc->refcount = 0;
48636 + atomic_set(&new_ldisc->refcount, 0);
48637 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48638
48639 return ret;
48640 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
48641 return -EINVAL;
48642
48643 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48644 - if (tty_ldiscs[disc]->refcount)
48645 + if (atomic_read(&tty_ldiscs[disc]->refcount))
48646 ret = -EBUSY;
48647 else
48648 tty_ldiscs[disc] = NULL;
48649 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
48650 if (ldops) {
48651 ret = ERR_PTR(-EAGAIN);
48652 if (try_module_get(ldops->owner)) {
48653 - ldops->refcount++;
48654 + atomic_inc(&ldops->refcount);
48655 ret = ldops;
48656 }
48657 }
48658 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
48659 unsigned long flags;
48660
48661 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
48662 - ldops->refcount--;
48663 + atomic_dec(&ldops->refcount);
48664 module_put(ldops->owner);
48665 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48666 }
48667 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
48668 /* unreleased reader reference(s) will cause this WARN */
48669 WARN_ON(!atomic_dec_and_test(&ld->users));
48670
48671 - ld->ops->refcount--;
48672 + atomic_dec(&ld->ops->refcount);
48673 module_put(ld->ops->owner);
48674 kfree(ld);
48675 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
48676 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
48677 index f597e88..b7f68ed 100644
48678 --- a/drivers/tty/tty_port.c
48679 +++ b/drivers/tty/tty_port.c
48680 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
48681 unsigned long flags;
48682
48683 spin_lock_irqsave(&port->lock, flags);
48684 - port->count = 0;
48685 + atomic_set(&port->count, 0);
48686 port->flags &= ~ASYNC_NORMAL_ACTIVE;
48687 tty = port->tty;
48688 if (tty)
48689 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48690 /* The port lock protects the port counts */
48691 spin_lock_irqsave(&port->lock, flags);
48692 if (!tty_hung_up_p(filp))
48693 - port->count--;
48694 + atomic_dec(&port->count);
48695 port->blocked_open++;
48696 spin_unlock_irqrestore(&port->lock, flags);
48697
48698 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
48699 we must not mess that up further */
48700 spin_lock_irqsave(&port->lock, flags);
48701 if (!tty_hung_up_p(filp))
48702 - port->count++;
48703 + atomic_inc(&port->count);
48704 port->blocked_open--;
48705 if (retval == 0)
48706 port->flags |= ASYNC_NORMAL_ACTIVE;
48707 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
48708 return 0;
48709 }
48710
48711 - if (tty->count == 1 && port->count != 1) {
48712 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
48713 printk(KERN_WARNING
48714 "tty_port_close_start: tty->count = 1 port count = %d.\n",
48715 - port->count);
48716 - port->count = 1;
48717 + atomic_read(&port->count));
48718 + atomic_set(&port->count, 1);
48719 }
48720 - if (--port->count < 0) {
48721 + if (atomic_dec_return(&port->count) < 0) {
48722 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
48723 - port->count);
48724 - port->count = 0;
48725 + atomic_read(&port->count));
48726 + atomic_set(&port->count, 0);
48727 }
48728
48729 - if (port->count) {
48730 + if (atomic_read(&port->count)) {
48731 spin_unlock_irqrestore(&port->lock, flags);
48732 if (port->ops->drop)
48733 port->ops->drop(port);
48734 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
48735 {
48736 spin_lock_irq(&port->lock);
48737 if (!tty_hung_up_p(filp))
48738 - ++port->count;
48739 + atomic_inc(&port->count);
48740 spin_unlock_irq(&port->lock);
48741 tty_port_tty_set(port, tty);
48742
48743 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
48744 index a9af1b9a..1e08e7f 100644
48745 --- a/drivers/tty/vt/keyboard.c
48746 +++ b/drivers/tty/vt/keyboard.c
48747 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
48748 kbd->kbdmode == VC_OFF) &&
48749 value != KVAL(K_SAK))
48750 return; /* SAK is allowed even in raw mode */
48751 +
48752 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
48753 + {
48754 + void *func = fn_handler[value];
48755 + if (func == fn_show_state || func == fn_show_ptregs ||
48756 + func == fn_show_mem)
48757 + return;
48758 + }
48759 +#endif
48760 +
48761 fn_handler[value](vc);
48762 }
48763
48764 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48765 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
48766 return -EFAULT;
48767
48768 - if (!capable(CAP_SYS_TTY_CONFIG))
48769 - perm = 0;
48770 -
48771 switch (cmd) {
48772 case KDGKBENT:
48773 /* Ensure another thread doesn't free it under us */
48774 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
48775 spin_unlock_irqrestore(&kbd_event_lock, flags);
48776 return put_user(val, &user_kbe->kb_value);
48777 case KDSKBENT:
48778 + if (!capable(CAP_SYS_TTY_CONFIG))
48779 + perm = 0;
48780 +
48781 if (!perm)
48782 return -EPERM;
48783 if (!i && v == K_NOSUCHMAP) {
48784 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48785 int i, j, k;
48786 int ret;
48787
48788 - if (!capable(CAP_SYS_TTY_CONFIG))
48789 - perm = 0;
48790 -
48791 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
48792 if (!kbs) {
48793 ret = -ENOMEM;
48794 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
48795 kfree(kbs);
48796 return ((p && *p) ? -EOVERFLOW : 0);
48797 case KDSKBSENT:
48798 + if (!capable(CAP_SYS_TTY_CONFIG))
48799 + perm = 0;
48800 +
48801 if (!perm) {
48802 ret = -EPERM;
48803 goto reterr;
48804 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
48805 index 3b96f18..6f6a8f1 100644
48806 --- a/drivers/uio/uio.c
48807 +++ b/drivers/uio/uio.c
48808 @@ -25,6 +25,7 @@
48809 #include <linux/kobject.h>
48810 #include <linux/cdev.h>
48811 #include <linux/uio_driver.h>
48812 +#include <asm/local.h>
48813
48814 #define UIO_MAX_DEVICES (1U << MINORBITS)
48815
48816 @@ -32,10 +33,10 @@ struct uio_device {
48817 struct module *owner;
48818 struct device *dev;
48819 int minor;
48820 - atomic_t event;
48821 + atomic_unchecked_t event;
48822 struct fasync_struct *async_queue;
48823 wait_queue_head_t wait;
48824 - int vma_count;
48825 + local_t vma_count;
48826 struct uio_info *info;
48827 struct kobject *map_dir;
48828 struct kobject *portio_dir;
48829 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
48830 struct device_attribute *attr, char *buf)
48831 {
48832 struct uio_device *idev = dev_get_drvdata(dev);
48833 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
48834 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
48835 }
48836
48837 static struct device_attribute uio_class_attributes[] = {
48838 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
48839 {
48840 struct uio_device *idev = info->uio_dev;
48841
48842 - atomic_inc(&idev->event);
48843 + atomic_inc_unchecked(&idev->event);
48844 wake_up_interruptible(&idev->wait);
48845 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
48846 }
48847 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
48848 }
48849
48850 listener->dev = idev;
48851 - listener->event_count = atomic_read(&idev->event);
48852 + listener->event_count = atomic_read_unchecked(&idev->event);
48853 filep->private_data = listener;
48854
48855 if (idev->info->open) {
48856 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
48857 return -EIO;
48858
48859 poll_wait(filep, &idev->wait, wait);
48860 - if (listener->event_count != atomic_read(&idev->event))
48861 + if (listener->event_count != atomic_read_unchecked(&idev->event))
48862 return POLLIN | POLLRDNORM;
48863 return 0;
48864 }
48865 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
48866 do {
48867 set_current_state(TASK_INTERRUPTIBLE);
48868
48869 - event_count = atomic_read(&idev->event);
48870 + event_count = atomic_read_unchecked(&idev->event);
48871 if (event_count != listener->event_count) {
48872 if (copy_to_user(buf, &event_count, count))
48873 retval = -EFAULT;
48874 @@ -584,9 +585,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
48875 static int uio_find_mem_index(struct vm_area_struct *vma)
48876 {
48877 struct uio_device *idev = vma->vm_private_data;
48878 + unsigned long size;
48879
48880 if (vma->vm_pgoff < MAX_UIO_MAPS) {
48881 - if (idev->info->mem[vma->vm_pgoff].size == 0)
48882 + size = idev->info->mem[vma->vm_pgoff].size;
48883 + if (size == 0)
48884 + return -1;
48885 + if (vma->vm_end - vma->vm_start > size)
48886 return -1;
48887 return (int)vma->vm_pgoff;
48888 }
48889 @@ -596,13 +601,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
48890 static void uio_vma_open(struct vm_area_struct *vma)
48891 {
48892 struct uio_device *idev = vma->vm_private_data;
48893 - idev->vma_count++;
48894 + local_inc(&idev->vma_count);
48895 }
48896
48897 static void uio_vma_close(struct vm_area_struct *vma)
48898 {
48899 struct uio_device *idev = vma->vm_private_data;
48900 - idev->vma_count--;
48901 + local_dec(&idev->vma_count);
48902 }
48903
48904 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
48905 @@ -640,14 +645,25 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
48906 {
48907 struct uio_device *idev = vma->vm_private_data;
48908 int mi = uio_find_mem_index(vma);
48909 + struct uio_mem *mem;
48910 if (mi < 0)
48911 return -EINVAL;
48912 + mem = idev->info->mem + mi;
48913
48914 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
48915
48916 + /*
48917 + * We cannot use the vm_iomap_memory() helper here,
48918 + * because vma->vm_pgoff is the map index we looked
48919 + * up above in uio_find_mem_index(), rather than an
48920 + * actual page offset into the mmap.
48921 + *
48922 + * So we just do the physical mmap without a page
48923 + * offset.
48924 + */
48925 return remap_pfn_range(vma,
48926 vma->vm_start,
48927 - idev->info->mem[mi].addr >> PAGE_SHIFT,
48928 + mem->addr >> PAGE_SHIFT,
48929 vma->vm_end - vma->vm_start,
48930 vma->vm_page_prot);
48931 }
48932 @@ -809,7 +825,7 @@ int __uio_register_device(struct module *owner,
48933 idev->owner = owner;
48934 idev->info = info;
48935 init_waitqueue_head(&idev->wait);
48936 - atomic_set(&idev->event, 0);
48937 + atomic_set_unchecked(&idev->event, 0);
48938
48939 ret = uio_get_minor(idev);
48940 if (ret)
48941 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
48942 index 8a7eb77..c00402f 100644
48943 --- a/drivers/usb/atm/cxacru.c
48944 +++ b/drivers/usb/atm/cxacru.c
48945 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
48946 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
48947 if (ret < 2)
48948 return -EINVAL;
48949 - if (index < 0 || index > 0x7f)
48950 + if (index > 0x7f)
48951 return -EINVAL;
48952 pos += tmp;
48953
48954 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
48955 index 5e0d33a..cc10579 100644
48956 --- a/drivers/usb/atm/usbatm.c
48957 +++ b/drivers/usb/atm/usbatm.c
48958 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48959 if (printk_ratelimit())
48960 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
48961 __func__, vpi, vci);
48962 - atomic_inc(&vcc->stats->rx_err);
48963 + atomic_inc_unchecked(&vcc->stats->rx_err);
48964 return;
48965 }
48966
48967 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48968 if (length > ATM_MAX_AAL5_PDU) {
48969 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
48970 __func__, length, vcc);
48971 - atomic_inc(&vcc->stats->rx_err);
48972 + atomic_inc_unchecked(&vcc->stats->rx_err);
48973 goto out;
48974 }
48975
48976 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48977 if (sarb->len < pdu_length) {
48978 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
48979 __func__, pdu_length, sarb->len, vcc);
48980 - atomic_inc(&vcc->stats->rx_err);
48981 + atomic_inc_unchecked(&vcc->stats->rx_err);
48982 goto out;
48983 }
48984
48985 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
48986 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
48987 __func__, vcc);
48988 - atomic_inc(&vcc->stats->rx_err);
48989 + atomic_inc_unchecked(&vcc->stats->rx_err);
48990 goto out;
48991 }
48992
48993 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
48994 if (printk_ratelimit())
48995 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
48996 __func__, length);
48997 - atomic_inc(&vcc->stats->rx_drop);
48998 + atomic_inc_unchecked(&vcc->stats->rx_drop);
48999 goto out;
49000 }
49001
49002 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49003
49004 vcc->push(vcc, skb);
49005
49006 - atomic_inc(&vcc->stats->rx);
49007 + atomic_inc_unchecked(&vcc->stats->rx);
49008 out:
49009 skb_trim(sarb, 0);
49010 }
49011 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
49012 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
49013
49014 usbatm_pop(vcc, skb);
49015 - atomic_inc(&vcc->stats->tx);
49016 + atomic_inc_unchecked(&vcc->stats->tx);
49017
49018 skb = skb_dequeue(&instance->sndqueue);
49019 }
49020 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
49021 if (!left--)
49022 return sprintf(page,
49023 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
49024 - atomic_read(&atm_dev->stats.aal5.tx),
49025 - atomic_read(&atm_dev->stats.aal5.tx_err),
49026 - atomic_read(&atm_dev->stats.aal5.rx),
49027 - atomic_read(&atm_dev->stats.aal5.rx_err),
49028 - atomic_read(&atm_dev->stats.aal5.rx_drop));
49029 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
49030 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
49031 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
49032 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
49033 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
49034
49035 if (!left--) {
49036 if (instance->disconnected)
49037 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
49038 index 2a3bbdf..91d72cf 100644
49039 --- a/drivers/usb/core/devices.c
49040 +++ b/drivers/usb/core/devices.c
49041 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49042 * time it gets called.
49043 */
49044 static struct device_connect_event {
49045 - atomic_t count;
49046 + atomic_unchecked_t count;
49047 wait_queue_head_t wait;
49048 } device_event = {
49049 .count = ATOMIC_INIT(1),
49050 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49051
49052 void usbfs_conn_disc_event(void)
49053 {
49054 - atomic_add(2, &device_event.count);
49055 + atomic_add_unchecked(2, &device_event.count);
49056 wake_up(&device_event.wait);
49057 }
49058
49059 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49060
49061 poll_wait(file, &device_event.wait, wait);
49062
49063 - event_count = atomic_read(&device_event.count);
49064 + event_count = atomic_read_unchecked(&device_event.count);
49065 if (file->f_version != event_count) {
49066 file->f_version = event_count;
49067 return POLLIN | POLLRDNORM;
49068 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49069 index 014dc99..4d25fd7 100644
49070 --- a/drivers/usb/core/hcd.c
49071 +++ b/drivers/usb/core/hcd.c
49072 @@ -1551,7 +1551,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49073 */
49074 usb_get_urb(urb);
49075 atomic_inc(&urb->use_count);
49076 - atomic_inc(&urb->dev->urbnum);
49077 + atomic_inc_unchecked(&urb->dev->urbnum);
49078 usbmon_urb_submit(&hcd->self, urb);
49079
49080 /* NOTE requirements on root-hub callers (usbfs and the hub
49081 @@ -1578,7 +1578,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49082 urb->hcpriv = NULL;
49083 INIT_LIST_HEAD(&urb->urb_list);
49084 atomic_dec(&urb->use_count);
49085 - atomic_dec(&urb->dev->urbnum);
49086 + atomic_dec_unchecked(&urb->dev->urbnum);
49087 if (atomic_read(&urb->reject))
49088 wake_up(&usb_kill_urb_queue);
49089 usb_put_urb(urb);
49090 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49091 index 17c3785..deffb11 100644
49092 --- a/drivers/usb/core/hub.c
49093 +++ b/drivers/usb/core/hub.c
49094 @@ -27,6 +27,7 @@
49095 #include <linux/freezer.h>
49096 #include <linux/random.h>
49097 #include <linux/pm_qos.h>
49098 +#include <linux/grsecurity.h>
49099
49100 #include <asm/uaccess.h>
49101 #include <asm/byteorder.h>
49102 @@ -4421,6 +4422,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49103 goto done;
49104 return;
49105 }
49106 +
49107 + if (gr_handle_new_usb())
49108 + goto done;
49109 +
49110 if (hub_is_superspeed(hub->hdev))
49111 unit_load = 150;
49112 else
49113 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49114 index e7ee1e4..1dfc9ea4 100644
49115 --- a/drivers/usb/core/message.c
49116 +++ b/drivers/usb/core/message.c
49117 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49118 * method can wait for it to complete. Since you don't have a handle on the
49119 * URB used, you can't cancel the request.
49120 */
49121 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49122 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49123 __u8 requesttype, __u16 value, __u16 index, void *data,
49124 __u16 size, int timeout)
49125 {
49126 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49127 index d9284b9..17023c7 100644
49128 --- a/drivers/usb/core/sysfs.c
49129 +++ b/drivers/usb/core/sysfs.c
49130 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
49131 struct usb_device *udev;
49132
49133 udev = to_usb_device(dev);
49134 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49135 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49136 }
49137 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
49138
49139 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49140 index 7dad603..350f7a9 100644
49141 --- a/drivers/usb/core/usb.c
49142 +++ b/drivers/usb/core/usb.c
49143 @@ -422,7 +422,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49144 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49145 dev->state = USB_STATE_ATTACHED;
49146 dev->lpm_disable_count = 1;
49147 - atomic_set(&dev->urbnum, 0);
49148 + atomic_set_unchecked(&dev->urbnum, 0);
49149
49150 INIT_LIST_HEAD(&dev->ep0.urb_list);
49151 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49152 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49153 index 14d28d6..5f511ac 100644
49154 --- a/drivers/usb/dwc3/gadget.c
49155 +++ b/drivers/usb/dwc3/gadget.c
49156 @@ -550,8 +550,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49157 if (!usb_endpoint_xfer_isoc(desc))
49158 return 0;
49159
49160 - memset(&trb_link, 0, sizeof(trb_link));
49161 -
49162 /* Link TRB for ISOC. The HWO bit is never reset */
49163 trb_st_hw = &dep->trb_pool[0];
49164
49165 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49166 index 5e29dde..eca992f 100644
49167 --- a/drivers/usb/early/ehci-dbgp.c
49168 +++ b/drivers/usb/early/ehci-dbgp.c
49169 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49170
49171 #ifdef CONFIG_KGDB
49172 static struct kgdb_io kgdbdbgp_io_ops;
49173 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49174 +static struct kgdb_io kgdbdbgp_io_ops_console;
49175 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49176 #else
49177 #define dbgp_kgdb_mode (0)
49178 #endif
49179 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49180 .write_char = kgdbdbgp_write_char,
49181 };
49182
49183 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49184 + .name = "kgdbdbgp",
49185 + .read_char = kgdbdbgp_read_char,
49186 + .write_char = kgdbdbgp_write_char,
49187 + .is_console = 1
49188 +};
49189 +
49190 static int kgdbdbgp_wait_time;
49191
49192 static int __init kgdbdbgp_parse_config(char *str)
49193 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49194 ptr++;
49195 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49196 }
49197 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49198 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49199 + if (early_dbgp_console.index != -1)
49200 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49201 + else
49202 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49203
49204 return 0;
49205 }
49206 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49207 index b369292..9f3ba40 100644
49208 --- a/drivers/usb/gadget/u_serial.c
49209 +++ b/drivers/usb/gadget/u_serial.c
49210 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49211 spin_lock_irq(&port->port_lock);
49212
49213 /* already open? Great. */
49214 - if (port->port.count) {
49215 + if (atomic_read(&port->port.count)) {
49216 status = 0;
49217 - port->port.count++;
49218 + atomic_inc(&port->port.count);
49219
49220 /* currently opening/closing? wait ... */
49221 } else if (port->openclose) {
49222 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49223 tty->driver_data = port;
49224 port->port.tty = tty;
49225
49226 - port->port.count = 1;
49227 + atomic_set(&port->port.count, 1);
49228 port->openclose = false;
49229
49230 /* if connected, start the I/O stream */
49231 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49232
49233 spin_lock_irq(&port->port_lock);
49234
49235 - if (port->port.count != 1) {
49236 - if (port->port.count == 0)
49237 + if (atomic_read(&port->port.count) != 1) {
49238 + if (atomic_read(&port->port.count) == 0)
49239 WARN_ON(1);
49240 else
49241 - --port->port.count;
49242 + atomic_dec(&port->port.count);
49243 goto exit;
49244 }
49245
49246 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49247 * and sleep if necessary
49248 */
49249 port->openclose = true;
49250 - port->port.count = 0;
49251 + atomic_set(&port->port.count, 0);
49252
49253 gser = port->port_usb;
49254 if (gser && gser->disconnect)
49255 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49256 int cond;
49257
49258 spin_lock_irq(&port->port_lock);
49259 - cond = (port->port.count == 0) && !port->openclose;
49260 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49261 spin_unlock_irq(&port->port_lock);
49262 return cond;
49263 }
49264 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49265 /* if it's already open, start I/O ... and notify the serial
49266 * protocol about open/close status (connect/disconnect).
49267 */
49268 - if (port->port.count) {
49269 + if (atomic_read(&port->port.count)) {
49270 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49271 gs_start_io(port);
49272 if (gser->connect)
49273 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49274
49275 port->port_usb = NULL;
49276 gser->ioport = NULL;
49277 - if (port->port.count > 0 || port->openclose) {
49278 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49279 wake_up_interruptible(&port->drain_wait);
49280 if (port->port.tty)
49281 tty_hangup(port->port.tty);
49282 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49283
49284 /* finally, free any unused/unusable I/O buffers */
49285 spin_lock_irqsave(&port->port_lock, flags);
49286 - if (port->port.count == 0 && !port->openclose)
49287 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49288 gs_buf_free(&port->port_write_buf);
49289 gs_free_requests(gser->out, &port->read_pool, NULL);
49290 gs_free_requests(gser->out, &port->read_queue, NULL);
49291 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49292 index ba6a5d6..f88f7f3 100644
49293 --- a/drivers/usb/misc/appledisplay.c
49294 +++ b/drivers/usb/misc/appledisplay.c
49295 @@ -83,7 +83,7 @@ struct appledisplay {
49296 spinlock_t lock;
49297 };
49298
49299 -static atomic_t count_displays = ATOMIC_INIT(0);
49300 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49301 static struct workqueue_struct *wq;
49302
49303 static void appledisplay_complete(struct urb *urb)
49304 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49305
49306 /* Register backlight device */
49307 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49308 - atomic_inc_return(&count_displays) - 1);
49309 + atomic_inc_return_unchecked(&count_displays) - 1);
49310 memset(&props, 0, sizeof(struct backlight_properties));
49311 props.type = BACKLIGHT_RAW;
49312 props.max_brightness = 0xff;
49313 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49314 index afb50ea..7b0b1cf 100644
49315 --- a/drivers/usb/serial/console.c
49316 +++ b/drivers/usb/serial/console.c
49317 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49318
49319 info->port = port;
49320
49321 - ++port->port.count;
49322 + atomic_inc(&port->port.count);
49323 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49324 if (serial->type->set_termios) {
49325 /*
49326 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
49327 }
49328 /* Now that any required fake tty operations are completed restore
49329 * the tty port count */
49330 - --port->port.count;
49331 + atomic_dec(&port->port.count);
49332 /* The console is special in terms of closing the device so
49333 * indicate this port is now acting as a system console. */
49334 port->port.console = 1;
49335 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
49336 free_tty:
49337 kfree(tty);
49338 reset_open_count:
49339 - port->port.count = 0;
49340 + atomic_set(&port->port.count, 0);
49341 usb_autopm_put_interface(serial->interface);
49342 error_get_interface:
49343 usb_serial_put(serial);
49344 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49345 index 75f70f0..d467e1a 100644
49346 --- a/drivers/usb/storage/usb.h
49347 +++ b/drivers/usb/storage/usb.h
49348 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49349 __u8 useProtocol;
49350 __u8 useTransport;
49351 int (*initFunction)(struct us_data *);
49352 -};
49353 +} __do_const;
49354
49355
49356 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49357 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49358 index d6bea3e..60b250e 100644
49359 --- a/drivers/usb/wusbcore/wa-hc.h
49360 +++ b/drivers/usb/wusbcore/wa-hc.h
49361 @@ -192,7 +192,7 @@ struct wahc {
49362 struct list_head xfer_delayed_list;
49363 spinlock_t xfer_list_lock;
49364 struct work_struct xfer_work;
49365 - atomic_t xfer_id_count;
49366 + atomic_unchecked_t xfer_id_count;
49367 };
49368
49369
49370 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
49371 INIT_LIST_HEAD(&wa->xfer_delayed_list);
49372 spin_lock_init(&wa->xfer_list_lock);
49373 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
49374 - atomic_set(&wa->xfer_id_count, 1);
49375 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49376 }
49377
49378 /**
49379 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49380 index d3493ca..0c33b7e 100644
49381 --- a/drivers/usb/wusbcore/wa-xfer.c
49382 +++ b/drivers/usb/wusbcore/wa-xfer.c
49383 @@ -297,7 +297,7 @@ out:
49384 */
49385 static void wa_xfer_id_init(struct wa_xfer *xfer)
49386 {
49387 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49388 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49389 }
49390
49391 /*
49392 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49393 index 842f450..d1d7409 100644
49394 --- a/drivers/vfio/vfio.c
49395 +++ b/drivers/vfio/vfio.c
49396 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49397 return 0;
49398
49399 /* TODO Prevent device auto probing */
49400 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49401 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49402 iommu_group_id(group->iommu_group));
49403
49404 return 0;
49405 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49406 index 5174eba..86e764a 100644
49407 --- a/drivers/vhost/vringh.c
49408 +++ b/drivers/vhost/vringh.c
49409 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49410
49411 static inline int putu16_kern(u16 *p, u16 val)
49412 {
49413 - ACCESS_ONCE(*p) = val;
49414 + ACCESS_ONCE_RW(*p) = val;
49415 return 0;
49416 }
49417
49418 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49419 index a4dfe8c..297ddd9 100644
49420 --- a/drivers/video/aty/aty128fb.c
49421 +++ b/drivers/video/aty/aty128fb.c
49422 @@ -149,7 +149,7 @@ enum {
49423 };
49424
49425 /* Must match above enum */
49426 -static char * const r128_family[] = {
49427 +static const char * const r128_family[] = {
49428 "AGP",
49429 "PCI",
49430 "PRO AGP",
49431 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49432 index 9b0f12c..024673d 100644
49433 --- a/drivers/video/aty/atyfb_base.c
49434 +++ b/drivers/video/aty/atyfb_base.c
49435 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49436 par->accel_flags = var->accel_flags; /* hack */
49437
49438 if (var->accel_flags) {
49439 - info->fbops->fb_sync = atyfb_sync;
49440 + pax_open_kernel();
49441 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49442 + pax_close_kernel();
49443 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49444 } else {
49445 - info->fbops->fb_sync = NULL;
49446 + pax_open_kernel();
49447 + *(void **)&info->fbops->fb_sync = NULL;
49448 + pax_close_kernel();
49449 info->flags |= FBINFO_HWACCEL_DISABLED;
49450 }
49451
49452 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49453 index 95ec042..e6affdd 100644
49454 --- a/drivers/video/aty/mach64_cursor.c
49455 +++ b/drivers/video/aty/mach64_cursor.c
49456 @@ -7,6 +7,7 @@
49457 #include <linux/string.h>
49458
49459 #include <asm/io.h>
49460 +#include <asm/pgtable.h>
49461
49462 #ifdef __sparc__
49463 #include <asm/fbio.h>
49464 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49465 info->sprite.buf_align = 16; /* and 64 lines tall. */
49466 info->sprite.flags = FB_PIXMAP_IO;
49467
49468 - info->fbops->fb_cursor = atyfb_cursor;
49469 + pax_open_kernel();
49470 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49471 + pax_close_kernel();
49472
49473 return 0;
49474 }
49475 diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
49476 index a54ccdc..22ad8524 100644
49477 --- a/drivers/video/au1100fb.c
49478 +++ b/drivers/video/au1100fb.c
49479 @@ -361,37 +361,13 @@ void au1100fb_fb_rotate(struct fb_info *fbi, int angle)
49480 int au1100fb_fb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)
49481 {
49482 struct au1100fb_device *fbdev;
49483 - unsigned int len;
49484 - unsigned long start=0, off;
49485
49486 fbdev = to_au1100fb_device(fbi);
49487
49488 - if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
49489 - return -EINVAL;
49490 - }
49491 -
49492 - start = fbdev->fb_phys & PAGE_MASK;
49493 - len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);
49494 -
49495 - off = vma->vm_pgoff << PAGE_SHIFT;
49496 -
49497 - if ((vma->vm_end - vma->vm_start + off) > len) {
49498 - return -EINVAL;
49499 - }
49500 -
49501 - off += start;
49502 - vma->vm_pgoff = off >> PAGE_SHIFT;
49503 -
49504 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
49505 pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6
49506
49507 - if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
49508 - vma->vm_end - vma->vm_start,
49509 - vma->vm_page_prot)) {
49510 - return -EAGAIN;
49511 - }
49512 -
49513 - return 0;
49514 + return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);
49515 }
49516
49517 static struct fb_ops au1100fb_ops =
49518 diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c
49519 index 301224e..1d02897 100644
49520 --- a/drivers/video/au1200fb.c
49521 +++ b/drivers/video/au1200fb.c
49522 @@ -1233,34 +1233,13 @@ static int au1200fb_fb_blank(int blank_mode, struct fb_info *fbi)
49523 * method mainly to allow the use of the TLB streaming flag (CCA=6)
49524 */
49525 static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
49526 -
49527 {
49528 - unsigned int len;
49529 - unsigned long start=0, off;
49530 struct au1200fb_device *fbdev = info->par;
49531
49532 - if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
49533 - return -EINVAL;
49534 - }
49535 -
49536 - start = fbdev->fb_phys & PAGE_MASK;
49537 - len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len);
49538 -
49539 - off = vma->vm_pgoff << PAGE_SHIFT;
49540 -
49541 - if ((vma->vm_end - vma->vm_start + off) > len) {
49542 - return -EINVAL;
49543 - }
49544 -
49545 - off += start;
49546 - vma->vm_pgoff = off >> PAGE_SHIFT;
49547 -
49548 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
49549 pgprot_val(vma->vm_page_prot) |= _CACHE_MASK; /* CCA=7 */
49550
49551 - return io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
49552 - vma->vm_end - vma->vm_start,
49553 - vma->vm_page_prot);
49554 + return vm_iomap_memory(vma, fbdev->fb_phys, fbdev->fb_len);
49555 }
49556
49557 static void set_global(u_int cmd, struct au1200_lcd_global_regs_t *pdata)
49558 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49559 index bca6ccc..252107e 100644
49560 --- a/drivers/video/backlight/kb3886_bl.c
49561 +++ b/drivers/video/backlight/kb3886_bl.c
49562 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49563 static unsigned long kb3886bl_flags;
49564 #define KB3886BL_SUSPENDED 0x01
49565
49566 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49567 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49568 {
49569 .ident = "Sahara Touch-iT",
49570 .matches = {
49571 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49572 index 900aa4e..6d49418 100644
49573 --- a/drivers/video/fb_defio.c
49574 +++ b/drivers/video/fb_defio.c
49575 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49576
49577 BUG_ON(!fbdefio);
49578 mutex_init(&fbdefio->lock);
49579 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49580 + pax_open_kernel();
49581 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49582 + pax_close_kernel();
49583 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49584 INIT_LIST_HEAD(&fbdefio->pagelist);
49585 if (fbdefio->delay == 0) /* set a default of 1 s */
49586 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49587 page->mapping = NULL;
49588 }
49589
49590 - info->fbops->fb_mmap = NULL;
49591 + *(void **)&info->fbops->fb_mmap = NULL;
49592 mutex_destroy(&fbdefio->lock);
49593 }
49594 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49595 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
49596 index 5c3960d..15cf8fc 100644
49597 --- a/drivers/video/fbcmap.c
49598 +++ b/drivers/video/fbcmap.c
49599 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
49600 rc = -ENODEV;
49601 goto out;
49602 }
49603 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
49604 - !info->fbops->fb_setcmap)) {
49605 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
49606 rc = -EINVAL;
49607 goto out1;
49608 }
49609 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49610 index 36e1fe2..c744820 100644
49611 --- a/drivers/video/fbmem.c
49612 +++ b/drivers/video/fbmem.c
49613 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49614 image->dx += image->width + 8;
49615 }
49616 } else if (rotate == FB_ROTATE_UD) {
49617 - for (x = 0; x < num && image->dx >= 0; x++) {
49618 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49619 info->fbops->fb_imageblit(info, image);
49620 image->dx -= image->width + 8;
49621 }
49622 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49623 image->dy += image->height + 8;
49624 }
49625 } else if (rotate == FB_ROTATE_CCW) {
49626 - for (x = 0; x < num && image->dy >= 0; x++) {
49627 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
49628 info->fbops->fb_imageblit(info, image);
49629 image->dy -= image->height + 8;
49630 }
49631 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
49632 return -EFAULT;
49633 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
49634 return -EINVAL;
49635 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
49636 + if (con2fb.framebuffer >= FB_MAX)
49637 return -EINVAL;
49638 if (!registered_fb[con2fb.framebuffer])
49639 request_module("fb%d", con2fb.framebuffer);
49640 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
49641 index d4d2c5f..ebbd113 100644
49642 --- a/drivers/video/hyperv_fb.c
49643 +++ b/drivers/video/hyperv_fb.c
49644 @@ -233,7 +233,7 @@ static uint screen_fb_size;
49645 static inline int synthvid_send(struct hv_device *hdev,
49646 struct synthvid_msg *msg)
49647 {
49648 - static atomic64_t request_id = ATOMIC64_INIT(0);
49649 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
49650 int ret;
49651
49652 msg->pipe_hdr.type = PIPE_MSG_DATA;
49653 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
49654
49655 ret = vmbus_sendpacket(hdev->channel, msg,
49656 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
49657 - atomic64_inc_return(&request_id),
49658 + atomic64_inc_return_unchecked(&request_id),
49659 VM_PKT_DATA_INBAND, 0);
49660
49661 if (ret)
49662 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
49663 index 7672d2e..b56437f 100644
49664 --- a/drivers/video/i810/i810_accel.c
49665 +++ b/drivers/video/i810/i810_accel.c
49666 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
49667 }
49668 }
49669 printk("ringbuffer lockup!!!\n");
49670 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
49671 i810_report_error(mmio);
49672 par->dev_flags |= LOCKUP;
49673 info->pixmap.scan_align = 1;
49674 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
49675 index 285d552..eafa544 100644
49676 --- a/drivers/video/logo/logo_linux_clut224.ppm
49677 +++ b/drivers/video/logo/logo_linux_clut224.ppm
49678 @@ -1,883 +1,1123 @@
49679 P3
49680 80 80
49681 255
49682 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49683 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 33 49 54 59 85 92 73 97 106
49684 -83 116 129 105 131 142 115 114 122 74 88 93 20 29 31 0 0 0 0 0 0 0 0 0
49685 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49686 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10 10 10 10
49687 -10 10 10 6 6 6 6 6 6 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49690 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49691 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49692 -
49693 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49694 -0 0 0 0 0 0 2 3 3 17 23 26 50 67 72 73 97 106 59 85 92 73 97 106
49695 -105 131 142 124 127 131 105 131 142 105 131 142 53 75 83 6 8 8 0 0 0 0 0 0
49696 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49697 -0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 26 26 26 30 30 30 34 34 34
49698 -30 30 30 30 30 30 26 26 26 18 18 18 14 14 14 10 10 10 6 6 6 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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49701 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49702 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49703 -
49704 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0
49705 -0 0 0 1 1 1 26 35 39 59 85 92 59 85 92 59 85 92 29 43 47 53 75 83
49706 -108 122 132 132 98 104 108 122 132 105 131 142 101 101 101 43 45 48 6 8 8 0 0 0
49707 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49708 -6 6 6 14 14 14 26 26 26 42 42 42 54 54 54 66 66 66 78 78 78 78 78 78
49709 -78 78 78 74 74 74 66 66 66 54 54 54 42 42 42 26 26 26 18 18 18 10 10 10
49710 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49711 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49712 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49713 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49714 -
49715 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 0
49716 -11 15 17 27 40 45 59 85 92 59 85 92 27 40 45 31 45 49 73 97 106 93 121 133
49717 -108 122 132 108 122 132 105 131 142 108 122 132 105 131 142 73 97 106 26 35 39 0 0 0
49718 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
49719 -22 22 22 42 42 42 66 66 66 86 86 86 66 66 66 38 38 38 38 38 38 22 22 22
49720 -26 26 26 34 34 34 54 54 54 66 66 66 86 86 86 70 70 70 46 46 46 26 26 26
49721 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49722 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49723 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49724 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49725 -
49726 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 7 12 13 21 31 35 42 59 64
49727 -53 75 83 53 75 83 50 67 72 42 59 64 32 40 45 42 59 64 73 97 106 116 116 116
49728 -132 98 104 116 116 116 108 122 132 117 104 110 105 131 142 83 116 129 50 67 72 7 12 13
49729 -1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
49730 -50 50 50 82 82 82 58 58 58 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
49731 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 54 54 54 86 86 86 66 66 66
49732 -38 38 38 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49733 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49734 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49735 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49736 -
49737 -0 0 0 1 1 1 6 8 8 15 22 25 26 35 39 36 54 60 53 75 83 59 85 92
49738 -59 85 92 48 63 69 15 22 25 12 17 20 52 67 79 94 94 94 132 98 104 132 98 104
49739 -117 104 110 108 122 132 108 122 132 115 114 122 105 131 142 77 105 114 59 85 92 36 54 60
49740 -7 12 13 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
49741 -78 78 78 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49742 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 70 70 70
49743 -78 78 78 46 46 46 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
49744 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49745 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49746 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49747 -
49748 -0 0 0 15 22 25 29 43 47 36 54 60 42 59 64 42 59 64 48 63 69 21 31 35
49749 -6 8 8 29 43 47 36 50 56 43 45 48 79 78 84 132 98 104 165 78 79 132 98 104
49750 -108 122 132 117 104 110 117 104 110 108 122 132 77 105 114 73 97 106 95 131 149 78 102 129
49751 -36 50 56 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18 42 42 42 82 82 82
49752 -26 26 26 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49753 -2 2 6 2 2 6 2 2 6 14 14 14 46 46 46 34 34 34 6 6 6 2 2 6
49754 -42 42 42 78 78 78 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
49755 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49756 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49757 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49758 -
49759 -27 40 45 53 75 83 48 63 69 24 31 37 6 8 12 0 0 0 18 25 28 26 35 39
49760 -12 17 20 26 35 39 65 78 84 112 81 86 152 81 83 137 83 86 132 98 104 117 104 110
49761 -117 104 110 132 98 104 132 98 104 115 114 122 73 97 106 53 75 83 95 131 149 93 124 152
49762 -68 78 128 15 22 25 0 0 0 0 0 0 10 10 10 30 30 30 66 66 66 58 58 58
49763 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49764 -2 2 6 2 2 6 2 2 6 26 26 26 86 86 86 101 101 101 46 46 46 10 10 10
49765 -2 2 6 58 58 58 70 70 70 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
49766 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49767 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49768 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49769 -
49770 -36 50 56 21 30 33 4 7 7 0 0 0 1 1 1 17 12 12 69 31 31 68 59 64
49771 -57 59 63 21 31 35 32 40 45 86 73 69 152 81 83 152 81 83 117 104 110 132 98 104
49772 -152 81 83 132 98 104 108 122 132 77 105 114 77 105 114 93 121 133 95 131 149 93 124 152
49773 -95 131 149 53 75 83 11 15 17 0 0 0 14 14 14 42 42 42 86 86 86 10 10 10
49774 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49775 -2 2 6 2 2 6 2 2 6 30 30 30 94 94 94 94 94 94 58 58 58 26 26 26
49776 -2 2 6 6 6 6 78 78 78 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0
49777 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49778 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49779 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49780 -
49781 -17 23 26 2 3 3 0 0 0 17 12 12 69 31 31 123 55 55 123 55 55 152 81 83
49782 -86 73 69 17 23 26 7 12 13 45 54 57 101 101 101 137 83 86 132 98 104 132 98 104
49783 -137 83 86 117 104 110 77 105 114 42 59 64 50 67 72 78 102 129 91 117 157 91 117 157
49784 -95 131 149 83 116 129 40 48 73 6 6 6 22 22 22 62 62 62 62 62 62 2 2 6
49785 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49786 -2 2 6 2 2 6 2 2 6 26 26 26 54 54 54 38 38 38 18 18 18 10 10 10
49787 -2 2 6 2 2 6 34 34 34 82 82 82 38 38 38 14 14 14 0 0 0 0 0 0
49788 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49789 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49790 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49791 -
49792 -1 1 1 1 2 2 2 3 3 28 12 12 123 55 55 174 79 79 174 79 79 174 79 79
49793 -152 81 83 68 59 64 26 35 39 27 40 45 79 78 84 137 83 86 165 78 79 137 83 86
49794 -94 94 94 48 63 69 36 50 56 50 67 72 73 97 106 93 121 133 93 124 152 93 124 152
49795 -95 131 149 91 118 149 78 102 129 27 40 45 30 30 30 78 78 78 30 30 30 2 2 6
49796 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49797 -2 2 6 2 2 6 2 2 6 10 10 10 10 10 10 2 2 6 2 2 6 2 2 6
49798 -2 2 6 2 2 6 2 2 6 78 78 78 50 50 50 18 18 18 6 6 6 0 0 0
49799 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49800 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49801 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49802 -
49803 -4 5 3 24 53 24 19 31 15 8 7 3 90 61 47 165 78 79 174 79 79 174 79 79
49804 -174 79 79 137 83 86 60 52 57 7 12 13 17 23 26 70 70 70 132 98 104 112 81 86
49805 -79 78 84 31 45 49 15 22 25 53 75 83 91 118 149 86 106 160 91 117 157 93 124 152
49806 -91 117 157 93 124 152 95 131 149 53 75 83 50 50 50 86 86 86 14 14 14 2 2 6
49807 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49808 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49809 -2 2 6 2 2 6 2 2 6 54 54 54 66 66 66 26 26 26 6 6 6 0 0 0
49810 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49811 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49812 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49813 -
49814 -19 31 15 34 76 34 34 76 34 19 31 15 28 12 12 123 55 55 174 79 79 174 79 79
49815 -174 79 79 165 78 79 112 81 86 32 40 45 15 22 25 38 53 58 65 78 84 29 31 32
49816 -21 30 33 42 59 64 60 80 103 78 102 129 87 112 149 84 96 162 91 117 157 93 124 152
49817 -91 117 157 93 124 152 93 121 133 59 85 92 57 68 71 82 85 86 2 2 6 2 2 6
49818 -2 2 6 6 6 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
49819 -2 2 6 2 2 6 2 2 6 6 6 6 14 14 14 10 10 10 2 2 6 2 2 6
49820 -2 2 6 2 2 6 2 2 6 18 18 18 82 82 82 34 34 34 10 10 10 0 0 0
49821 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49822 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49823 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49824 -
49825 -34 76 34 40 89 40 40 89 40 34 76 34 8 15 6 48 26 18 123 55 55 174 79 79
49826 -174 79 79 174 79 79 137 83 86 68 59 64 32 40 45 21 30 33 31 45 49 21 31 35
49827 -12 17 20 48 63 69 78 102 129 81 88 166 84 96 162 91 117 157 93 124 152 91 117 157
49828 -93 124 152 95 131 149 83 116 129 59 85 92 57 68 71 86 86 86 2 2 6 2 2 6
49829 -6 6 6 6 6 6 22 22 22 34 34 34 6 6 6 2 2 6 2 2 6 2 2 6
49830 -2 2 6 2 2 6 18 18 18 34 34 34 10 10 10 50 50 50 22 22 22 2 2 6
49831 -2 2 6 2 2 6 2 2 6 10 10 10 86 86 86 42 42 42 14 14 14 0 0 0
49832 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49833 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49834 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49835 -
49836 -40 89 40 40 89 40 40 89 40 40 89 40 24 53 24 6 6 6 69 31 31 123 55 55
49837 -123 55 55 90 61 47 69 31 31 36 32 33 21 31 35 7 12 13 18 25 28 48 63 69
49838 -60 80 103 68 78 128 84 101 153 84 96 162 84 96 162 91 117 157 91 117 157 84 96 162
49839 -91 117 157 73 97 106 48 63 69 50 67 72 57 59 63 86 86 86 2 2 6 2 2 6
49840 -38 38 38 116 116 116 94 94 94 22 22 22 22 22 22 2 2 6 2 2 6 2 2 6
49841 -14 14 14 86 86 86 124 131 137 170 170 170 151 151 151 38 38 38 26 26 26 6 6 6
49842 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 46 46 46 14 14 14 0 0 0
49843 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49844 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49845 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49846 -
49847 -34 76 34 40 89 40 40 89 40 40 89 40 34 76 34 19 31 15 17 12 12 48 26 18
49848 -48 26 18 8 7 3 10 10 22 23 29 47 51 61 92 42 59 64 21 30 33 34 45 54
49849 -68 78 128 81 88 166 81 82 173 86 106 160 86 106 160 84 96 162 86 106 160 87 112 149
49850 -91 118 149 77 105 114 52 67 79 32 40 45 50 50 50 86 86 86 2 2 6 14 14 14
49851 -124 131 137 198 198 198 195 195 195 116 116 116 10 10 10 2 2 6 2 2 6 6 6 6
49852 -101 98 89 187 187 187 210 210 210 218 218 218 214 214 214 124 131 137 14 14 14 6 6 6
49853 -2 2 6 2 2 6 2 2 6 2 2 6 86 86 86 50 50 50 18 18 18 6 6 6
49854 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49855 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49856 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49857 -
49858 -19 31 15 34 76 34 40 89 40 40 89 40 40 89 40 24 53 24 8 7 3 0 0 0
49859 -6 8 12 28 32 52 51 61 92 54 54 122 74 77 160 68 78 128 26 35 39 6 8 8
49860 -34 45 54 68 78 128 84 96 162 86 106 160 86 106 160 81 88 166 84 96 162 87 112 149
49861 -73 97 106 36 50 56 33 49 54 18 18 18 46 46 46 86 86 86 2 2 6 54 54 54
49862 -218 218 218 195 195 195 226 226 226 246 246 246 58 58 58 2 2 6 2 2 6 30 30 30
49863 -210 210 210 253 253 253 170 170 170 124 127 131 221 221 221 234 234 234 74 74 74 2 2 6
49864 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49865 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49866 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49867 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49868 -
49869 -4 5 3 24 53 24 40 89 40 40 89 40 34 76 34 12 22 15 4 5 3 4 5 3
49870 -13 17 26 54 54 122 78 78 174 78 78 174 78 78 174 74 77 160 51 61 92 21 31 35
49871 -26 35 39 53 75 83 84 101 153 81 82 173 81 88 166 84 101 153 60 80 103 60 80 103
49872 -53 75 83 38 53 58 42 59 64 22 22 22 46 46 46 82 82 82 2 2 6 106 106 106
49873 -170 170 170 26 26 26 86 86 86 226 226 226 124 127 131 10 10 10 14 14 14 46 46 46
49874 -231 231 231 190 190 190 6 6 6 70 70 70 90 90 90 238 238 238 151 151 151 2 2 6
49875 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 58 58 58 22 22 22 6 6 6
49876 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49877 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49878 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49879 -
49880 -1 2 2 8 15 6 24 53 24 34 76 34 19 31 15 8 15 6 63 55 20 63 55 20
49881 -18 18 18 40 48 73 74 77 160 78 78 174 78 78 174 81 82 173 74 77 160 52 67 79
49882 -17 23 26 21 31 35 60 80 103 81 88 166 74 77 160 78 102 129 36 54 60 12 17 20
49883 -42 59 64 48 63 69 21 31 35 18 18 18 42 42 42 86 86 86 6 6 6 116 116 116
49884 -106 106 106 6 6 6 70 70 70 151 151 151 124 127 131 18 18 18 38 38 38 54 54 54
49885 -221 221 221 106 106 106 2 2 6 14 14 14 46 46 46 190 190 190 198 198 198 2 2 6
49886 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49887 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49888 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49889 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49890 -
49891 -11 15 17 0 0 0 12 22 15 19 31 15 8 15 6 63 55 20 149 139 69 149 139 69
49892 -63 55 20 10 10 22 54 54 122 78 78 174 78 78 174 78 78 174 81 82 173 68 78 128
49893 -24 31 37 6 6 6 36 50 56 60 80 103 51 61 92 42 59 64 36 50 56 31 45 49
49894 -29 43 47 27 40 45 6 8 8 14 14 14 42 42 42 94 94 94 14 14 14 101 101 101
49895 -124 127 131 2 2 6 18 18 18 116 116 116 106 107 48 121 92 8 121 92 8 98 70 6
49896 -170 170 170 106 106 106 2 2 6 2 2 6 2 2 6 195 195 195 195 195 195 6 6 6
49897 -2 2 6 2 2 6 2 2 6 2 2 6 74 74 74 62 62 62 22 22 22 6 6 6
49898 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49899 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49900 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49901 -
49902 -26 35 39 3 5 6 1 1 1 2 3 3 35 31 12 133 118 54 175 176 80 175 176 80
49903 -133 118 54 35 31 12 23 29 47 54 54 122 78 78 174 78 78 174 74 77 160 68 78 128
49904 -51 61 92 31 45 49 26 35 39 36 50 56 29 43 47 7 12 13 21 30 33 42 59 64
49905 -18 25 28 7 12 13 1 1 1 10 10 10 38 38 38 90 90 90 14 14 14 58 58 58
49906 -210 210 210 26 26 26 62 42 6 154 114 10 226 170 11 237 188 10 220 174 15 184 138 11
49907 -220 174 15 174 140 55 35 31 12 2 2 6 70 70 70 246 246 246 124 131 137 2 2 6
49908 -2 2 6 2 2 6 2 2 6 2 2 6 70 70 70 66 66 66 26 26 26 6 6 6
49909 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49910 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49911 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49912 -
49913 -27 40 45 17 23 26 2 3 3 1 1 1 56 77 35 165 152 80 175 176 80 175 176 80
49914 -175 176 80 106 107 48 22 22 22 28 32 52 54 54 122 54 54 122 51 61 92 28 32 52
49915 -20 27 34 31 45 49 11 15 17 7 12 13 36 50 56 31 45 49 29 43 47 36 50 56
49916 -6 8 8 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 14 14 14 10 10 10
49917 -195 195 195 198 179 130 192 133 9 220 174 15 239 182 13 237 188 10 232 195 16 239 207 25
49918 -237 201 50 241 208 19 232 195 16 184 138 11 198 179 130 208 206 196 42 42 42 2 2 6
49919 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 74 74 74 30 30 30 6 6 6
49920 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49921 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49922 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49923 -
49924 -15 22 25 26 35 39 15 22 25 0 0 0 35 31 12 133 118 54 175 176 80 175 176 80
49925 -175 176 80 165 152 80 56 77 35 6 8 12 23 29 47 13 17 26 2 2 6 0 0 0
49926 -1 2 2 26 35 39 26 35 39 26 35 39 42 59 64 42 59 64 20 29 31 6 8 8
49927 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 86 86 86 14 14 14 2 2 6
49928 -121 92 8 192 133 9 219 162 10 239 182 13 237 188 10 232 195 16 241 208 19 237 201 50
49929 -237 201 50 239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 121 92 8 2 2 6
49930 -2 2 6 2 2 6 2 2 6 2 2 6 50 50 50 82 82 82 34 34 34 10 10 10
49931 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49932 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49933 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49934 -
49935 -1 2 2 15 22 25 31 45 49 6 8 12 4 5 3 63 55 20 149 139 69 175 176 80
49936 -175 176 80 175 176 80 106 107 48 20 16 6 1 1 1 0 0 0 2 3 3 11 15 17
49937 -21 30 33 36 50 56 36 50 56 24 31 37 15 22 25 6 8 8 0 0 0 0 0 0
49938 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 82 82 82 30 30 30 62 42 6
49939 -180 123 7 206 145 10 230 174 11 239 182 13 237 188 10 238 202 15 241 208 19 237 201 50
49940 -239 207 25 241 208 19 241 208 19 241 208 19 230 187 11 220 174 15 184 138 11 6 6 6
49941 -2 2 6 2 2 6 2 2 6 2 2 6 26 26 26 94 94 94 42 42 42 14 14 14
49942 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49945 -
49946 -0 0 0 1 2 2 29 43 47 26 35 39 3 5 6 8 7 3 106 107 48 165 152 80
49947 -175 176 80 149 139 69 63 55 20 4 5 3 2 3 3 12 17 20 26 35 39 26 35 39
49948 -17 23 26 7 12 13 6 8 8 3 5 6 1 2 2 0 0 0 0 0 0 0 0 0
49949 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 50 50 50 104 69 6
49950 -192 133 9 216 158 10 236 178 12 237 188 10 232 195 16 241 208 19 237 201 50 237 201 50
49951 -241 208 19 241 208 19 241 208 19 204 160 10 200 144 11 216 158 10 156 118 10 2 2 6
49952 -2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 90 90 90 54 54 54 18 18 18
49953 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49954 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49955 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49956 -
49957 -0 0 0 0 0 0 12 17 20 27 40 45 18 25 28 1 1 1 35 31 12 106 107 48
49958 -149 139 69 56 77 35 8 7 3 1 2 2 12 17 20 26 35 39 21 31 35 11 15 17
49959 -3 5 6 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49960 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 78 78 78 46 46 46 22 22 22
49961 -137 92 6 204 160 10 239 182 13 237 188 10 238 202 15 241 208 19 241 208 19 241 208 19
49962 -241 208 19 204 160 10 184 138 11 210 150 10 216 158 10 210 150 10 98 70 6 2 2 6
49963 -6 6 6 54 54 54 14 14 14 2 2 6 2 2 6 62 62 62 74 74 74 30 30 30
49964 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49967 -
49968 -0 0 0 0 0 0 1 1 1 15 22 25 33 49 54 12 17 20 2 3 3 35 31 12
49969 -56 77 35 20 16 6 1 1 1 18 25 28 21 31 35 11 15 17 1 1 1 0 0 0
49970 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49971 -0 0 0 0 0 0 0 0 0 10 10 10 34 34 34 78 78 78 50 50 50 6 6 6
49972 -88 55 22 139 102 15 190 146 13 230 187 11 239 207 25 232 195 16 220 174 15 190 146 13
49973 -171 120 8 192 133 9 210 150 10 213 154 11 185 146 40 165 152 80 101 98 89 2 2 6
49974 -2 2 6 78 78 78 116 116 116 58 58 58 2 2 6 22 22 22 90 90 90 46 46 46
49975 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49978 -
49979 -0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 29 43 47 3 5 6 2 3 3
49980 -8 7 3 1 1 1 17 23 26 31 45 49 15 22 25 0 0 0 0 0 0 0 0 0
49981 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49982 -0 0 0 0 0 0 0 0 0 10 10 10 38 38 38 86 86 86 50 50 50 6 6 6
49983 -124 127 131 168 158 138 156 107 11 171 120 8 204 160 10 184 138 11 197 138 11 200 144 11
49984 -206 145 10 206 145 10 197 138 11 198 179 130 195 195 195 198 198 198 170 170 170 14 14 14
49985 -2 2 6 22 22 22 116 116 116 116 116 116 22 22 22 2 2 6 74 74 74 70 70 70
49986 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49987 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49988 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49989 -
49990 -0 0 0 0 0 0 0 0 0 0 0 0 11 15 17 31 45 49 26 35 39 3 5 6
49991 -0 0 0 7 12 13 27 40 45 18 25 28 0 0 0 0 0 0 0 0 0 0 0 0
49992 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49993 -0 0 0 0 0 0 6 6 6 18 18 18 50 50 50 101 101 101 26 26 26 10 10 10
49994 -124 131 137 190 190 190 168 158 138 156 107 11 197 138 11 200 144 11 197 138 11 192 133 9
49995 -180 123 7 185 146 40 198 179 130 187 187 187 202 202 202 221 221 221 214 214 214 66 66 66
49996 -2 2 6 2 2 6 50 50 50 62 62 62 6 6 6 2 2 6 10 10 10 90 90 90
49997 -50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50000 -
50001 -0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 15 22 25 36 54 60 18 25 28
50002 -0 0 0 21 30 33 27 40 45 2 3 3 0 0 0 0 0 0 0 0 0 0 0 0
50003 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50004 -0 0 0 0 0 0 10 10 10 34 34 34 74 74 74 74 74 74 2 2 6 6 6 6
50005 -151 151 151 198 198 198 190 190 190 168 158 138 148 132 55 156 107 11 156 107 11 169 125 40
50006 -168 158 138 187 187 187 190 190 190 210 210 210 246 246 246 253 253 253 253 253 253 180 180 180
50007 -6 6 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62
50008 -74 74 74 34 34 34 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50009 -0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0
50011 -
50012 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 27 40 45 35 52 58
50013 -18 25 28 35 52 58 17 23 26 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50014 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50015 -0 0 0 10 10 10 22 22 22 54 54 54 94 94 94 18 18 18 2 2 6 46 46 46
50016 -234 234 234 221 221 221 190 190 190 190 190 190 190 190 190 187 187 187 187 187 187 190 190 190
50017 -190 190 190 195 195 195 214 214 214 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50018 -82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 14 14 14
50019 -86 86 86 54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
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 0 0 0 0 0 0 0 0 0 0 0 0
50022 -
50023 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 12 13 33 49 54
50024 -52 72 81 36 54 60 6 8 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50025 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50026 -6 6 6 18 18 18 46 46 46 90 90 90 46 46 46 18 18 18 6 6 6 180 180 180
50027 -253 253 253 246 246 246 202 202 202 190 190 190 190 190 190 190 190 190 190 190 190 190 190 190
50028 -202 202 202 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50029 -202 202 202 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50030 -42 42 42 86 86 86 42 42 42 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
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 0 0 0 0 0 0 0 0 0
50033 -
50034 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20
50035 -36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50036 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50037 -14 14 14 38 38 38 74 74 74 66 66 66 2 2 6 6 6 6 90 90 90 250 250 250
50038 -253 253 253 253 253 253 238 238 238 198 198 198 190 190 190 190 190 190 195 195 195 221 221 221
50039 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50040 -253 253 253 82 82 82 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50041 -2 2 6 78 78 78 70 70 70 34 34 34 14 14 14 6 6 6 0 0 0 0 0 0
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 0 0 0 0 0 0
50044 -
50045 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50046 -21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50047 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50048 -34 34 34 66 66 66 78 78 78 6 6 6 2 2 6 18 18 18 218 218 218 253 253 253
50049 -253 253 253 253 253 253 253 253 253 246 246 246 226 226 226 231 231 231 246 246 246 253 253 253
50050 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50051 -253 253 253 180 180 180 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50052 -2 2 6 18 18 18 90 90 90 62 62 62 30 30 30 10 10 10 0 0 0 0 0 0
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 0 0 0
50055 -
50056 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50057 -12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50058 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26
50059 -58 58 58 90 90 90 18 18 18 2 2 6 2 2 6 106 106 106 253 253 253 253 253 253
50060 -253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253
50061 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50062 -253 253 253 231 231 231 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50063 -2 2 6 2 2 6 18 18 18 94 94 94 54 54 54 26 26 26 10 10 10 0 0 0
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 -
50067 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50068 -0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0 0 0 0 0 0 0
50069 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 50 50 50
50070 -90 90 90 26 26 26 2 2 6 2 2 6 14 14 14 195 195 195 250 250 250 253 253 253
50071 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50072 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50073 -250 250 250 242 242 242 54 54 54 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50074 -2 2 6 2 2 6 2 2 6 38 38 38 86 86 86 50 50 50 22 22 22 6 6 6
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 -
50078 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50079 -0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0 0 0 0
50080 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 38 38 38 82 82 82
50081 -34 34 34 2 2 6 2 2 6 2 2 6 42 42 42 195 195 195 246 246 246 253 253 253
50082 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 242 242 242 250 250 250 253 253 253
50083 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 246 246 246 238 238 238
50084 -226 226 226 231 231 231 101 101 101 6 6 6 2 2 6 2 2 6 2 2 6 2 2 6
50085 -2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 82 82 82 42 42 42 14 14 14
50086 -6 6 6 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 -
50089 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50090 -0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0 0 0 0
50091 -0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 26 26 26 62 62 62 66 66 66
50092 -2 2 6 2 2 6 2 2 6 6 6 6 70 70 70 170 170 170 202 202 202 234 234 234
50093 -246 246 246 250 250 250 250 250 250 238 238 238 226 226 226 231 231 231 238 238 238 250 250 250
50094 -250 250 250 250 250 250 246 246 246 231 231 231 214 214 214 202 202 202 202 202 202 202 202 202
50095 -198 198 198 202 202 202 180 180 180 18 18 18 2 2 6 2 2 6 2 2 6 2 2 6
50096 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66 30 30 30
50097 -10 10 10 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 -
50100 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50101 -0 0 0 0 0 0 0 0 0 12 17 20 36 54 60 29 43 47 0 0 0 0 0 0
50102 -0 0 0 0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 82 82 82 18 18 18
50103 -2 2 6 2 2 6 2 2 6 10 10 10 94 94 94 180 180 180 218 218 218 242 242 242
50104 -250 250 250 253 253 253 253 253 253 250 250 250 234 234 234 253 253 253 253 253 253 253 253 253
50105 -253 253 253 253 253 253 253 253 253 246 246 246 238 238 238 226 226 226 210 210 210 202 202 202
50106 -195 195 195 195 195 195 210 210 210 151 151 151 6 6 6 14 14 14 50 50 50 14 14 14
50107 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 86 86 86 46 46 46
50108 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50109 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50110 -
50111 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50112 -0 0 0 0 0 0 0 0 0 0 0 0 21 30 33 35 52 58 6 8 12 0 0 0
50113 -0 0 0 0 0 0 0 0 0 6 6 6 22 22 22 54 54 54 70 70 70 2 2 6
50114 -2 2 6 10 10 10 2 2 6 22 22 22 170 170 170 231 231 231 250 250 250 253 253 253
50115 -253 253 253 253 253 253 253 253 253 250 250 250 242 242 242 253 253 253 253 253 253 253 253 253
50116 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246
50117 -231 231 231 202 202 202 198 198 198 226 226 226 94 94 94 2 2 6 6 6 6 38 38 38
50118 -30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 62 62 66 66 66
50119 -26 26 26 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50120 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50121 -
50122 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50123 -0 0 0 0 0 0 0 0 0 0 0 0 6 8 8 33 49 54 29 43 47 6 8 12
50124 -0 0 0 0 0 0 0 0 0 10 10 10 30 30 30 74 74 74 50 50 50 2 2 6
50125 -26 26 26 26 26 26 2 2 6 106 106 106 238 238 238 253 253 253 253 253 253 253 253 253
50126 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50127 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50128 -253 253 253 246 246 246 218 218 218 202 202 202 210 210 210 14 14 14 2 2 6 2 2 6
50129 -30 30 30 22 22 22 2 2 6 2 2 6 2 2 6 2 2 6 18 18 18 86 86 86
50130 -42 42 42 14 14 14 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 0 0 0
50132 -
50133 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50134 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 17 20 33 49 54 17 23 26
50135 -0 0 0 0 0 0 0 0 0 14 14 14 42 42 42 90 90 90 22 22 22 2 2 6
50136 -42 42 42 2 2 6 18 18 18 218 218 218 253 253 253 253 253 253 253 253 253 253 253 253
50137 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50138 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50139 -253 253 253 253 253 253 250 250 250 221 221 221 218 218 218 101 101 101 2 2 6 14 14 14
50140 -18 18 18 38 38 38 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 78 78 78
50141 -58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50142 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50143 -
50144 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50145 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 22 25 36 54 60
50146 -0 0 0 0 0 0 0 0 0 18 18 18 54 54 54 82 82 82 2 2 6 26 26 26
50147 -22 22 22 2 2 6 124 127 131 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50148 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50149 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50150 -253 253 253 253 253 253 253 253 253 250 250 250 238 238 238 198 198 198 6 6 6 38 38 38
50151 -58 58 58 26 26 26 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6 46 46 46
50152 -78 78 78 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50153 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50154 -
50155 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50156 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21 30 33
50157 -36 54 60 0 0 0 0 0 0 30 30 30 74 74 74 58 58 58 2 2 6 42 42 42
50158 -2 2 6 22 22 22 231 231 231 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50159 -253 253 253 253 253 253 253 253 253 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50160 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50161 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 246 246 246 46 46 46 38 38 38
50162 -42 42 42 14 14 14 38 38 38 14 14 14 2 2 6 2 2 6 2 2 6 6 6 6
50163 -86 86 86 46 46 46 14 14 14 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 0 0 0 0 0 0
50165 -
50166 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50167 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50168 -36 54 60 0 0 0 0 0 0 42 42 42 90 90 90 18 18 18 18 18 18 26 26 26
50169 -2 2 6 116 116 116 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50170 -253 253 253 253 253 253 250 250 250 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50171 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50172 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 94 94 94 6 6 6
50173 -2 2 6 2 2 6 10 10 10 34 34 34 2 2 6 2 2 6 2 2 6 2 2 6
50174 -74 74 74 58 58 58 22 22 22 6 6 6 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 0 0 0 0 0 0
50176 -
50177 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50178 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50179 -0 0 0 36 54 60 26 26 26 66 66 66 82 82 82 2 2 6 38 38 38 6 6 6
50180 -14 14 14 210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50181 -253 253 253 253 253 253 246 246 246 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50182 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50183 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 2 2 6
50184 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50185 -42 42 42 74 74 74 30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50186 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50187 -
50188 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50189 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50190 -6 6 6 36 54 60 21 30 33 90 90 90 26 26 26 6 6 6 42 42 42 2 2 6
50191 -74 74 74 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50192 -253 253 253 253 253 253 242 242 242 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50193 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50194 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 180 180 180 2 2 6
50195 -2 2 6 2 2 6 2 2 6 46 46 46 2 2 6 2 2 6 2 2 6 2 2 6
50196 -10 10 10 86 86 86 38 38 38 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0
50197 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50198 -
50199 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50200 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50201 -10 10 10 26 26 26 36 54 60 82 82 82 2 2 6 22 22 22 18 18 18 2 2 6
50202 -151 151 151 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50203 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50204 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50205 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50206 -2 2 6 2 2 6 2 2 6 38 38 38 2 2 6 2 2 6 2 2 6 2 2 6
50207 -6 6 6 86 86 86 46 46 46 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
50208 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50209 -
50210 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50211 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50212 -18 18 18 46 46 46 86 86 86 36 54 60 2 2 6 34 34 34 10 10 10 6 6 6
50213 -210 210 210 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50214 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50215 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50216 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 221 221 221 6 6 6
50217 -2 2 6 2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50218 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50219 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50220 -
50221 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50222 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50223 -26 26 26 66 66 66 62 62 62 2 2 6 2 2 6 38 38 38 10 10 10 26 26 26
50224 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50225 -253 253 253 253 253 253 231 231 231 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253
50226 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50227 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 231 231 231 6 6 6
50228 -2 2 6 2 2 6 10 10 10 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6
50229 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50230 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50231 -
50232 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50233 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50234 -38 38 38 78 78 78 6 6 6 2 2 6 2 2 6 46 46 46 14 14 14 42 42 42
50235 -246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50236 -253 253 253 253 253 253 231 231 231 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50237 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50238 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 10 10 10
50239 -2 2 6 2 2 6 22 22 22 14 14 14 2 2 6 2 2 6 2 2 6 2 2 6
50240 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50241 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50242 -
50243 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50244 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50245 -50 50 50 74 74 74 2 2 6 2 2 6 14 14 14 70 70 70 34 34 34 62 62 62
50246 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50247 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50248 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50249 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 234 234 234 14 14 14
50250 -2 2 6 2 2 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50251 -2 2 6 66 66 66 62 62 62 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50252 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50253 -
50254 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50255 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50256 -54 54 54 62 62 62 2 2 6 2 2 6 2 2 6 30 30 30 46 46 46 70 70 70
50257 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50258 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50259 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50260 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 226 226 226 10 10 10
50261 -2 2 6 6 6 6 30 30 30 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50262 -2 2 6 66 66 66 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0
50263 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50264 -
50265 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50266 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50267 -58 58 58 62 62 62 2 2 6 2 2 6 2 2 6 2 2 6 30 30 30 78 78 78
50268 -250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50269 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50270 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50271 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 202 202 202 2 2 6
50272 -22 22 22 34 34 34 20 16 6 22 22 22 26 26 26 18 18 18 6 6 6 2 2 6
50273 -2 2 6 82 82 82 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50274 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50275 -
50276 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50277 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 26 26 26
50278 -62 62 62 106 106 106 63 55 20 184 138 11 204 160 10 121 92 8 6 6 6 62 62 62
50279 -238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50280 -253 253 253 253 253 253 231 231 231 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253
50281 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50282 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 151 151 151 18 18 18
50283 -14 14 14 2 2 6 2 2 6 2 2 6 6 6 6 18 18 18 66 66 66 38 38 38
50284 -6 6 6 94 94 94 50 50 50 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50285 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50286 -
50287 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50288 -0 0 0 0 0 0 0 0 0 6 6 6 10 10 10 10 10 10 18 18 18 38 38 38
50289 -78 78 78 138 132 106 216 158 10 242 186 14 246 190 14 246 190 14 156 118 10 10 10 10
50290 -90 90 90 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50291 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50292 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50293 -253 253 253 253 253 253 253 253 253 246 230 190 214 187 87 214 187 87 185 146 40 35 31 12
50294 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 38 38 38 46 46 46
50295 -26 26 26 106 106 106 54 54 54 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0
50296 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50297 -
50298 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50299 -0 0 0 6 6 6 14 14 14 22 22 22 30 30 30 38 38 38 50 50 50 70 70 70
50300 -106 106 106 185 146 40 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 154 114 10
50301 -6 6 6 74 74 74 226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50302 -253 253 253 253 253 253 231 231 231 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253
50303 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50304 -253 253 253 253 253 253 253 253 253 237 201 50 241 196 14 241 208 19 232 195 16 35 31 12
50305 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 30 30 30 26 26 26
50306 -204 160 10 165 152 80 66 66 66 26 26 26 6 6 6 0 0 0 0 0 0 0 0 0
50307 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50308 -
50309 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50310 -6 6 6 18 18 18 38 38 38 58 58 58 78 78 78 86 86 86 101 101 101 124 127 131
50311 -174 140 55 210 150 10 234 174 13 246 186 14 246 190 14 246 190 14 246 190 14 237 188 10
50312 -98 70 6 2 2 6 46 46 46 198 198 198 253 253 253 253 253 253 253 253 253 253 253 253
50313 -253 253 253 253 253 253 234 234 234 242 242 242 253 253 253 253 253 253 253 253 253 253 253 253
50314 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50315 -253 253 253 253 253 253 253 253 253 214 187 87 242 186 14 241 196 14 204 160 10 20 16 6
50316 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 6 6 6 121 92 8
50317 -238 202 15 232 195 16 82 82 82 34 34 34 10 10 10 0 0 0 0 0 0 0 0 0
50318 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50319 -
50320 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50321 -14 14 14 38 38 38 70 70 70 148 132 55 185 146 40 200 144 11 197 138 11 197 138 11
50322 -213 154 11 226 170 11 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50323 -220 174 15 35 31 12 2 2 6 22 22 22 151 151 151 250 250 250 253 253 253 253 253 253
50324 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50325 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50326 -253 253 253 250 250 250 242 242 242 214 187 87 239 182 13 237 188 10 213 154 11 35 31 12
50327 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 62 42 6 220 174 15
50328 -237 188 10 237 188 10 113 101 86 42 42 42 14 14 14 0 0 0 0 0 0 0 0 0
50329 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50330 -
50331 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50332 -22 22 22 54 54 54 148 132 55 213 154 11 226 170 11 230 174 11 226 170 11 226 170 11
50333 -236 178 12 242 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50334 -241 196 14 184 138 11 10 10 10 2 2 6 6 6 6 116 116 116 242 242 242 253 253 253
50335 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50336 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50337 -253 253 253 231 231 231 198 198 198 213 164 39 236 178 12 236 178 12 210 150 10 137 92 6
50338 -20 16 6 2 2 6 2 2 6 2 2 6 6 6 6 62 42 6 200 144 11 236 178 12
50339 -239 182 13 239 182 13 124 112 88 58 58 58 22 22 22 6 6 6 0 0 0 0 0 0
50340 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50341 -
50342 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50343 -30 30 30 70 70 70 169 125 40 226 170 11 239 182 13 242 186 14 242 186 14 246 186 14
50344 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50345 -246 190 14 232 195 16 98 70 6 2 2 6 2 2 6 2 2 6 66 66 66 221 221 221
50346 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50347 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50348 -253 253 253 202 202 202 198 198 198 213 164 39 230 174 11 230 174 11 216 158 10 192 133 9
50349 -163 110 8 120 80 7 98 70 6 120 80 7 167 114 7 197 138 11 226 170 11 239 182 13
50350 -242 186 14 242 186 14 165 152 80 78 78 78 34 34 34 14 14 14 6 6 6 0 0 0
50351 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50352 -
50353 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50354 -30 30 30 78 78 78 185 146 40 226 170 11 239 182 13 246 190 14 246 190 14 246 190 14
50355 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50356 -246 190 14 241 196 14 204 160 10 20 16 6 2 2 6 2 2 6 2 2 6 38 38 38
50357 -218 218 218 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50358 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50359 -250 250 250 202 202 202 198 198 198 213 164 39 226 170 11 236 178 12 224 166 10 210 150 10
50360 -200 144 11 197 138 11 192 133 9 197 138 11 210 150 10 226 170 11 242 186 14 246 190 14
50361 -246 190 14 246 186 14 220 174 15 124 112 88 62 62 62 30 30 30 14 14 14 6 6 6
50362 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50363 -
50364 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50365 -30 30 30 78 78 78 174 140 55 224 166 10 239 182 13 246 190 14 246 190 14 246 190 14
50366 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50367 -246 190 14 246 190 14 241 196 14 139 102 15 2 2 6 2 2 6 2 2 6 2 2 6
50368 -78 78 78 250 250 250 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50369 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50370 -250 250 250 214 214 214 198 198 198 185 146 40 219 162 10 236 178 12 234 174 13 224 166 10
50371 -216 158 10 213 154 11 213 154 11 216 158 10 226 170 11 239 182 13 246 190 14 246 190 14
50372 -246 190 14 246 190 14 242 186 14 213 164 39 101 101 101 58 58 58 30 30 30 14 14 14
50373 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50374 -
50375 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50376 -30 30 30 74 74 74 174 140 55 216 158 10 236 178 12 246 190 14 246 190 14 246 190 14
50377 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50378 -246 190 14 246 190 14 241 196 14 230 187 11 62 42 6 2 2 6 2 2 6 2 2 6
50379 -22 22 22 238 238 238 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50380 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50381 -253 253 253 226 226 226 187 187 187 169 125 40 216 158 10 236 178 12 239 182 13 236 178 12
50382 -230 174 11 226 170 11 226 170 11 230 174 11 236 178 12 242 186 14 246 190 14 246 190 14
50383 -246 190 14 246 190 14 246 186 14 239 182 13 213 164 39 106 106 106 66 66 66 34 34 34
50384 -14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50385 -
50386 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50387 -26 26 26 70 70 70 149 139 69 213 154 11 236 178 12 246 190 14 246 190 14 246 190 14
50388 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50389 -246 190 14 246 190 14 246 190 14 241 196 14 190 146 13 20 16 6 2 2 6 2 2 6
50390 -46 46 46 246 246 246 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50391 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50392 -253 253 253 221 221 221 86 86 86 156 107 11 216 158 10 236 178 12 242 186 14 246 186 14
50393 -242 186 14 239 182 13 239 182 13 242 186 14 242 186 14 246 186 14 246 190 14 246 190 14
50394 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 220 174 15 149 139 69 66 66 66
50395 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50396 -
50397 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50398 -26 26 26 70 70 70 149 139 69 210 150 10 236 178 12 246 190 14 246 190 14 246 190 14
50399 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50400 -246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 121 92 8 34 34 34 106 106 106
50401 -221 221 221 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50402 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50403 -242 242 242 82 82 82 20 16 6 163 110 8 216 158 10 236 178 12 242 186 14 246 190 14
50404 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50405 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 149 139 69
50406 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50407 -
50408 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10
50409 -30 30 30 78 78 78 149 139 69 210 150 10 236 178 12 246 186 14 246 190 14 246 190 14
50410 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50411 -246 190 14 246 190 14 246 190 14 246 190 14 241 196 14 220 174 15 198 179 130 253 253 253
50412 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50413 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 218 218 218
50414 -58 58 58 2 2 6 20 16 6 167 114 7 216 158 10 236 178 12 246 186 14 246 190 14
50415 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50416 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 242 186 14 185 146 40
50417 -54 54 54 22 22 22 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50418 -
50419 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50420 -38 38 38 86 86 86 169 125 40 213 154 11 236 178 12 246 186 14 246 190 14 246 190 14
50421 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50422 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 232 195 16 190 146 13 214 214 214
50423 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50424 -253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 250 250 250 170 170 170 26 26 26
50425 -2 2 6 2 2 6 35 31 12 163 110 8 219 162 10 239 182 13 246 186 14 246 190 14
50426 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50427 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 224 166 10 149 139 69
50428 -46 46 46 18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50429 -
50430 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50431 -50 50 50 113 101 86 192 133 9 224 166 10 242 186 14 246 190 14 246 190 14 246 190 14
50432 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50433 -246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 230 187 11 204 160 10 133 118 54
50434 -226 226 226 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253 253
50435 -253 253 253 253 253 253 253 253 253 253 253 253 198 198 198 66 66 66 2 2 6 2 2 6
50436 -2 2 6 2 2 6 62 42 6 156 107 11 219 162 10 239 182 13 246 186 14 246 190 14
50437 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50438 -246 190 14 246 190 14 246 190 14 242 186 14 234 174 13 213 154 11 148 132 55 66 66 66
50439 -30 30 30 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50440 -
50441 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50442 -58 58 58 148 132 55 206 145 10 234 174 13 242 186 14 246 186 14 246 190 14 246 190 14
50443 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50444 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 236 178 12 204 160 10 163 110 8
50445 -62 42 6 124 131 137 218 218 218 250 250 250 253 253 253 253 253 253 253 253 253 250 250 250
50446 -242 242 242 210 210 210 151 151 151 66 66 66 6 6 6 2 2 6 2 2 6 2 2 6
50447 -2 2 6 2 2 6 62 42 6 163 110 8 216 158 10 236 178 12 246 190 14 246 190 14
50448 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50449 -246 190 14 239 182 13 230 174 11 216 158 10 185 146 40 124 112 88 70 70 70 38 38 38
50450 -18 18 18 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50451 -
50452 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 22 22 22
50453 -62 62 62 169 125 40 206 145 10 224 166 10 236 178 12 239 182 13 242 186 14 242 186 14
50454 -246 186 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 246 190 14
50455 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 236 178 12 216 158 10 171 120 8
50456 -85 57 6 2 2 6 6 6 6 30 30 30 54 54 54 62 62 62 50 50 50 38 38 38
50457 -14 14 14 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50458 -2 2 6 6 6 6 85 57 6 167 114 7 213 154 11 236 178 12 246 190 14 246 190 14
50459 -246 190 14 246 190 14 246 190 14 246 190 14 246 190 14 242 186 14 239 182 13 239 182 13
50460 -230 174 11 210 150 10 174 140 55 124 112 88 82 82 82 54 54 54 34 34 34 18 18 18
50461 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50462 -
50463 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 18 18 18
50464 -50 50 50 169 125 40 192 133 9 200 144 11 216 158 10 219 162 10 224 166 10 226 170 11
50465 -230 174 11 236 178 12 239 182 13 239 182 13 242 186 14 246 186 14 246 190 14 246 190 14
50466 -246 190 14 246 190 14 246 190 14 246 190 14 246 186 14 230 174 11 210 150 10 163 110 8
50467 -104 69 6 10 10 10 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50468 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50469 -2 2 6 6 6 6 85 57 6 167 114 7 206 145 10 230 174 11 242 186 14 246 190 14
50470 -246 190 14 246 190 14 246 186 14 242 186 14 239 182 13 230 174 11 224 166 10 213 154 11
50471 -169 125 40 124 112 88 86 86 86 58 58 58 38 38 38 22 22 22 10 10 10 6 6 6
50472 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50473 -
50474 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 14 14 14
50475 -34 34 34 70 70 70 133 118 54 169 125 40 167 114 7 180 123 7 192 133 9 197 138 11
50476 -200 144 11 206 145 10 213 154 11 219 162 10 224 166 10 230 174 11 239 182 13 242 186 14
50477 -246 186 14 246 186 14 246 186 14 246 186 14 239 182 13 216 158 10 184 138 11 152 99 6
50478 -104 69 6 20 16 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50479 -2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6 2 2 6
50480 -2 2 6 6 6 6 85 57 6 152 99 6 192 133 9 219 162 10 236 178 12 239 182 13
50481 -246 186 14 242 186 14 239 182 13 236 178 12 224 166 10 206 145 10 192 133 9 148 132 55
50482 -94 94 94 62 62 62 42 42 42 22 22 22 14 14 14 6 6 6 0 0 0 0 0 0
50483 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50484 -
50485 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50486 -18 18 18 34 34 34 58 58 58 78 78 78 101 98 89 124 112 88 133 118 54 156 107 11
50487 -163 110 8 167 114 7 171 120 8 180 123 7 184 138 11 197 138 11 210 150 10 219 162 10
50488 -226 170 11 236 178 12 236 178 12 234 174 13 219 162 10 197 138 11 163 110 8 134 84 6
50489 -85 57 6 10 10 10 2 2 6 2 2 6 18 18 18 38 38 38 38 38 38 38 38 38
50490 -38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 26 26 26 2 2 6
50491 -2 2 6 6 6 6 62 42 6 137 92 6 171 120 8 200 144 11 219 162 10 230 174 11
50492 -234 174 13 230 174 11 219 162 10 210 150 10 192 133 9 163 110 8 124 112 88 82 82 82
50493 -50 50 50 30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50494 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50495 -
50496 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50497 -6 6 6 14 14 14 22 22 22 34 34 34 42 42 42 58 58 58 74 74 74 86 86 86
50498 -101 98 89 113 101 86 133 118 54 121 92 8 137 92 6 152 99 6 163 110 8 180 123 7
50499 -184 138 11 197 138 11 206 145 10 200 144 11 180 123 7 156 107 11 134 84 6 104 69 6
50500 -62 42 6 54 54 54 106 106 106 101 98 89 86 86 86 82 82 82 78 78 78 78 78 78
50501 -78 78 78 78 78 78 78 78 78 78 78 78 78 78 78 82 82 82 86 86 86 94 94 94
50502 -106 106 106 101 101 101 90 61 47 120 80 7 156 107 11 180 123 7 192 133 9 200 144 11
50503 -206 145 10 200 144 11 192 133 9 171 120 8 139 102 15 113 101 86 70 70 70 42 42 42
50504 -22 22 22 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50505 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50506 -
50507 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50508 -0 0 0 0 0 0 6 6 6 10 10 10 14 14 14 22 22 22 30 30 30 38 38 38
50509 -50 50 50 62 62 62 74 74 74 90 90 90 101 98 89 113 101 86 121 92 8 120 80 7
50510 -137 92 6 152 99 6 152 99 6 152 99 6 134 84 6 120 80 7 98 70 6 88 55 22
50511 -101 98 89 82 82 82 58 58 58 46 46 46 38 38 38 34 34 34 34 34 34 34 34 34
50512 -34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 38 38 38 42 42 42
50513 -54 54 54 82 82 82 94 86 71 85 57 6 134 84 6 156 107 11 167 114 7 171 120 8
50514 -171 120 8 167 114 7 152 99 6 121 92 8 101 98 89 62 62 62 34 34 34 18 18 18
50515 -6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50516 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50517 -
50518 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50519 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 10 10 10
50520 -18 18 18 22 22 22 30 30 30 42 42 42 50 50 50 66 66 66 86 86 86 101 98 89
50521 -94 86 71 98 70 6 104 69 6 104 69 6 104 69 6 85 57 6 88 55 22 90 90 90
50522 -62 62 62 38 38 38 22 22 22 14 14 14 10 10 10 10 10 10 10 10 10 10 10 10
50523 -10 10 10 10 10 10 6 6 6 10 10 10 10 10 10 10 10 10 10 10 10 14 14 14
50524 -22 22 22 42 42 42 70 70 70 94 86 71 85 57 6 104 69 6 120 80 7 137 92 6
50525 -134 84 6 120 80 7 94 86 71 86 86 86 58 58 58 30 30 30 14 14 14 6 6 6
50526 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50527 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50528 -
50529 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50530 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50531 -0 0 0 6 6 6 10 10 10 14 14 14 18 18 18 26 26 26 38 38 38 54 54 54
50532 -70 70 70 86 86 86 94 86 71 94 86 71 94 86 71 86 86 86 74 74 74 50 50 50
50533 -30 30 30 14 14 14 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50534 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50535 -6 6 6 18 18 18 34 34 34 58 58 58 82 82 82 94 86 71 94 86 71 94 86 71
50536 -94 86 71 94 86 71 74 74 74 50 50 50 26 26 26 14 14 14 6 6 6 0 0 0
50537 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50538 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50539 -
50540 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50541 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50542 -0 0 0 0 0 0 0 0 0 0 0 0 6 6 6 6 6 6 14 14 14 18 18 18
50543 -30 30 30 38 38 38 46 46 46 54 54 54 50 50 50 42 42 42 30 30 30 18 18 18
50544 -10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50545 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50546 -0 0 0 6 6 6 14 14 14 26 26 26 38 38 38 50 50 50 58 58 58 58 58 58
50547 -54 54 54 42 42 42 30 30 30 18 18 18 10 10 10 0 0 0 0 0 0 0 0 0
50548 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50549 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50550 -
50551 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50552 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50553 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 6 6
50554 -6 6 6 10 10 10 14 14 14 18 18 18 18 18 18 14 14 14 10 10 10 6 6 6
50555 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50556 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50557 -0 0 0 0 0 0 0 0 0 6 6 6 14 14 14 18 18 18 22 22 22 22 22 22
50558 -18 18 18 14 14 14 10 10 10 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
50559 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50560 -0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50561 -
50562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50565 +4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
50568 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50569 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50571 +4 4 4 4 4 4 4 4 4 4 4 4 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
50576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50579 +4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4
50582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50583 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50585 +4 4 4 4 4 4 4 4 4 4 4 4 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
50590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4
50595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50597 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50599 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4
50604 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50613 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4
50617 +4 4 4 4 4 4
50618 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50627 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4
50631 +4 4 4 4 4 4
50632 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50641 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4
50645 +4 4 4 4 4 4
50646 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50650 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
50651 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
50652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50655 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
50656 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50657 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
50658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50659 +4 4 4 4 4 4
50660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50664 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
50665 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
50666 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50669 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
50670 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
50671 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
50672 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50673 +4 4 4 4 4 4
50674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50678 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
50679 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
50680 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50683 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
50684 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
50685 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
50686 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
50687 +4 4 4 4 4 4
50688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50691 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
50692 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
50693 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
50694 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
50695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50696 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50697 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
50698 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
50699 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
50700 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
50701 +4 4 4 4 4 4
50702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50705 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
50706 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
50707 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
50708 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
50709 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
50710 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
50711 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
50712 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
50713 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
50714 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
50715 +4 4 4 4 4 4
50716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
50719 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
50720 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
50721 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
50722 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
50723 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
50724 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
50725 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
50726 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
50727 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
50728 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
50729 +4 4 4 4 4 4
50730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50732 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
50733 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
50734 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
50735 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
50736 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
50737 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
50738 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
50739 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
50740 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
50741 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
50742 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
50743 +4 4 4 4 4 4
50744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50746 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
50747 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
50748 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
50749 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
50750 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
50751 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
50752 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
50753 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
50754 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
50755 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
50756 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
50757 +4 4 4 4 4 4
50758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50760 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
50761 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
50762 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
50763 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
50764 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
50765 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
50766 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
50767 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
50768 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
50769 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
50770 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
50771 +4 4 4 4 4 4
50772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50774 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
50775 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
50776 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
50777 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
50778 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
50779 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
50780 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
50781 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
50782 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
50783 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
50784 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
50785 +4 4 4 4 4 4
50786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50787 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
50788 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
50789 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
50790 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
50791 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
50792 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
50793 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
50794 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
50795 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
50796 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
50797 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
50798 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
50799 +4 4 4 4 4 4
50800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50801 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
50802 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
50803 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
50804 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
50805 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
50806 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
50807 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
50808 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
50809 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
50810 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
50811 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
50812 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
50813 +0 0 0 4 4 4
50814 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
50815 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
50816 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
50817 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
50818 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
50819 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
50820 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
50821 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
50822 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
50823 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
50824 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
50825 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
50826 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
50827 +2 0 0 0 0 0
50828 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
50829 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
50830 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
50831 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
50832 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
50833 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
50834 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
50835 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
50836 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
50837 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
50838 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
50839 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
50840 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
50841 +37 38 37 0 0 0
50842 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50843 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
50844 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
50845 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
50846 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
50847 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
50848 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
50849 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
50850 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
50851 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
50852 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
50853 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
50854 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
50855 +85 115 134 4 0 0
50856 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
50857 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
50858 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
50859 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
50860 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
50861 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
50862 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
50863 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
50864 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
50865 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
50866 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
50867 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
50868 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
50869 +60 73 81 4 0 0
50870 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
50871 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
50872 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
50873 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
50874 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
50875 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
50876 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
50877 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
50878 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
50879 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
50880 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
50881 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
50882 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
50883 +16 19 21 4 0 0
50884 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
50885 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
50886 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
50887 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
50888 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
50889 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
50890 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
50891 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
50892 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
50893 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
50894 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
50895 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
50896 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
50897 +4 0 0 4 3 3
50898 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
50899 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
50900 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
50901 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
50902 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
50903 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
50904 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
50905 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
50906 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
50907 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
50908 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
50909 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
50910 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
50911 +3 2 2 4 4 4
50912 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
50913 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
50914 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
50915 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
50916 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
50917 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
50918 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
50919 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
50920 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
50921 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
50922 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
50923 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
50924 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
50925 +4 4 4 4 4 4
50926 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
50927 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
50928 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
50929 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
50930 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
50931 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
50932 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
50933 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
50934 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
50935 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
50936 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
50937 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
50938 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
50939 +4 4 4 4 4 4
50940 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
50941 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
50942 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
50943 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
50944 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
50945 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
50946 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
50947 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
50948 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
50949 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
50950 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
50951 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
50952 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
50953 +5 5 5 5 5 5
50954 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
50955 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
50956 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
50957 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
50958 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
50959 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50960 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
50961 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
50962 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
50963 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
50964 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
50965 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
50966 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
50967 +5 5 5 4 4 4
50968 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
50969 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
50970 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
50971 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
50972 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
50973 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
50974 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
50975 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
50976 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
50977 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
50978 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
50979 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
50980 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50981 +4 4 4 4 4 4
50982 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
50983 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
50984 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
50985 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
50986 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
50987 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50988 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
50989 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
50990 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
50991 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
50992 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
50993 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
50994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
50995 +4 4 4 4 4 4
50996 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
50997 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
50998 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
50999 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
51000 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51001 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
51002 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
51003 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
51004 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
51005 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
51006 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
51007 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51008 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51009 +4 4 4 4 4 4
51010 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
51011 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
51012 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
51013 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
51014 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51015 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51016 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
51017 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
51018 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
51019 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
51020 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
51021 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51022 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51023 +4 4 4 4 4 4
51024 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
51025 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
51026 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
51027 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
51028 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51029 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
51030 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
51031 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
51032 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
51033 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
51034 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51035 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51036 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51037 +4 4 4 4 4 4
51038 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
51039 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
51040 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
51041 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
51042 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
51043 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
51044 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
51045 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
51046 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
51047 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
51048 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
51049 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51050 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51051 +4 4 4 4 4 4
51052 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
51053 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
51054 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
51055 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
51056 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
51057 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
51058 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
51059 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
51060 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
51061 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
51062 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
51063 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51064 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51065 +4 4 4 4 4 4
51066 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
51067 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
51068 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
51069 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51070 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
51071 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
51072 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
51073 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
51074 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
51075 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
51076 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51077 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51078 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51079 +4 4 4 4 4 4
51080 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
51081 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
51082 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
51083 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51084 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51085 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
51086 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
51087 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
51088 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
51089 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
51090 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51091 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51092 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51093 +4 4 4 4 4 4
51094 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
51095 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
51096 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51097 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
51098 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51099 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
51100 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
51101 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
51102 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
51103 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
51104 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51105 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51106 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51107 +4 4 4 4 4 4
51108 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
51109 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
51110 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51111 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
51112 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51113 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
51114 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
51115 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
51116 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51117 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51118 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51119 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51120 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51121 +4 4 4 4 4 4
51122 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51123 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
51124 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
51125 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
51126 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
51127 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
51128 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
51129 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
51130 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51131 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51132 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51133 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51134 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51135 +4 4 4 4 4 4
51136 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
51137 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
51138 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
51139 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
51140 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51141 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
51142 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
51143 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
51144 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51145 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51146 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51147 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51148 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51149 +4 4 4 4 4 4
51150 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
51151 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
51152 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51153 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
51154 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
51155 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
51156 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
51157 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
51158 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51159 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51160 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51161 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51162 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51163 +4 4 4 4 4 4
51164 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
51165 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
51166 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51167 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
51168 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
51169 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
51170 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
51171 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
51172 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
51173 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51174 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51175 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51176 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51177 +4 4 4 4 4 4
51178 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51179 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
51180 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
51181 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
51182 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
51183 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
51184 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
51185 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
51186 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51187 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51188 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51189 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51190 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51191 +4 4 4 4 4 4
51192 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
51193 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
51194 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51195 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
51196 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
51197 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
51198 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
51199 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
51200 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
51201 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51202 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51203 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51204 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51205 +4 4 4 4 4 4
51206 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
51207 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
51208 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
51209 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
51210 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
51211 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
51212 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
51213 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
51214 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51215 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51216 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51217 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51218 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51219 +4 4 4 4 4 4
51220 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51221 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
51222 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
51223 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
51224 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
51225 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
51226 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
51227 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
51228 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51229 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51230 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51231 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51232 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51233 +4 4 4 4 4 4
51234 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51235 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
51236 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
51237 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
51238 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
51239 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
51240 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51241 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
51242 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
51243 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51244 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51245 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51246 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51247 +4 4 4 4 4 4
51248 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51249 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
51250 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
51251 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51252 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
51253 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
51254 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
51255 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
51256 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
51257 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51258 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51259 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51260 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51261 +4 4 4 4 4 4
51262 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
51263 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
51264 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
51265 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
51266 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
51267 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
51268 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
51269 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
51270 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
51271 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51272 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51273 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51274 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51275 +4 4 4 4 4 4
51276 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51277 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
51278 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
51279 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
51280 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
51281 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
51282 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
51283 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
51284 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
51285 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51286 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51287 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51288 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51289 +4 4 4 4 4 4
51290 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
51291 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
51292 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
51293 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
51294 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
51295 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
51296 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
51297 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
51298 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
51299 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51300 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51301 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51302 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51303 +4 4 4 4 4 4
51304 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
51305 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
51306 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
51307 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
51308 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
51309 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
51310 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
51311 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
51312 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
51313 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
51314 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51316 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51317 +4 4 4 4 4 4
51318 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
51319 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
51320 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
51321 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
51322 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
51323 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
51324 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
51325 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
51326 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
51327 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
51328 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51329 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51330 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51331 +4 4 4 4 4 4
51332 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
51333 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51334 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
51335 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
51336 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
51337 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
51338 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
51339 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
51340 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
51341 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
51342 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51343 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51344 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51345 +4 4 4 4 4 4
51346 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
51347 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
51348 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
51349 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
51350 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
51351 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
51352 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51353 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
51354 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
51355 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
51356 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51357 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51358 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51359 +4 4 4 4 4 4
51360 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
51361 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
51362 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
51363 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
51364 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
51365 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
51366 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
51367 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
51368 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
51369 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
51370 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51371 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51372 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51373 +4 4 4 4 4 4
51374 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
51375 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
51376 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51377 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
51378 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
51379 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
51380 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
51381 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
51382 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
51383 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
51384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51385 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51386 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51387 +4 4 4 4 4 4
51388 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51389 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
51390 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
51391 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
51392 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
51393 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
51394 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
51395 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
51396 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
51397 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
51398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51399 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51400 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51401 +4 4 4 4 4 4
51402 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
51403 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
51404 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
51405 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
51406 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
51407 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
51408 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
51409 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
51410 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
51411 +4 0 0 4 0 0 5 5 5 5 5 5 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51414 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51415 +4 4 4 4 4 4
51416 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
51417 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
51418 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
51419 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
51420 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
51421 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
51422 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
51423 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
51424 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51425 +4 3 3 5 5 5 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4
51428 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51429 +4 4 4 4 4 4
51430 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
51431 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51432 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
51433 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
51434 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
51435 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
51436 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
51437 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
51438 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
51439 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51443 +4 4 4 4 4 4
51444 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
51445 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
51446 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
51447 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
51448 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
51449 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
51450 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
51451 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
51452 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
51453 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4
51457 +4 4 4 4 4 4
51458 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51459 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
51460 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
51461 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
51462 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
51463 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
51464 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
51465 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
51466 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51467 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4
51472 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
51473 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
51474 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51475 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
51476 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
51477 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
51478 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
51479 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
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 4 4 4 4 4 4 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
51486 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51487 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
51488 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
51489 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
51490 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
51491 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
51492 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
51493 +6 6 6 4 0 0 4 0 0 4 3 3 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 4 4 4 4 4 4 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
51500 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51501 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
51502 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51503 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
51504 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
51505 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
51506 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
51507 +4 0 0 4 3 3 6 6 6 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 4 4 4 4 4 4 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
51514 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51515 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
51516 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
51517 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
51518 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
51519 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
51520 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
51521 +6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4 4 4 4 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
51528 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51529 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
51530 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
51531 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51532 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
51533 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
51534 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
51535 +5 5 5 5 5 5 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 4 4 4 4 4 4 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
51542 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51544 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51545 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
51546 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
51547 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
51548 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
51549 +4 3 3 5 5 5 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 4 4 4 4 4 4 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
51556 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51559 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51560 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
51561 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
51562 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
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 4 4 4 4 4 4 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
51570 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51573 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
51574 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
51575 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
51576 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
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 4 4 4 4 4 4 4 4 4 4 4 4
51580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51582 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51583 +4 4 4 4 4 4
51584 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51587 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
51588 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
51589 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
51590 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
51591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51596 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51597 +4 4 4 4 4 4
51598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51601 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
51602 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
51603 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
51604 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
51605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51610 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51611 +4 4 4 4 4 4
51612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51616 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
51617 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
51618 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
51619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51624 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51625 +4 4 4 4 4 4
51626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51630 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
51631 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
51632 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51638 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51639 +4 4 4 4 4 4
51640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51644 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
51645 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
51646 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51652 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51653 +4 4 4 4 4 4
51654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51658 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
51659 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
51660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51667 +4 4 4 4 4 4
51668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51672 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
51673 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
51674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51681 +4 4 4 4 4 4
51682 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
51683 index fe92eed..106e085 100644
51684 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
51685 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
51686 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
51687 struct mb862xxfb_par *par = info->par;
51688
51689 if (info->var.bits_per_pixel == 32) {
51690 - info->fbops->fb_fillrect = cfb_fillrect;
51691 - info->fbops->fb_copyarea = cfb_copyarea;
51692 - info->fbops->fb_imageblit = cfb_imageblit;
51693 + pax_open_kernel();
51694 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51695 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51696 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51697 + pax_close_kernel();
51698 } else {
51699 outreg(disp, GC_L0EM, 3);
51700 - info->fbops->fb_fillrect = mb86290fb_fillrect;
51701 - info->fbops->fb_copyarea = mb86290fb_copyarea;
51702 - info->fbops->fb_imageblit = mb86290fb_imageblit;
51703 + pax_open_kernel();
51704 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
51705 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
51706 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
51707 + pax_close_kernel();
51708 }
51709 outreg(draw, GDC_REG_DRAW_BASE, 0);
51710 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
51711 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
51712 index ff22871..b129bed 100644
51713 --- a/drivers/video/nvidia/nvidia.c
51714 +++ b/drivers/video/nvidia/nvidia.c
51715 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
51716 info->fix.line_length = (info->var.xres_virtual *
51717 info->var.bits_per_pixel) >> 3;
51718 if (info->var.accel_flags) {
51719 - info->fbops->fb_imageblit = nvidiafb_imageblit;
51720 - info->fbops->fb_fillrect = nvidiafb_fillrect;
51721 - info->fbops->fb_copyarea = nvidiafb_copyarea;
51722 - info->fbops->fb_sync = nvidiafb_sync;
51723 + pax_open_kernel();
51724 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
51725 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
51726 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
51727 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
51728 + pax_close_kernel();
51729 info->pixmap.scan_align = 4;
51730 info->flags &= ~FBINFO_HWACCEL_DISABLED;
51731 info->flags |= FBINFO_READS_FAST;
51732 NVResetGraphics(info);
51733 } else {
51734 - info->fbops->fb_imageblit = cfb_imageblit;
51735 - info->fbops->fb_fillrect = cfb_fillrect;
51736 - info->fbops->fb_copyarea = cfb_copyarea;
51737 - info->fbops->fb_sync = NULL;
51738 + pax_open_kernel();
51739 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
51740 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
51741 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
51742 + *(void **)&info->fbops->fb_sync = NULL;
51743 + pax_close_kernel();
51744 info->pixmap.scan_align = 1;
51745 info->flags |= FBINFO_HWACCEL_DISABLED;
51746 info->flags &= ~FBINFO_READS_FAST;
51747 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
51748 info->pixmap.size = 8 * 1024;
51749 info->pixmap.flags = FB_PIXMAP_SYSTEM;
51750
51751 - if (!hwcur)
51752 - info->fbops->fb_cursor = NULL;
51753 + if (!hwcur) {
51754 + pax_open_kernel();
51755 + *(void **)&info->fbops->fb_cursor = NULL;
51756 + pax_close_kernel();
51757 + }
51758
51759 info->var.accel_flags = (!noaccel);
51760
51761 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
51762 index 05c2dc3..ea1f391 100644
51763 --- a/drivers/video/s1d13xxxfb.c
51764 +++ b/drivers/video/s1d13xxxfb.c
51765 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
51766
51767 switch(prod_id) {
51768 case S1D13506_PROD_ID: /* activate acceleration */
51769 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51770 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51771 + pax_open_kernel();
51772 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
51773 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
51774 + pax_close_kernel();
51775 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
51776 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
51777 break;
51778 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
51779 index e188ada..aac63c8 100644
51780 --- a/drivers/video/smscufx.c
51781 +++ b/drivers/video/smscufx.c
51782 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
51783 fb_deferred_io_cleanup(info);
51784 kfree(info->fbdefio);
51785 info->fbdefio = NULL;
51786 - info->fbops->fb_mmap = ufx_ops_mmap;
51787 + pax_open_kernel();
51788 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
51789 + pax_close_kernel();
51790 }
51791
51792 pr_debug("released /dev/fb%d user=%d count=%d",
51793 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
51794 index d2e5bc3..4cb05d1 100644
51795 --- a/drivers/video/udlfb.c
51796 +++ b/drivers/video/udlfb.c
51797 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
51798 dlfb_urb_completion(urb);
51799
51800 error:
51801 - atomic_add(bytes_sent, &dev->bytes_sent);
51802 - atomic_add(bytes_identical, &dev->bytes_identical);
51803 - atomic_add(width*height*2, &dev->bytes_rendered);
51804 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51805 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51806 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
51807 end_cycles = get_cycles();
51808 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51809 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51810 >> 10)), /* Kcycles */
51811 &dev->cpu_kcycles_used);
51812
51813 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
51814 dlfb_urb_completion(urb);
51815
51816 error:
51817 - atomic_add(bytes_sent, &dev->bytes_sent);
51818 - atomic_add(bytes_identical, &dev->bytes_identical);
51819 - atomic_add(bytes_rendered, &dev->bytes_rendered);
51820 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
51821 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
51822 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
51823 end_cycles = get_cycles();
51824 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
51825 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
51826 >> 10)), /* Kcycles */
51827 &dev->cpu_kcycles_used);
51828 }
51829 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
51830 fb_deferred_io_cleanup(info);
51831 kfree(info->fbdefio);
51832 info->fbdefio = NULL;
51833 - info->fbops->fb_mmap = dlfb_ops_mmap;
51834 + pax_open_kernel();
51835 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
51836 + pax_close_kernel();
51837 }
51838
51839 pr_warn("released /dev/fb%d user=%d count=%d\n",
51840 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
51841 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51842 struct dlfb_data *dev = fb_info->par;
51843 return snprintf(buf, PAGE_SIZE, "%u\n",
51844 - atomic_read(&dev->bytes_rendered));
51845 + atomic_read_unchecked(&dev->bytes_rendered));
51846 }
51847
51848 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51849 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
51850 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51851 struct dlfb_data *dev = fb_info->par;
51852 return snprintf(buf, PAGE_SIZE, "%u\n",
51853 - atomic_read(&dev->bytes_identical));
51854 + atomic_read_unchecked(&dev->bytes_identical));
51855 }
51856
51857 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51858 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
51859 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51860 struct dlfb_data *dev = fb_info->par;
51861 return snprintf(buf, PAGE_SIZE, "%u\n",
51862 - atomic_read(&dev->bytes_sent));
51863 + atomic_read_unchecked(&dev->bytes_sent));
51864 }
51865
51866 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51867 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
51868 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51869 struct dlfb_data *dev = fb_info->par;
51870 return snprintf(buf, PAGE_SIZE, "%u\n",
51871 - atomic_read(&dev->cpu_kcycles_used));
51872 + atomic_read_unchecked(&dev->cpu_kcycles_used));
51873 }
51874
51875 static ssize_t edid_show(
51876 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
51877 struct fb_info *fb_info = dev_get_drvdata(fbdev);
51878 struct dlfb_data *dev = fb_info->par;
51879
51880 - atomic_set(&dev->bytes_rendered, 0);
51881 - atomic_set(&dev->bytes_identical, 0);
51882 - atomic_set(&dev->bytes_sent, 0);
51883 - atomic_set(&dev->cpu_kcycles_used, 0);
51884 + atomic_set_unchecked(&dev->bytes_rendered, 0);
51885 + atomic_set_unchecked(&dev->bytes_identical, 0);
51886 + atomic_set_unchecked(&dev->bytes_sent, 0);
51887 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
51888
51889 return count;
51890 }
51891 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
51892 index 7aec6f3..e3b2d55 100644
51893 --- a/drivers/video/uvesafb.c
51894 +++ b/drivers/video/uvesafb.c
51895 @@ -19,6 +19,7 @@
51896 #include <linux/io.h>
51897 #include <linux/mutex.h>
51898 #include <linux/slab.h>
51899 +#include <linux/moduleloader.h>
51900 #include <video/edid.h>
51901 #include <video/uvesafb.h>
51902 #ifdef CONFIG_X86
51903 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
51904 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
51905 par->pmi_setpal = par->ypan = 0;
51906 } else {
51907 +
51908 +#ifdef CONFIG_PAX_KERNEXEC
51909 +#ifdef CONFIG_MODULES
51910 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
51911 +#endif
51912 + if (!par->pmi_code) {
51913 + par->pmi_setpal = par->ypan = 0;
51914 + return 0;
51915 + }
51916 +#endif
51917 +
51918 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
51919 + task->t.regs.edi);
51920 +
51921 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51922 + pax_open_kernel();
51923 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
51924 + pax_close_kernel();
51925 +
51926 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
51927 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
51928 +#else
51929 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
51930 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
51931 +#endif
51932 +
51933 printk(KERN_INFO "uvesafb: protected mode interface info at "
51934 "%04x:%04x\n",
51935 (u16)task->t.regs.es, (u16)task->t.regs.edi);
51936 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
51937 par->ypan = ypan;
51938
51939 if (par->pmi_setpal || par->ypan) {
51940 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
51941 if (__supported_pte_mask & _PAGE_NX) {
51942 par->pmi_setpal = par->ypan = 0;
51943 printk(KERN_WARNING "uvesafb: NX protection is active, "
51944 "better not use the PMI.\n");
51945 - } else {
51946 + } else
51947 +#endif
51948 uvesafb_vbe_getpmi(task, par);
51949 - }
51950 }
51951 #else
51952 /* The protected mode interface is not available on non-x86. */
51953 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51954 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
51955
51956 /* Disable blanking if the user requested so. */
51957 - if (!blank)
51958 - info->fbops->fb_blank = NULL;
51959 + if (!blank) {
51960 + pax_open_kernel();
51961 + *(void **)&info->fbops->fb_blank = NULL;
51962 + pax_close_kernel();
51963 + }
51964
51965 /*
51966 * Find out how much IO memory is required for the mode with
51967 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
51968 info->flags = FBINFO_FLAG_DEFAULT |
51969 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
51970
51971 - if (!par->ypan)
51972 - info->fbops->fb_pan_display = NULL;
51973 + if (!par->ypan) {
51974 + pax_open_kernel();
51975 + *(void **)&info->fbops->fb_pan_display = NULL;
51976 + pax_close_kernel();
51977 + }
51978 }
51979
51980 static void uvesafb_init_mtrr(struct fb_info *info)
51981 @@ -1796,6 +1826,11 @@ out:
51982 if (par->vbe_modes)
51983 kfree(par->vbe_modes);
51984
51985 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51986 + if (par->pmi_code)
51987 + module_free_exec(NULL, par->pmi_code);
51988 +#endif
51989 +
51990 framebuffer_release(info);
51991 return err;
51992 }
51993 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
51994 kfree(par->vbe_state_orig);
51995 if (par->vbe_state_saved)
51996 kfree(par->vbe_state_saved);
51997 +
51998 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
51999 + if (par->pmi_code)
52000 + module_free_exec(NULL, par->pmi_code);
52001 +#endif
52002 +
52003 }
52004
52005 framebuffer_release(info);
52006 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
52007 index 501b340..d80aa17 100644
52008 --- a/drivers/video/vesafb.c
52009 +++ b/drivers/video/vesafb.c
52010 @@ -9,6 +9,7 @@
52011 */
52012
52013 #include <linux/module.h>
52014 +#include <linux/moduleloader.h>
52015 #include <linux/kernel.h>
52016 #include <linux/errno.h>
52017 #include <linux/string.h>
52018 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
52019 static int vram_total __initdata; /* Set total amount of memory */
52020 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
52021 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
52022 -static void (*pmi_start)(void) __read_mostly;
52023 -static void (*pmi_pal) (void) __read_mostly;
52024 +static void (*pmi_start)(void) __read_only;
52025 +static void (*pmi_pal) (void) __read_only;
52026 static int depth __read_mostly;
52027 static int vga_compat __read_mostly;
52028 /* --------------------------------------------------------------------- */
52029 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
52030 unsigned int size_vmode;
52031 unsigned int size_remap;
52032 unsigned int size_total;
52033 + void *pmi_code = NULL;
52034
52035 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
52036 return -ENODEV;
52037 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
52038 size_remap = size_total;
52039 vesafb_fix.smem_len = size_remap;
52040
52041 -#ifndef __i386__
52042 - screen_info.vesapm_seg = 0;
52043 -#endif
52044 -
52045 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
52046 printk(KERN_WARNING
52047 "vesafb: cannot reserve video memory at 0x%lx\n",
52048 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
52049 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
52050 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
52051
52052 +#ifdef __i386__
52053 +
52054 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52055 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
52056 + if (!pmi_code)
52057 +#elif !defined(CONFIG_PAX_KERNEXEC)
52058 + if (0)
52059 +#endif
52060 +
52061 +#endif
52062 + screen_info.vesapm_seg = 0;
52063 +
52064 if (screen_info.vesapm_seg) {
52065 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
52066 - screen_info.vesapm_seg,screen_info.vesapm_off);
52067 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
52068 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
52069 }
52070
52071 if (screen_info.vesapm_seg < 0xc000)
52072 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
52073
52074 if (ypan || pmi_setpal) {
52075 unsigned short *pmi_base;
52076 +
52077 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
52078 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
52079 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
52080 +
52081 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52082 + pax_open_kernel();
52083 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
52084 +#else
52085 + pmi_code = pmi_base;
52086 +#endif
52087 +
52088 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
52089 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
52090 +
52091 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52092 + pmi_start = ktva_ktla(pmi_start);
52093 + pmi_pal = ktva_ktla(pmi_pal);
52094 + pax_close_kernel();
52095 +#endif
52096 +
52097 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
52098 if (pmi_base[3]) {
52099 printk(KERN_INFO "vesafb: pmi: ports = ");
52100 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52101 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
52102 (ypan ? FBINFO_HWACCEL_YPAN : 0);
52103
52104 - if (!ypan)
52105 - info->fbops->fb_pan_display = NULL;
52106 + if (!ypan) {
52107 + pax_open_kernel();
52108 + *(void **)&info->fbops->fb_pan_display = NULL;
52109 + pax_close_kernel();
52110 + }
52111
52112 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
52113 err = -ENOMEM;
52114 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
52115 info->node, info->fix.id);
52116 return 0;
52117 err:
52118 +
52119 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
52120 + module_free_exec(NULL, pmi_code);
52121 +#endif
52122 +
52123 if (info->screen_base)
52124 iounmap(info->screen_base);
52125 framebuffer_release(info);
52126 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
52127 index 88714ae..16c2e11 100644
52128 --- a/drivers/video/via/via_clock.h
52129 +++ b/drivers/video/via/via_clock.h
52130 @@ -56,7 +56,7 @@ struct via_clock {
52131
52132 void (*set_engine_pll_state)(u8 state);
52133 void (*set_engine_pll)(struct via_pll_config config);
52134 -};
52135 +} __no_const;
52136
52137
52138 static inline u32 get_pll_internal_frequency(u32 ref_freq,
52139 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
52140 index fef20db..d28b1ab 100644
52141 --- a/drivers/xen/xenfs/xenstored.c
52142 +++ b/drivers/xen/xenfs/xenstored.c
52143 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
52144 static int xsd_kva_open(struct inode *inode, struct file *file)
52145 {
52146 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
52147 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52148 + NULL);
52149 +#else
52150 xen_store_interface);
52151 +#endif
52152 +
52153 if (!file->private_data)
52154 return -ENOMEM;
52155 return 0;
52156 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
52157 index 9ff073f..05cef23 100644
52158 --- a/fs/9p/vfs_addr.c
52159 +++ b/fs/9p/vfs_addr.c
52160 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
52161
52162 retval = v9fs_file_write_internal(inode,
52163 v9inode->writeback_fid,
52164 - (__force const char __user *)buffer,
52165 + (const char __force_user *)buffer,
52166 len, &offset, 0);
52167 if (retval > 0)
52168 retval = 0;
52169 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
52170 index 25b018e..b941525 100644
52171 --- a/fs/9p/vfs_inode.c
52172 +++ b/fs/9p/vfs_inode.c
52173 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
52174 void
52175 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52176 {
52177 - char *s = nd_get_link(nd);
52178 + const char *s = nd_get_link(nd);
52179
52180 p9_debug(P9_DEBUG_VFS, " %s %s\n",
52181 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
52182 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
52183 index 370b24c..ff0be7b 100644
52184 --- a/fs/Kconfig.binfmt
52185 +++ b/fs/Kconfig.binfmt
52186 @@ -103,7 +103,7 @@ config HAVE_AOUT
52187
52188 config BINFMT_AOUT
52189 tristate "Kernel support for a.out and ECOFF binaries"
52190 - depends on HAVE_AOUT
52191 + depends on HAVE_AOUT && BROKEN
52192 ---help---
52193 A.out (Assembler.OUTput) is a set of formats for libraries and
52194 executables used in the earliest versions of UNIX. Linux used
52195 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
52196 index 789bc25..fafaeea 100644
52197 --- a/fs/afs/inode.c
52198 +++ b/fs/afs/inode.c
52199 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52200 struct afs_vnode *vnode;
52201 struct super_block *sb;
52202 struct inode *inode;
52203 - static atomic_t afs_autocell_ino;
52204 + static atomic_unchecked_t afs_autocell_ino;
52205
52206 _enter("{%x:%u},%*.*s,",
52207 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
52208 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
52209 data.fid.unique = 0;
52210 data.fid.vnode = 0;
52211
52212 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
52213 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
52214 afs_iget5_autocell_test, afs_iget5_set,
52215 &data);
52216 if (!inode) {
52217 diff --git a/fs/aio.c b/fs/aio.c
52218 index 9b5ca11..c530886 100644
52219 --- a/fs/aio.c
52220 +++ b/fs/aio.c
52221 @@ -162,7 +162,7 @@ static int aio_setup_ring(struct kioctx *ctx)
52222 size += sizeof(struct io_event) * nr_events;
52223 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
52224
52225 - if (nr_pages < 0)
52226 + if (nr_pages <= 0)
52227 return -EINVAL;
52228
52229 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
52230 @@ -952,6 +952,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
52231 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52232 {
52233 ssize_t ret;
52234 + struct iovec iovstack;
52235
52236 kiocb->ki_nr_segs = kiocb->ki_nbytes;
52237
52238 @@ -959,17 +960,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
52239 if (compat)
52240 ret = compat_rw_copy_check_uvector(rw,
52241 (struct compat_iovec __user *)kiocb->ki_buf,
52242 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52243 + kiocb->ki_nr_segs, 1, &iovstack,
52244 &kiocb->ki_iovec);
52245 else
52246 #endif
52247 ret = rw_copy_check_uvector(rw,
52248 (struct iovec __user *)kiocb->ki_buf,
52249 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
52250 + kiocb->ki_nr_segs, 1, &iovstack,
52251 &kiocb->ki_iovec);
52252 if (ret < 0)
52253 return ret;
52254
52255 + if (kiocb->ki_iovec == &iovstack) {
52256 + kiocb->ki_inline_vec = iovstack;
52257 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
52258 + }
52259 +
52260 /* ki_nbytes now reflect bytes instead of segs */
52261 kiocb->ki_nbytes = ret;
52262 return 0;
52263 diff --git a/fs/attr.c b/fs/attr.c
52264 index 1449adb..a2038c2 100644
52265 --- a/fs/attr.c
52266 +++ b/fs/attr.c
52267 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
52268 unsigned long limit;
52269
52270 limit = rlimit(RLIMIT_FSIZE);
52271 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
52272 if (limit != RLIM_INFINITY && offset > limit)
52273 goto out_sig;
52274 if (offset > inode->i_sb->s_maxbytes)
52275 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
52276 index 3db70da..7aeec5b 100644
52277 --- a/fs/autofs4/waitq.c
52278 +++ b/fs/autofs4/waitq.c
52279 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
52280 {
52281 unsigned long sigpipe, flags;
52282 mm_segment_t fs;
52283 - const char *data = (const char *)addr;
52284 + const char __user *data = (const char __force_user *)addr;
52285 ssize_t wr = 0;
52286
52287 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
52288 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
52289 return 1;
52290 }
52291
52292 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52293 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
52294 +#endif
52295 +
52296 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52297 enum autofs_notify notify)
52298 {
52299 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
52300
52301 /* If this is a direct mount request create a dummy name */
52302 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
52303 +#ifdef CONFIG_GRKERNSEC_HIDESYM
52304 + /* this name does get written to userland via autofs4_write() */
52305 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
52306 +#else
52307 qstr.len = sprintf(name, "%p", dentry);
52308 +#endif
52309 else {
52310 qstr.len = autofs4_getpath(sbi, dentry, &name);
52311 if (!qstr.len) {
52312 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
52313 index 2722387..c8dd2a7 100644
52314 --- a/fs/befs/endian.h
52315 +++ b/fs/befs/endian.h
52316 @@ -11,7 +11,7 @@
52317
52318 #include <asm/byteorder.h>
52319
52320 -static inline u64
52321 +static inline u64 __intentional_overflow(-1)
52322 fs64_to_cpu(const struct super_block *sb, fs64 n)
52323 {
52324 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52325 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
52326 return (__force fs64)cpu_to_be64(n);
52327 }
52328
52329 -static inline u32
52330 +static inline u32 __intentional_overflow(-1)
52331 fs32_to_cpu(const struct super_block *sb, fs32 n)
52332 {
52333 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
52334 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
52335 index e9c75e2..1baece1 100644
52336 --- a/fs/befs/linuxvfs.c
52337 +++ b/fs/befs/linuxvfs.c
52338 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
52339 {
52340 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
52341 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
52342 - char *link = nd_get_link(nd);
52343 + const char *link = nd_get_link(nd);
52344 if (!IS_ERR(link))
52345 kfree(link);
52346 }
52347 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
52348 index 89dec7f..361b0d75 100644
52349 --- a/fs/binfmt_aout.c
52350 +++ b/fs/binfmt_aout.c
52351 @@ -16,6 +16,7 @@
52352 #include <linux/string.h>
52353 #include <linux/fs.h>
52354 #include <linux/file.h>
52355 +#include <linux/security.h>
52356 #include <linux/stat.h>
52357 #include <linux/fcntl.h>
52358 #include <linux/ptrace.h>
52359 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
52360 #endif
52361 # define START_STACK(u) ((void __user *)u.start_stack)
52362
52363 + memset(&dump, 0, sizeof(dump));
52364 +
52365 fs = get_fs();
52366 set_fs(KERNEL_DS);
52367 has_dumped = 1;
52368 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
52369
52370 /* If the size of the dump file exceeds the rlimit, then see what would happen
52371 if we wrote the stack, but not the data area. */
52372 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
52373 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
52374 dump.u_dsize = 0;
52375
52376 /* Make sure we have enough room to write the stack and data areas. */
52377 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
52378 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
52379 dump.u_ssize = 0;
52380
52381 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
52382 rlim = rlimit(RLIMIT_DATA);
52383 if (rlim >= RLIM_INFINITY)
52384 rlim = ~0;
52385 +
52386 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
52387 if (ex.a_data + ex.a_bss > rlim)
52388 return -ENOMEM;
52389
52390 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
52391
52392 install_exec_creds(bprm);
52393
52394 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52395 + current->mm->pax_flags = 0UL;
52396 +#endif
52397 +
52398 +#ifdef CONFIG_PAX_PAGEEXEC
52399 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
52400 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
52401 +
52402 +#ifdef CONFIG_PAX_EMUTRAMP
52403 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
52404 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
52405 +#endif
52406 +
52407 +#ifdef CONFIG_PAX_MPROTECT
52408 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
52409 + current->mm->pax_flags |= MF_PAX_MPROTECT;
52410 +#endif
52411 +
52412 + }
52413 +#endif
52414 +
52415 if (N_MAGIC(ex) == OMAGIC) {
52416 unsigned long text_addr, map_size;
52417 loff_t pos;
52418 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
52419 }
52420
52421 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
52422 - PROT_READ | PROT_WRITE | PROT_EXEC,
52423 + PROT_READ | PROT_WRITE,
52424 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
52425 fd_offset + ex.a_text);
52426 if (error != N_DATADDR(ex)) {
52427 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
52428 index 4c94a79..f428019 100644
52429 --- a/fs/binfmt_elf.c
52430 +++ b/fs/binfmt_elf.c
52431 @@ -34,6 +34,7 @@
52432 #include <linux/utsname.h>
52433 #include <linux/coredump.h>
52434 #include <linux/sched.h>
52435 +#include <linux/xattr.h>
52436 #include <asm/uaccess.h>
52437 #include <asm/param.h>
52438 #include <asm/page.h>
52439 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
52440 #define elf_core_dump NULL
52441 #endif
52442
52443 +#ifdef CONFIG_PAX_MPROTECT
52444 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
52445 +#endif
52446 +
52447 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52448 +static void elf_handle_mmap(struct file *file);
52449 +#endif
52450 +
52451 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
52452 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
52453 #else
52454 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
52455 .load_binary = load_elf_binary,
52456 .load_shlib = load_elf_library,
52457 .core_dump = elf_core_dump,
52458 +
52459 +#ifdef CONFIG_PAX_MPROTECT
52460 + .handle_mprotect= elf_handle_mprotect,
52461 +#endif
52462 +
52463 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
52464 + .handle_mmap = elf_handle_mmap,
52465 +#endif
52466 +
52467 .min_coredump = ELF_EXEC_PAGESIZE,
52468 };
52469
52470 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
52471
52472 static int set_brk(unsigned long start, unsigned long end)
52473 {
52474 + unsigned long e = end;
52475 +
52476 start = ELF_PAGEALIGN(start);
52477 end = ELF_PAGEALIGN(end);
52478 if (end > start) {
52479 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
52480 if (BAD_ADDR(addr))
52481 return addr;
52482 }
52483 - current->mm->start_brk = current->mm->brk = end;
52484 + current->mm->start_brk = current->mm->brk = e;
52485 return 0;
52486 }
52487
52488 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52489 elf_addr_t __user *u_rand_bytes;
52490 const char *k_platform = ELF_PLATFORM;
52491 const char *k_base_platform = ELF_BASE_PLATFORM;
52492 - unsigned char k_rand_bytes[16];
52493 + u32 k_rand_bytes[4];
52494 int items;
52495 elf_addr_t *elf_info;
52496 int ei_index = 0;
52497 const struct cred *cred = current_cred();
52498 struct vm_area_struct *vma;
52499 + unsigned long saved_auxv[AT_VECTOR_SIZE];
52500
52501 /*
52502 * In some cases (e.g. Hyper-Threading), we want to avoid L1
52503 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52504 * Generate 16 random bytes for userspace PRNG seeding.
52505 */
52506 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
52507 - u_rand_bytes = (elf_addr_t __user *)
52508 - STACK_ALLOC(p, sizeof(k_rand_bytes));
52509 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
52510 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
52511 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
52512 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
52513 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
52514 + u_rand_bytes = (elf_addr_t __user *) p;
52515 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
52516 return -EFAULT;
52517
52518 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
52519 return -EFAULT;
52520 current->mm->env_end = p;
52521
52522 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
52523 +
52524 /* Put the elf_info on the stack in the right place. */
52525 sp = (elf_addr_t __user *)envp + 1;
52526 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
52527 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
52528 return -EFAULT;
52529 return 0;
52530 }
52531 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
52532 an ELF header */
52533
52534 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52535 - struct file *interpreter, unsigned long *interp_map_addr,
52536 - unsigned long no_base)
52537 + struct file *interpreter, unsigned long no_base)
52538 {
52539 struct elf_phdr *elf_phdata;
52540 struct elf_phdr *eppnt;
52541 - unsigned long load_addr = 0;
52542 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
52543 int load_addr_set = 0;
52544 unsigned long last_bss = 0, elf_bss = 0;
52545 - unsigned long error = ~0UL;
52546 + unsigned long error = -EINVAL;
52547 unsigned long total_size;
52548 int retval, i, size;
52549
52550 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52551 goto out_close;
52552 }
52553
52554 +#ifdef CONFIG_PAX_SEGMEXEC
52555 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
52556 + pax_task_size = SEGMEXEC_TASK_SIZE;
52557 +#endif
52558 +
52559 eppnt = elf_phdata;
52560 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
52561 if (eppnt->p_type == PT_LOAD) {
52562 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52563 map_addr = elf_map(interpreter, load_addr + vaddr,
52564 eppnt, elf_prot, elf_type, total_size);
52565 total_size = 0;
52566 - if (!*interp_map_addr)
52567 - *interp_map_addr = map_addr;
52568 error = map_addr;
52569 if (BAD_ADDR(map_addr))
52570 goto out_close;
52571 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52572 k = load_addr + eppnt->p_vaddr;
52573 if (BAD_ADDR(k) ||
52574 eppnt->p_filesz > eppnt->p_memsz ||
52575 - eppnt->p_memsz > TASK_SIZE ||
52576 - TASK_SIZE - eppnt->p_memsz < k) {
52577 + eppnt->p_memsz > pax_task_size ||
52578 + pax_task_size - eppnt->p_memsz < k) {
52579 error = -ENOMEM;
52580 goto out_close;
52581 }
52582 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
52583 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
52584
52585 /* Map the last of the bss segment */
52586 - error = vm_brk(elf_bss, last_bss - elf_bss);
52587 - if (BAD_ADDR(error))
52588 - goto out_close;
52589 + if (last_bss > elf_bss) {
52590 + error = vm_brk(elf_bss, last_bss - elf_bss);
52591 + if (BAD_ADDR(error))
52592 + goto out_close;
52593 + }
52594 }
52595
52596 error = load_addr;
52597 @@ -538,6 +569,315 @@ out:
52598 return error;
52599 }
52600
52601 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52602 +#ifdef CONFIG_PAX_SOFTMODE
52603 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
52604 +{
52605 + unsigned long pax_flags = 0UL;
52606 +
52607 +#ifdef CONFIG_PAX_PAGEEXEC
52608 + if (elf_phdata->p_flags & PF_PAGEEXEC)
52609 + pax_flags |= MF_PAX_PAGEEXEC;
52610 +#endif
52611 +
52612 +#ifdef CONFIG_PAX_SEGMEXEC
52613 + if (elf_phdata->p_flags & PF_SEGMEXEC)
52614 + pax_flags |= MF_PAX_SEGMEXEC;
52615 +#endif
52616 +
52617 +#ifdef CONFIG_PAX_EMUTRAMP
52618 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52619 + pax_flags |= MF_PAX_EMUTRAMP;
52620 +#endif
52621 +
52622 +#ifdef CONFIG_PAX_MPROTECT
52623 + if (elf_phdata->p_flags & PF_MPROTECT)
52624 + pax_flags |= MF_PAX_MPROTECT;
52625 +#endif
52626 +
52627 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52628 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
52629 + pax_flags |= MF_PAX_RANDMMAP;
52630 +#endif
52631 +
52632 + return pax_flags;
52633 +}
52634 +#endif
52635 +
52636 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
52637 +{
52638 + unsigned long pax_flags = 0UL;
52639 +
52640 +#ifdef CONFIG_PAX_PAGEEXEC
52641 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
52642 + pax_flags |= MF_PAX_PAGEEXEC;
52643 +#endif
52644 +
52645 +#ifdef CONFIG_PAX_SEGMEXEC
52646 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
52647 + pax_flags |= MF_PAX_SEGMEXEC;
52648 +#endif
52649 +
52650 +#ifdef CONFIG_PAX_EMUTRAMP
52651 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
52652 + pax_flags |= MF_PAX_EMUTRAMP;
52653 +#endif
52654 +
52655 +#ifdef CONFIG_PAX_MPROTECT
52656 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
52657 + pax_flags |= MF_PAX_MPROTECT;
52658 +#endif
52659 +
52660 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52661 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
52662 + pax_flags |= MF_PAX_RANDMMAP;
52663 +#endif
52664 +
52665 + return pax_flags;
52666 +}
52667 +#endif
52668 +
52669 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52670 +#ifdef CONFIG_PAX_SOFTMODE
52671 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
52672 +{
52673 + unsigned long pax_flags = 0UL;
52674 +
52675 +#ifdef CONFIG_PAX_PAGEEXEC
52676 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
52677 + pax_flags |= MF_PAX_PAGEEXEC;
52678 +#endif
52679 +
52680 +#ifdef CONFIG_PAX_SEGMEXEC
52681 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
52682 + pax_flags |= MF_PAX_SEGMEXEC;
52683 +#endif
52684 +
52685 +#ifdef CONFIG_PAX_EMUTRAMP
52686 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
52687 + pax_flags |= MF_PAX_EMUTRAMP;
52688 +#endif
52689 +
52690 +#ifdef CONFIG_PAX_MPROTECT
52691 + if (pax_flags_softmode & MF_PAX_MPROTECT)
52692 + pax_flags |= MF_PAX_MPROTECT;
52693 +#endif
52694 +
52695 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52696 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
52697 + pax_flags |= MF_PAX_RANDMMAP;
52698 +#endif
52699 +
52700 + return pax_flags;
52701 +}
52702 +#endif
52703 +
52704 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
52705 +{
52706 + unsigned long pax_flags = 0UL;
52707 +
52708 +#ifdef CONFIG_PAX_PAGEEXEC
52709 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
52710 + pax_flags |= MF_PAX_PAGEEXEC;
52711 +#endif
52712 +
52713 +#ifdef CONFIG_PAX_SEGMEXEC
52714 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
52715 + pax_flags |= MF_PAX_SEGMEXEC;
52716 +#endif
52717 +
52718 +#ifdef CONFIG_PAX_EMUTRAMP
52719 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
52720 + pax_flags |= MF_PAX_EMUTRAMP;
52721 +#endif
52722 +
52723 +#ifdef CONFIG_PAX_MPROTECT
52724 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
52725 + pax_flags |= MF_PAX_MPROTECT;
52726 +#endif
52727 +
52728 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
52729 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
52730 + pax_flags |= MF_PAX_RANDMMAP;
52731 +#endif
52732 +
52733 + return pax_flags;
52734 +}
52735 +#endif
52736 +
52737 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52738 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
52739 +{
52740 + unsigned long pax_flags = 0UL;
52741 +
52742 +#ifdef CONFIG_PAX_EI_PAX
52743 +
52744 +#ifdef CONFIG_PAX_PAGEEXEC
52745 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
52746 + pax_flags |= MF_PAX_PAGEEXEC;
52747 +#endif
52748 +
52749 +#ifdef CONFIG_PAX_SEGMEXEC
52750 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
52751 + pax_flags |= MF_PAX_SEGMEXEC;
52752 +#endif
52753 +
52754 +#ifdef CONFIG_PAX_EMUTRAMP
52755 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
52756 + pax_flags |= MF_PAX_EMUTRAMP;
52757 +#endif
52758 +
52759 +#ifdef CONFIG_PAX_MPROTECT
52760 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
52761 + pax_flags |= MF_PAX_MPROTECT;
52762 +#endif
52763 +
52764 +#ifdef CONFIG_PAX_ASLR
52765 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
52766 + pax_flags |= MF_PAX_RANDMMAP;
52767 +#endif
52768 +
52769 +#else
52770 +
52771 +#ifdef CONFIG_PAX_PAGEEXEC
52772 + pax_flags |= MF_PAX_PAGEEXEC;
52773 +#endif
52774 +
52775 +#ifdef CONFIG_PAX_SEGMEXEC
52776 + pax_flags |= MF_PAX_SEGMEXEC;
52777 +#endif
52778 +
52779 +#ifdef CONFIG_PAX_MPROTECT
52780 + pax_flags |= MF_PAX_MPROTECT;
52781 +#endif
52782 +
52783 +#ifdef CONFIG_PAX_RANDMMAP
52784 + if (randomize_va_space)
52785 + pax_flags |= MF_PAX_RANDMMAP;
52786 +#endif
52787 +
52788 +#endif
52789 +
52790 + return pax_flags;
52791 +}
52792 +
52793 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
52794 +{
52795 +
52796 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
52797 + unsigned long i;
52798 +
52799 + for (i = 0UL; i < elf_ex->e_phnum; i++)
52800 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
52801 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
52802 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
52803 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
52804 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
52805 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
52806 + return ~0UL;
52807 +
52808 +#ifdef CONFIG_PAX_SOFTMODE
52809 + if (pax_softmode)
52810 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
52811 + else
52812 +#endif
52813 +
52814 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
52815 + break;
52816 + }
52817 +#endif
52818 +
52819 + return ~0UL;
52820 +}
52821 +
52822 +static unsigned long pax_parse_xattr_pax(struct file * const file)
52823 +{
52824 +
52825 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
52826 + ssize_t xattr_size, i;
52827 + unsigned char xattr_value[sizeof("pemrs") - 1];
52828 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
52829 +
52830 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
52831 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
52832 + return ~0UL;
52833 +
52834 + for (i = 0; i < xattr_size; i++)
52835 + switch (xattr_value[i]) {
52836 + default:
52837 + return ~0UL;
52838 +
52839 +#define parse_flag(option1, option2, flag) \
52840 + case option1: \
52841 + if (pax_flags_hardmode & MF_PAX_##flag) \
52842 + return ~0UL; \
52843 + pax_flags_hardmode |= MF_PAX_##flag; \
52844 + break; \
52845 + case option2: \
52846 + if (pax_flags_softmode & MF_PAX_##flag) \
52847 + return ~0UL; \
52848 + pax_flags_softmode |= MF_PAX_##flag; \
52849 + break;
52850 +
52851 + parse_flag('p', 'P', PAGEEXEC);
52852 + parse_flag('e', 'E', EMUTRAMP);
52853 + parse_flag('m', 'M', MPROTECT);
52854 + parse_flag('r', 'R', RANDMMAP);
52855 + parse_flag('s', 'S', SEGMEXEC);
52856 +
52857 +#undef parse_flag
52858 + }
52859 +
52860 + if (pax_flags_hardmode & pax_flags_softmode)
52861 + return ~0UL;
52862 +
52863 +#ifdef CONFIG_PAX_SOFTMODE
52864 + if (pax_softmode)
52865 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
52866 + else
52867 +#endif
52868 +
52869 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
52870 +#else
52871 + return ~0UL;
52872 +#endif
52873 +
52874 +}
52875 +
52876 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
52877 +{
52878 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
52879 +
52880 + pax_flags = pax_parse_ei_pax(elf_ex);
52881 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
52882 + xattr_pax_flags = pax_parse_xattr_pax(file);
52883 +
52884 + if (pt_pax_flags == ~0UL)
52885 + pt_pax_flags = xattr_pax_flags;
52886 + else if (xattr_pax_flags == ~0UL)
52887 + xattr_pax_flags = pt_pax_flags;
52888 + if (pt_pax_flags != xattr_pax_flags)
52889 + return -EINVAL;
52890 + if (pt_pax_flags != ~0UL)
52891 + pax_flags = pt_pax_flags;
52892 +
52893 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
52894 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52895 + if ((__supported_pte_mask & _PAGE_NX))
52896 + pax_flags &= ~MF_PAX_SEGMEXEC;
52897 + else
52898 + pax_flags &= ~MF_PAX_PAGEEXEC;
52899 + }
52900 +#endif
52901 +
52902 + if (0 > pax_check_flags(&pax_flags))
52903 + return -EINVAL;
52904 +
52905 + current->mm->pax_flags = pax_flags;
52906 + return 0;
52907 +}
52908 +#endif
52909 +
52910 /*
52911 * These are the functions used to load ELF style executables and shared
52912 * libraries. There is no binary dependent code anywhere else.
52913 @@ -554,6 +894,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
52914 {
52915 unsigned int random_variable = 0;
52916
52917 +#ifdef CONFIG_PAX_RANDUSTACK
52918 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
52919 + return stack_top - current->mm->delta_stack;
52920 +#endif
52921 +
52922 if ((current->flags & PF_RANDOMIZE) &&
52923 !(current->personality & ADDR_NO_RANDOMIZE)) {
52924 random_variable = get_random_int() & STACK_RND_MASK;
52925 @@ -572,7 +917,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
52926 unsigned long load_addr = 0, load_bias = 0;
52927 int load_addr_set = 0;
52928 char * elf_interpreter = NULL;
52929 - unsigned long error;
52930 + unsigned long error = 0;
52931 struct elf_phdr *elf_ppnt, *elf_phdata;
52932 unsigned long elf_bss, elf_brk;
52933 int retval, i;
52934 @@ -582,12 +927,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
52935 unsigned long start_code, end_code, start_data, end_data;
52936 unsigned long reloc_func_desc __maybe_unused = 0;
52937 int executable_stack = EXSTACK_DEFAULT;
52938 - unsigned long def_flags = 0;
52939 struct pt_regs *regs = current_pt_regs();
52940 struct {
52941 struct elfhdr elf_ex;
52942 struct elfhdr interp_elf_ex;
52943 } *loc;
52944 + unsigned long pax_task_size = TASK_SIZE;
52945
52946 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
52947 if (!loc) {
52948 @@ -723,11 +1068,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
52949 goto out_free_dentry;
52950
52951 /* OK, This is the point of no return */
52952 - current->mm->def_flags = def_flags;
52953 +
52954 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52955 + current->mm->pax_flags = 0UL;
52956 +#endif
52957 +
52958 +#ifdef CONFIG_PAX_DLRESOLVE
52959 + current->mm->call_dl_resolve = 0UL;
52960 +#endif
52961 +
52962 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
52963 + current->mm->call_syscall = 0UL;
52964 +#endif
52965 +
52966 +#ifdef CONFIG_PAX_ASLR
52967 + current->mm->delta_mmap = 0UL;
52968 + current->mm->delta_stack = 0UL;
52969 +#endif
52970 +
52971 + current->mm->def_flags = 0;
52972 +
52973 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
52974 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
52975 + send_sig(SIGKILL, current, 0);
52976 + goto out_free_dentry;
52977 + }
52978 +#endif
52979 +
52980 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52981 + pax_set_initial_flags(bprm);
52982 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
52983 + if (pax_set_initial_flags_func)
52984 + (pax_set_initial_flags_func)(bprm);
52985 +#endif
52986 +
52987 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
52988 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
52989 + current->mm->context.user_cs_limit = PAGE_SIZE;
52990 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
52991 + }
52992 +#endif
52993 +
52994 +#ifdef CONFIG_PAX_SEGMEXEC
52995 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
52996 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
52997 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
52998 + pax_task_size = SEGMEXEC_TASK_SIZE;
52999 + current->mm->def_flags |= VM_NOHUGEPAGE;
53000 + }
53001 +#endif
53002 +
53003 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
53004 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53005 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
53006 + put_cpu();
53007 + }
53008 +#endif
53009
53010 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
53011 may depend on the personality. */
53012 SET_PERSONALITY(loc->elf_ex);
53013 +
53014 +#ifdef CONFIG_PAX_ASLR
53015 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53016 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
53017 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
53018 + }
53019 +#endif
53020 +
53021 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53022 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53023 + executable_stack = EXSTACK_DISABLE_X;
53024 + current->personality &= ~READ_IMPLIES_EXEC;
53025 + } else
53026 +#endif
53027 +
53028 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
53029 current->personality |= READ_IMPLIES_EXEC;
53030
53031 @@ -817,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
53032 #else
53033 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
53034 #endif
53035 +
53036 +#ifdef CONFIG_PAX_RANDMMAP
53037 + /* PaX: randomize base address at the default exe base if requested */
53038 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
53039 +#ifdef CONFIG_SPARC64
53040 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
53041 +#else
53042 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
53043 +#endif
53044 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
53045 + elf_flags |= MAP_FIXED;
53046 + }
53047 +#endif
53048 +
53049 }
53050
53051 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
53052 @@ -849,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
53053 * allowed task size. Note that p_filesz must always be
53054 * <= p_memsz so it is only necessary to check p_memsz.
53055 */
53056 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53057 - elf_ppnt->p_memsz > TASK_SIZE ||
53058 - TASK_SIZE - elf_ppnt->p_memsz < k) {
53059 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
53060 + elf_ppnt->p_memsz > pax_task_size ||
53061 + pax_task_size - elf_ppnt->p_memsz < k) {
53062 /* set_brk can never work. Avoid overflows. */
53063 send_sig(SIGKILL, current, 0);
53064 retval = -EINVAL;
53065 @@ -890,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
53066 goto out_free_dentry;
53067 }
53068 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
53069 - send_sig(SIGSEGV, current, 0);
53070 - retval = -EFAULT; /* Nobody gets to see this, but.. */
53071 - goto out_free_dentry;
53072 + /*
53073 + * This bss-zeroing can fail if the ELF
53074 + * file specifies odd protections. So
53075 + * we don't check the return value
53076 + */
53077 }
53078
53079 +#ifdef CONFIG_PAX_RANDMMAP
53080 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
53081 + unsigned long start, size, flags;
53082 + vm_flags_t vm_flags;
53083 +
53084 + start = ELF_PAGEALIGN(elf_brk);
53085 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
53086 + flags = MAP_FIXED | MAP_PRIVATE;
53087 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
53088 +
53089 + down_write(&current->mm->mmap_sem);
53090 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
53091 + retval = -ENOMEM;
53092 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
53093 +// if (current->personality & ADDR_NO_RANDOMIZE)
53094 +// vm_flags |= VM_READ | VM_MAYREAD;
53095 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
53096 + retval = IS_ERR_VALUE(start) ? start : 0;
53097 + }
53098 + up_write(&current->mm->mmap_sem);
53099 + if (retval == 0)
53100 + retval = set_brk(start + size, start + size + PAGE_SIZE);
53101 + if (retval < 0) {
53102 + send_sig(SIGKILL, current, 0);
53103 + goto out_free_dentry;
53104 + }
53105 + }
53106 +#endif
53107 +
53108 if (elf_interpreter) {
53109 - unsigned long interp_map_addr = 0;
53110 -
53111 elf_entry = load_elf_interp(&loc->interp_elf_ex,
53112 interpreter,
53113 - &interp_map_addr,
53114 load_bias);
53115 if (!IS_ERR((void *)elf_entry)) {
53116 /*
53117 @@ -1122,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
53118 * Decide what to dump of a segment, part, all or none.
53119 */
53120 static unsigned long vma_dump_size(struct vm_area_struct *vma,
53121 - unsigned long mm_flags)
53122 + unsigned long mm_flags, long signr)
53123 {
53124 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
53125
53126 @@ -1160,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
53127 if (vma->vm_file == NULL)
53128 return 0;
53129
53130 - if (FILTER(MAPPED_PRIVATE))
53131 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
53132 goto whole;
53133
53134 /*
53135 @@ -1385,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
53136 {
53137 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
53138 int i = 0;
53139 - do
53140 + do {
53141 i += 2;
53142 - while (auxv[i - 2] != AT_NULL);
53143 + } while (auxv[i - 2] != AT_NULL);
53144 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
53145 }
53146
53147 @@ -1396,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
53148 {
53149 mm_segment_t old_fs = get_fs();
53150 set_fs(KERNEL_DS);
53151 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
53152 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
53153 set_fs(old_fs);
53154 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
53155 }
53156 @@ -2023,14 +2480,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
53157 }
53158
53159 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
53160 - unsigned long mm_flags)
53161 + struct coredump_params *cprm)
53162 {
53163 struct vm_area_struct *vma;
53164 size_t size = 0;
53165
53166 for (vma = first_vma(current, gate_vma); vma != NULL;
53167 vma = next_vma(vma, gate_vma))
53168 - size += vma_dump_size(vma, mm_flags);
53169 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53170 return size;
53171 }
53172
53173 @@ -2123,7 +2580,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53174
53175 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
53176
53177 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
53178 + offset += elf_core_vma_data_size(gate_vma, cprm);
53179 offset += elf_core_extra_data_size();
53180 e_shoff = offset;
53181
53182 @@ -2137,10 +2594,12 @@ static int elf_core_dump(struct coredump_params *cprm)
53183 offset = dataoff;
53184
53185 size += sizeof(*elf);
53186 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53187 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
53188 goto end_coredump;
53189
53190 size += sizeof(*phdr4note);
53191 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53192 if (size > cprm->limit
53193 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
53194 goto end_coredump;
53195 @@ -2154,7 +2613,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53196 phdr.p_offset = offset;
53197 phdr.p_vaddr = vma->vm_start;
53198 phdr.p_paddr = 0;
53199 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
53200 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53201 phdr.p_memsz = vma->vm_end - vma->vm_start;
53202 offset += phdr.p_filesz;
53203 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
53204 @@ -2165,6 +2624,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53205 phdr.p_align = ELF_EXEC_PAGESIZE;
53206
53207 size += sizeof(phdr);
53208 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53209 if (size > cprm->limit
53210 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
53211 goto end_coredump;
53212 @@ -2189,7 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53213 unsigned long addr;
53214 unsigned long end;
53215
53216 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
53217 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
53218
53219 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
53220 struct page *page;
53221 @@ -2198,6 +2658,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53222 page = get_dump_page(addr);
53223 if (page) {
53224 void *kaddr = kmap(page);
53225 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
53226 stop = ((size += PAGE_SIZE) > cprm->limit) ||
53227 !dump_write(cprm->file, kaddr,
53228 PAGE_SIZE);
53229 @@ -2215,6 +2676,7 @@ static int elf_core_dump(struct coredump_params *cprm)
53230
53231 if (e_phnum == PN_XNUM) {
53232 size += sizeof(*shdr4extnum);
53233 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
53234 if (size > cprm->limit
53235 || !dump_write(cprm->file, shdr4extnum,
53236 sizeof(*shdr4extnum)))
53237 @@ -2235,6 +2697,167 @@ out:
53238
53239 #endif /* CONFIG_ELF_CORE */
53240
53241 +#ifdef CONFIG_PAX_MPROTECT
53242 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
53243 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
53244 + * we'll remove VM_MAYWRITE for good on RELRO segments.
53245 + *
53246 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
53247 + * basis because we want to allow the common case and not the special ones.
53248 + */
53249 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
53250 +{
53251 + struct elfhdr elf_h;
53252 + struct elf_phdr elf_p;
53253 + unsigned long i;
53254 + unsigned long oldflags;
53255 + bool is_textrel_rw, is_textrel_rx, is_relro;
53256 +
53257 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
53258 + return;
53259 +
53260 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
53261 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
53262 +
53263 +#ifdef CONFIG_PAX_ELFRELOCS
53264 + /* possible TEXTREL */
53265 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
53266 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
53267 +#else
53268 + is_textrel_rw = false;
53269 + is_textrel_rx = false;
53270 +#endif
53271 +
53272 + /* possible RELRO */
53273 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
53274 +
53275 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
53276 + return;
53277 +
53278 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53279 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53280 +
53281 +#ifdef CONFIG_PAX_ETEXECRELOCS
53282 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53283 +#else
53284 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
53285 +#endif
53286 +
53287 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
53288 + !elf_check_arch(&elf_h) ||
53289 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53290 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53291 + return;
53292 +
53293 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53294 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53295 + return;
53296 + switch (elf_p.p_type) {
53297 + case PT_DYNAMIC:
53298 + if (!is_textrel_rw && !is_textrel_rx)
53299 + continue;
53300 + i = 0UL;
53301 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
53302 + elf_dyn dyn;
53303 +
53304 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
53305 + break;
53306 + if (dyn.d_tag == DT_NULL)
53307 + break;
53308 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
53309 + gr_log_textrel(vma);
53310 + if (is_textrel_rw)
53311 + vma->vm_flags |= VM_MAYWRITE;
53312 + else
53313 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
53314 + vma->vm_flags &= ~VM_MAYWRITE;
53315 + break;
53316 + }
53317 + i++;
53318 + }
53319 + is_textrel_rw = false;
53320 + is_textrel_rx = false;
53321 + continue;
53322 +
53323 + case PT_GNU_RELRO:
53324 + if (!is_relro)
53325 + continue;
53326 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
53327 + vma->vm_flags &= ~VM_MAYWRITE;
53328 + is_relro = false;
53329 + continue;
53330 +
53331 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53332 + case PT_PAX_FLAGS: {
53333 + const char *msg_mprotect = "", *msg_emutramp = "";
53334 + char *buffer_lib, *buffer_exe;
53335 +
53336 + if (elf_p.p_flags & PF_NOMPROTECT)
53337 + msg_mprotect = "MPROTECT disabled";
53338 +
53339 +#ifdef CONFIG_PAX_EMUTRAMP
53340 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
53341 + msg_emutramp = "EMUTRAMP enabled";
53342 +#endif
53343 +
53344 + if (!msg_mprotect[0] && !msg_emutramp[0])
53345 + continue;
53346 +
53347 + if (!printk_ratelimit())
53348 + continue;
53349 +
53350 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
53351 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
53352 + if (buffer_lib && buffer_exe) {
53353 + char *path_lib, *path_exe;
53354 +
53355 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
53356 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
53357 +
53358 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
53359 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
53360 +
53361 + }
53362 + free_page((unsigned long)buffer_exe);
53363 + free_page((unsigned long)buffer_lib);
53364 + continue;
53365 + }
53366 +#endif
53367 +
53368 + }
53369 + }
53370 +}
53371 +#endif
53372 +
53373 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53374 +
53375 +extern int grsec_enable_log_rwxmaps;
53376 +
53377 +static void elf_handle_mmap(struct file *file)
53378 +{
53379 + struct elfhdr elf_h;
53380 + struct elf_phdr elf_p;
53381 + unsigned long i;
53382 +
53383 + if (!grsec_enable_log_rwxmaps)
53384 + return;
53385 +
53386 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
53387 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
53388 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
53389 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
53390 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
53391 + return;
53392 +
53393 + for (i = 0UL; i < elf_h.e_phnum; i++) {
53394 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
53395 + return;
53396 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
53397 + gr_log_ptgnustack(file);
53398 + }
53399 +}
53400 +#endif
53401 +
53402 static int __init init_elf_binfmt(void)
53403 {
53404 register_binfmt(&elf_format);
53405 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
53406 index d50bbe5..af3b649 100644
53407 --- a/fs/binfmt_flat.c
53408 +++ b/fs/binfmt_flat.c
53409 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
53410 realdatastart = (unsigned long) -ENOMEM;
53411 printk("Unable to allocate RAM for process data, errno %d\n",
53412 (int)-realdatastart);
53413 + down_write(&current->mm->mmap_sem);
53414 vm_munmap(textpos, text_len);
53415 + up_write(&current->mm->mmap_sem);
53416 ret = realdatastart;
53417 goto err;
53418 }
53419 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53420 }
53421 if (IS_ERR_VALUE(result)) {
53422 printk("Unable to read data+bss, errno %d\n", (int)-result);
53423 + down_write(&current->mm->mmap_sem);
53424 vm_munmap(textpos, text_len);
53425 vm_munmap(realdatastart, len);
53426 + up_write(&current->mm->mmap_sem);
53427 ret = result;
53428 goto err;
53429 }
53430 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
53431 }
53432 if (IS_ERR_VALUE(result)) {
53433 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
53434 + down_write(&current->mm->mmap_sem);
53435 vm_munmap(textpos, text_len + data_len + extra +
53436 MAX_SHARED_LIBS * sizeof(unsigned long));
53437 + up_write(&current->mm->mmap_sem);
53438 ret = result;
53439 goto err;
53440 }
53441 diff --git a/fs/bio.c b/fs/bio.c
53442 index 5e7507d..418c639 100644
53443 --- a/fs/bio.c
53444 +++ b/fs/bio.c
53445 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
53446 /*
53447 * Overflow, abort
53448 */
53449 - if (end < start)
53450 + if (end < start || end - start > INT_MAX - nr_pages)
53451 return ERR_PTR(-EINVAL);
53452
53453 nr_pages += end - start;
53454 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
53455 /*
53456 * Overflow, abort
53457 */
53458 - if (end < start)
53459 + if (end < start || end - start > INT_MAX - nr_pages)
53460 return ERR_PTR(-EINVAL);
53461
53462 nr_pages += end - start;
53463 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
53464 const int read = bio_data_dir(bio) == READ;
53465 struct bio_map_data *bmd = bio->bi_private;
53466 int i;
53467 - char *p = bmd->sgvecs[0].iov_base;
53468 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
53469
53470 bio_for_each_segment_all(bvec, bio, i) {
53471 char *addr = page_address(bvec->bv_page);
53472 diff --git a/fs/block_dev.c b/fs/block_dev.c
53473 index c7bda5c..2121e94 100644
53474 --- a/fs/block_dev.c
53475 +++ b/fs/block_dev.c
53476 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
53477 else if (bdev->bd_contains == bdev)
53478 return true; /* is a whole device which isn't held */
53479
53480 - else if (whole->bd_holder == bd_may_claim)
53481 + else if (whole->bd_holder == (void *)bd_may_claim)
53482 return true; /* is a partition of a device that is being partitioned */
53483 else if (whole->bd_holder != NULL)
53484 return false; /* is a partition of a held device */
53485 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
53486 index ed50460..fe84385 100644
53487 --- a/fs/btrfs/ctree.c
53488 +++ b/fs/btrfs/ctree.c
53489 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
53490 free_extent_buffer(buf);
53491 add_root_to_dirty_list(root);
53492 } else {
53493 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
53494 - parent_start = parent->start;
53495 - else
53496 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
53497 + if (parent)
53498 + parent_start = parent->start;
53499 + else
53500 + parent_start = 0;
53501 + } else
53502 parent_start = 0;
53503
53504 WARN_ON(trans->transid != btrfs_header_generation(parent));
53505 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
53506 index 3755109..e3d457f 100644
53507 --- a/fs/btrfs/delayed-inode.c
53508 +++ b/fs/btrfs/delayed-inode.c
53509 @@ -458,7 +458,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
53510
53511 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
53512 {
53513 - int seq = atomic_inc_return(&delayed_root->items_seq);
53514 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
53515 if ((atomic_dec_return(&delayed_root->items) <
53516 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
53517 waitqueue_active(&delayed_root->wait))
53518 @@ -1377,7 +1377,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
53519 static int refs_newer(struct btrfs_delayed_root *delayed_root,
53520 int seq, int count)
53521 {
53522 - int val = atomic_read(&delayed_root->items_seq);
53523 + int val = atomic_read_unchecked(&delayed_root->items_seq);
53524
53525 if (val < seq || val >= seq + count)
53526 return 1;
53527 @@ -1394,7 +1394,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
53528 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
53529 return;
53530
53531 - seq = atomic_read(&delayed_root->items_seq);
53532 + seq = atomic_read_unchecked(&delayed_root->items_seq);
53533
53534 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
53535 int ret;
53536 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
53537 index a4b38f9..f86a509 100644
53538 --- a/fs/btrfs/delayed-inode.h
53539 +++ b/fs/btrfs/delayed-inode.h
53540 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
53541 */
53542 struct list_head prepare_list;
53543 atomic_t items; /* for delayed items */
53544 - atomic_t items_seq; /* for delayed items */
53545 + atomic_unchecked_t items_seq; /* for delayed items */
53546 int nodes; /* for delayed nodes */
53547 wait_queue_head_t wait;
53548 };
53549 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
53550 struct btrfs_delayed_root *delayed_root)
53551 {
53552 atomic_set(&delayed_root->items, 0);
53553 - atomic_set(&delayed_root->items_seq, 0);
53554 + atomic_set_unchecked(&delayed_root->items_seq, 0);
53555 delayed_root->nodes = 0;
53556 spin_lock_init(&delayed_root->lock);
53557 init_waitqueue_head(&delayed_root->wait);
53558 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
53559 index 9877a2a..7ebf9ab 100644
53560 --- a/fs/btrfs/ioctl.c
53561 +++ b/fs/btrfs/ioctl.c
53562 @@ -3097,9 +3097,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53563 for (i = 0; i < num_types; i++) {
53564 struct btrfs_space_info *tmp;
53565
53566 + /* Don't copy in more than we allocated */
53567 if (!slot_count)
53568 break;
53569
53570 + slot_count--;
53571 +
53572 info = NULL;
53573 rcu_read_lock();
53574 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
53575 @@ -3121,10 +3124,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
53576 memcpy(dest, &space, sizeof(space));
53577 dest++;
53578 space_args.total_spaces++;
53579 - slot_count--;
53580 }
53581 - if (!slot_count)
53582 - break;
53583 }
53584 up_read(&info->groups_sem);
53585 }
53586 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
53587 index 8eb6191..eda91e2 100644
53588 --- a/fs/btrfs/super.c
53589 +++ b/fs/btrfs/super.c
53590 @@ -264,7 +264,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
53591 function, line, errstr);
53592 return;
53593 }
53594 - ACCESS_ONCE(trans->transaction->aborted) = errno;
53595 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
53596 /* Wake up anybody who may be waiting on this transaction */
53597 wake_up(&root->fs_info->transaction_wait);
53598 wake_up(&root->fs_info->transaction_blocked_wait);
53599 diff --git a/fs/buffer.c b/fs/buffer.c
53600 index 4d74335..7bd000a 100644
53601 --- a/fs/buffer.c
53602 +++ b/fs/buffer.c
53603 @@ -1005,9 +1005,19 @@ grow_dev_page(struct block_device *bdev, sector_t block,
53604 struct buffer_head *bh;
53605 sector_t end_block;
53606 int ret = 0; /* Will call free_more_memory() */
53607 + gfp_t gfp_mask;
53608
53609 - page = find_or_create_page(inode->i_mapping, index,
53610 - (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE);
53611 + gfp_mask = mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS;
53612 + gfp_mask |= __GFP_MOVABLE;
53613 + /*
53614 + * XXX: __getblk_slow() can not really deal with failure and
53615 + * will endlessly loop on improvised global reclaim. Prefer
53616 + * looping in the allocator rather than here, at least that
53617 + * code knows what it's doing.
53618 + */
53619 + gfp_mask |= __GFP_NOFAIL;
53620 +
53621 + page = find_or_create_page(inode->i_mapping, index, gfp_mask);
53622 if (!page)
53623 return ret;
53624
53625 @@ -3416,7 +3426,7 @@ void __init buffer_init(void)
53626 bh_cachep = kmem_cache_create("buffer_head",
53627 sizeof(struct buffer_head), 0,
53628 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
53629 - SLAB_MEM_SPREAD),
53630 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
53631 NULL);
53632
53633 /*
53634 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
53635 index 622f469..e8d2d55 100644
53636 --- a/fs/cachefiles/bind.c
53637 +++ b/fs/cachefiles/bind.c
53638 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
53639 args);
53640
53641 /* start by checking things over */
53642 - ASSERT(cache->fstop_percent >= 0 &&
53643 - cache->fstop_percent < cache->fcull_percent &&
53644 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
53645 cache->fcull_percent < cache->frun_percent &&
53646 cache->frun_percent < 100);
53647
53648 - ASSERT(cache->bstop_percent >= 0 &&
53649 - cache->bstop_percent < cache->bcull_percent &&
53650 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
53651 cache->bcull_percent < cache->brun_percent &&
53652 cache->brun_percent < 100);
53653
53654 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
53655 index 0a1467b..6a53245 100644
53656 --- a/fs/cachefiles/daemon.c
53657 +++ b/fs/cachefiles/daemon.c
53658 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
53659 if (n > buflen)
53660 return -EMSGSIZE;
53661
53662 - if (copy_to_user(_buffer, buffer, n) != 0)
53663 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
53664 return -EFAULT;
53665
53666 return n;
53667 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
53668 if (test_bit(CACHEFILES_DEAD, &cache->flags))
53669 return -EIO;
53670
53671 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
53672 + if (datalen > PAGE_SIZE - 1)
53673 return -EOPNOTSUPP;
53674
53675 /* drag the command string into the kernel so we can parse it */
53676 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
53677 if (args[0] != '%' || args[1] != '\0')
53678 return -EINVAL;
53679
53680 - if (fstop < 0 || fstop >= cache->fcull_percent)
53681 + if (fstop >= cache->fcull_percent)
53682 return cachefiles_daemon_range_error(cache, args);
53683
53684 cache->fstop_percent = fstop;
53685 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
53686 if (args[0] != '%' || args[1] != '\0')
53687 return -EINVAL;
53688
53689 - if (bstop < 0 || bstop >= cache->bcull_percent)
53690 + if (bstop >= cache->bcull_percent)
53691 return cachefiles_daemon_range_error(cache, args);
53692
53693 cache->bstop_percent = bstop;
53694 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
53695 index 4938251..7e01445 100644
53696 --- a/fs/cachefiles/internal.h
53697 +++ b/fs/cachefiles/internal.h
53698 @@ -59,7 +59,7 @@ struct cachefiles_cache {
53699 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
53700 struct rb_root active_nodes; /* active nodes (can't be culled) */
53701 rwlock_t active_lock; /* lock for active_nodes */
53702 - atomic_t gravecounter; /* graveyard uniquifier */
53703 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
53704 unsigned frun_percent; /* when to stop culling (% files) */
53705 unsigned fcull_percent; /* when to start culling (% files) */
53706 unsigned fstop_percent; /* when to stop allocating (% files) */
53707 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
53708 * proc.c
53709 */
53710 #ifdef CONFIG_CACHEFILES_HISTOGRAM
53711 -extern atomic_t cachefiles_lookup_histogram[HZ];
53712 -extern atomic_t cachefiles_mkdir_histogram[HZ];
53713 -extern atomic_t cachefiles_create_histogram[HZ];
53714 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53715 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53716 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
53717
53718 extern int __init cachefiles_proc_init(void);
53719 extern void cachefiles_proc_cleanup(void);
53720 static inline
53721 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
53722 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
53723 {
53724 unsigned long jif = jiffies - start_jif;
53725 if (jif >= HZ)
53726 jif = HZ - 1;
53727 - atomic_inc(&histogram[jif]);
53728 + atomic_inc_unchecked(&histogram[jif]);
53729 }
53730
53731 #else
53732 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
53733 index 25badd1..d70d918 100644
53734 --- a/fs/cachefiles/namei.c
53735 +++ b/fs/cachefiles/namei.c
53736 @@ -317,7 +317,7 @@ try_again:
53737 /* first step is to make up a grave dentry in the graveyard */
53738 sprintf(nbuffer, "%08x%08x",
53739 (uint32_t) get_seconds(),
53740 - (uint32_t) atomic_inc_return(&cache->gravecounter));
53741 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
53742
53743 /* do the multiway lock magic */
53744 trap = lock_rename(cache->graveyard, dir);
53745 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
53746 index eccd339..4c1d995 100644
53747 --- a/fs/cachefiles/proc.c
53748 +++ b/fs/cachefiles/proc.c
53749 @@ -14,9 +14,9 @@
53750 #include <linux/seq_file.h>
53751 #include "internal.h"
53752
53753 -atomic_t cachefiles_lookup_histogram[HZ];
53754 -atomic_t cachefiles_mkdir_histogram[HZ];
53755 -atomic_t cachefiles_create_histogram[HZ];
53756 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
53757 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
53758 +atomic_unchecked_t cachefiles_create_histogram[HZ];
53759
53760 /*
53761 * display the latency histogram
53762 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
53763 return 0;
53764 default:
53765 index = (unsigned long) v - 3;
53766 - x = atomic_read(&cachefiles_lookup_histogram[index]);
53767 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
53768 - z = atomic_read(&cachefiles_create_histogram[index]);
53769 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
53770 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
53771 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
53772 if (x == 0 && y == 0 && z == 0)
53773 return 0;
53774
53775 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
53776 index ebaff36..7e3ea26 100644
53777 --- a/fs/cachefiles/rdwr.c
53778 +++ b/fs/cachefiles/rdwr.c
53779 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
53780 old_fs = get_fs();
53781 set_fs(KERNEL_DS);
53782 ret = file->f_op->write(
53783 - file, (const void __user *) data, len, &pos);
53784 + file, (const void __force_user *) data, len, &pos);
53785 set_fs(old_fs);
53786 kunmap(page);
53787 file_end_write(file);
53788 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
53789 index a40ceda..f43d17c 100644
53790 --- a/fs/ceph/dir.c
53791 +++ b/fs/ceph/dir.c
53792 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
53793 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
53794 struct ceph_mds_client *mdsc = fsc->mdsc;
53795 unsigned frag = fpos_frag(ctx->pos);
53796 - int off = fpos_off(ctx->pos);
53797 + unsigned int off = fpos_off(ctx->pos);
53798 int err;
53799 u32 ftype;
53800 struct ceph_mds_reply_info_parsed *rinfo;
53801 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
53802 index 6627b26..634ec4b 100644
53803 --- a/fs/ceph/super.c
53804 +++ b/fs/ceph/super.c
53805 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
53806 /*
53807 * construct our own bdi so we can control readahead, etc.
53808 */
53809 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
53810 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
53811
53812 static int ceph_register_bdi(struct super_block *sb,
53813 struct ceph_fs_client *fsc)
53814 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
53815 default_backing_dev_info.ra_pages;
53816
53817 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
53818 - atomic_long_inc_return(&bdi_seq));
53819 + atomic_long_inc_return_unchecked(&bdi_seq));
53820 if (!err)
53821 sb->s_bdi = &fsc->backing_dev_info;
53822 return err;
53823 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
53824 index f3ac415..3d2420c 100644
53825 --- a/fs/cifs/cifs_debug.c
53826 +++ b/fs/cifs/cifs_debug.c
53827 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53828
53829 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
53830 #ifdef CONFIG_CIFS_STATS2
53831 - atomic_set(&totBufAllocCount, 0);
53832 - atomic_set(&totSmBufAllocCount, 0);
53833 + atomic_set_unchecked(&totBufAllocCount, 0);
53834 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53835 #endif /* CONFIG_CIFS_STATS2 */
53836 spin_lock(&cifs_tcp_ses_lock);
53837 list_for_each(tmp1, &cifs_tcp_ses_list) {
53838 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
53839 tcon = list_entry(tmp3,
53840 struct cifs_tcon,
53841 tcon_list);
53842 - atomic_set(&tcon->num_smbs_sent, 0);
53843 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
53844 if (server->ops->clear_stats)
53845 server->ops->clear_stats(tcon);
53846 }
53847 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53848 smBufAllocCount.counter, cifs_min_small);
53849 #ifdef CONFIG_CIFS_STATS2
53850 seq_printf(m, "Total Large %d Small %d Allocations\n",
53851 - atomic_read(&totBufAllocCount),
53852 - atomic_read(&totSmBufAllocCount));
53853 + atomic_read_unchecked(&totBufAllocCount),
53854 + atomic_read_unchecked(&totSmBufAllocCount));
53855 #endif /* CONFIG_CIFS_STATS2 */
53856
53857 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
53858 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
53859 if (tcon->need_reconnect)
53860 seq_puts(m, "\tDISCONNECTED ");
53861 seq_printf(m, "\nSMBs: %d",
53862 - atomic_read(&tcon->num_smbs_sent));
53863 + atomic_read_unchecked(&tcon->num_smbs_sent));
53864 if (server->ops->print_stats)
53865 server->ops->print_stats(m, tcon);
53866 }
53867 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
53868 index 85ea98d..1eee040 100644
53869 --- a/fs/cifs/cifsfs.c
53870 +++ b/fs/cifs/cifsfs.c
53871 @@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb)
53872 {
53873 struct inode *inode;
53874 struct cifs_sb_info *cifs_sb;
53875 + struct cifs_tcon *tcon;
53876 int rc = 0;
53877
53878 cifs_sb = CIFS_SB(sb);
53879 + tcon = cifs_sb_master_tcon(cifs_sb);
53880
53881 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
53882 sb->s_flags |= MS_POSIXACL;
53883
53884 - if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES)
53885 + if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)
53886 sb->s_maxbytes = MAX_LFS_FILESIZE;
53887 else
53888 sb->s_maxbytes = MAX_NON_LFS;
53889 @@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb)
53890 goto out_no_root;
53891 }
53892
53893 - if (cifs_sb_master_tcon(cifs_sb)->nocase)
53894 + if (tcon->nocase)
53895 sb->s_d_op = &cifs_ci_dentry_ops;
53896 else
53897 sb->s_d_op = &cifs_dentry_ops;
53898 @@ -1037,7 +1039,7 @@ cifs_init_request_bufs(void)
53899 */
53900 cifs_req_cachep = kmem_cache_create("cifs_request",
53901 CIFSMaxBufSize + max_hdr_size, 0,
53902 - SLAB_HWCACHE_ALIGN, NULL);
53903 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
53904 if (cifs_req_cachep == NULL)
53905 return -ENOMEM;
53906
53907 @@ -1064,7 +1066,7 @@ cifs_init_request_bufs(void)
53908 efficient to alloc 1 per page off the slab compared to 17K (5page)
53909 alloc of large cifs buffers even when page debugging is on */
53910 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
53911 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
53912 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
53913 NULL);
53914 if (cifs_sm_req_cachep == NULL) {
53915 mempool_destroy(cifs_req_poolp);
53916 @@ -1149,8 +1151,8 @@ init_cifs(void)
53917 atomic_set(&bufAllocCount, 0);
53918 atomic_set(&smBufAllocCount, 0);
53919 #ifdef CONFIG_CIFS_STATS2
53920 - atomic_set(&totBufAllocCount, 0);
53921 - atomic_set(&totSmBufAllocCount, 0);
53922 + atomic_set_unchecked(&totBufAllocCount, 0);
53923 + atomic_set_unchecked(&totSmBufAllocCount, 0);
53924 #endif /* CONFIG_CIFS_STATS2 */
53925
53926 atomic_set(&midCount, 0);
53927 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
53928 index 52ca861..47f309c 100644
53929 --- a/fs/cifs/cifsglob.h
53930 +++ b/fs/cifs/cifsglob.h
53931 @@ -756,35 +756,35 @@ struct cifs_tcon {
53932 __u16 Flags; /* optional support bits */
53933 enum statusEnum tidStatus;
53934 #ifdef CONFIG_CIFS_STATS
53935 - atomic_t num_smbs_sent;
53936 + atomic_unchecked_t num_smbs_sent;
53937 union {
53938 struct {
53939 - atomic_t num_writes;
53940 - atomic_t num_reads;
53941 - atomic_t num_flushes;
53942 - atomic_t num_oplock_brks;
53943 - atomic_t num_opens;
53944 - atomic_t num_closes;
53945 - atomic_t num_deletes;
53946 - atomic_t num_mkdirs;
53947 - atomic_t num_posixopens;
53948 - atomic_t num_posixmkdirs;
53949 - atomic_t num_rmdirs;
53950 - atomic_t num_renames;
53951 - atomic_t num_t2renames;
53952 - atomic_t num_ffirst;
53953 - atomic_t num_fnext;
53954 - atomic_t num_fclose;
53955 - atomic_t num_hardlinks;
53956 - atomic_t num_symlinks;
53957 - atomic_t num_locks;
53958 - atomic_t num_acl_get;
53959 - atomic_t num_acl_set;
53960 + atomic_unchecked_t num_writes;
53961 + atomic_unchecked_t num_reads;
53962 + atomic_unchecked_t num_flushes;
53963 + atomic_unchecked_t num_oplock_brks;
53964 + atomic_unchecked_t num_opens;
53965 + atomic_unchecked_t num_closes;
53966 + atomic_unchecked_t num_deletes;
53967 + atomic_unchecked_t num_mkdirs;
53968 + atomic_unchecked_t num_posixopens;
53969 + atomic_unchecked_t num_posixmkdirs;
53970 + atomic_unchecked_t num_rmdirs;
53971 + atomic_unchecked_t num_renames;
53972 + atomic_unchecked_t num_t2renames;
53973 + atomic_unchecked_t num_ffirst;
53974 + atomic_unchecked_t num_fnext;
53975 + atomic_unchecked_t num_fclose;
53976 + atomic_unchecked_t num_hardlinks;
53977 + atomic_unchecked_t num_symlinks;
53978 + atomic_unchecked_t num_locks;
53979 + atomic_unchecked_t num_acl_get;
53980 + atomic_unchecked_t num_acl_set;
53981 } cifs_stats;
53982 #ifdef CONFIG_CIFS_SMB2
53983 struct {
53984 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53985 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53986 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
53987 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
53988 } smb2_stats;
53989 #endif /* CONFIG_CIFS_SMB2 */
53990 } stats;
53991 @@ -1096,7 +1096,7 @@ convert_delimiter(char *path, char delim)
53992 }
53993
53994 #ifdef CONFIG_CIFS_STATS
53995 -#define cifs_stats_inc atomic_inc
53996 +#define cifs_stats_inc atomic_inc_unchecked
53997
53998 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
53999 unsigned int bytes)
54000 @@ -1461,8 +1461,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
54001 /* Various Debug counters */
54002 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
54003 #ifdef CONFIG_CIFS_STATS2
54004 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
54005 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
54006 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
54007 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
54008 #endif
54009 GLOBAL_EXTERN atomic_t smBufAllocCount;
54010 GLOBAL_EXTERN atomic_t midCount;
54011 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
54012 index 562044f..4af6a17 100644
54013 --- a/fs/cifs/link.c
54014 +++ b/fs/cifs/link.c
54015 @@ -638,7 +638,7 @@ symlink_exit:
54016
54017 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
54018 {
54019 - char *p = nd_get_link(nd);
54020 + const char *p = nd_get_link(nd);
54021 if (!IS_ERR(p))
54022 kfree(p);
54023 }
54024 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
54025 index f7d4b22..1254377 100644
54026 --- a/fs/cifs/misc.c
54027 +++ b/fs/cifs/misc.c
54028 @@ -169,7 +169,7 @@ cifs_buf_get(void)
54029 memset(ret_buf, 0, buf_size + 3);
54030 atomic_inc(&bufAllocCount);
54031 #ifdef CONFIG_CIFS_STATS2
54032 - atomic_inc(&totBufAllocCount);
54033 + atomic_inc_unchecked(&totBufAllocCount);
54034 #endif /* CONFIG_CIFS_STATS2 */
54035 }
54036
54037 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
54038 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
54039 atomic_inc(&smBufAllocCount);
54040 #ifdef CONFIG_CIFS_STATS2
54041 - atomic_inc(&totSmBufAllocCount);
54042 + atomic_inc_unchecked(&totSmBufAllocCount);
54043 #endif /* CONFIG_CIFS_STATS2 */
54044
54045 }
54046 diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
54047 index af847e1..651a527 100644
54048 --- a/fs/cifs/netmisc.c
54049 +++ b/fs/cifs/netmisc.c
54050 @@ -780,7 +780,9 @@ static const struct {
54051 ERRDOS, ERRnoaccess, 0xc0000290}, {
54052 ERRDOS, ERRbadfunc, 0xc000029c}, {
54053 ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
54054 - ERRDOS, ERRinvlevel, 0x007c0001}, };
54055 + ERRDOS, ERRinvlevel, 0x007c0001}, {
54056 + 0, 0, 0 }
54057 +};
54058
54059 /*****************************************************************************
54060 Print an error message from the status code
54061 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
54062 index 6094397..51e576f 100644
54063 --- a/fs/cifs/smb1ops.c
54064 +++ b/fs/cifs/smb1ops.c
54065 @@ -590,27 +590,27 @@ static void
54066 cifs_clear_stats(struct cifs_tcon *tcon)
54067 {
54068 #ifdef CONFIG_CIFS_STATS
54069 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
54070 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
54071 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
54072 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54073 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
54074 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
54075 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54076 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
54077 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
54078 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
54079 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
54080 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
54081 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
54082 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
54083 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
54084 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
54085 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
54086 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
54087 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
54088 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
54089 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
54090 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
54091 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
54092 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
54093 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
54094 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
54095 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
54096 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
54097 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
54098 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
54099 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
54100 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
54101 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
54102 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
54103 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
54104 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
54105 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
54106 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
54107 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
54108 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
54109 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
54110 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
54111 #endif
54112 }
54113
54114 @@ -619,36 +619,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54115 {
54116 #ifdef CONFIG_CIFS_STATS
54117 seq_printf(m, " Oplocks breaks: %d",
54118 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
54119 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
54120 seq_printf(m, "\nReads: %d Bytes: %llu",
54121 - atomic_read(&tcon->stats.cifs_stats.num_reads),
54122 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
54123 (long long)(tcon->bytes_read));
54124 seq_printf(m, "\nWrites: %d Bytes: %llu",
54125 - atomic_read(&tcon->stats.cifs_stats.num_writes),
54126 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
54127 (long long)(tcon->bytes_written));
54128 seq_printf(m, "\nFlushes: %d",
54129 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
54130 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
54131 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
54132 - atomic_read(&tcon->stats.cifs_stats.num_locks),
54133 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
54134 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
54135 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
54136 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
54137 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
54138 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
54139 - atomic_read(&tcon->stats.cifs_stats.num_opens),
54140 - atomic_read(&tcon->stats.cifs_stats.num_closes),
54141 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
54142 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
54143 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
54144 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
54145 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
54146 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
54147 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
54148 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
54149 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
54150 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
54151 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
54152 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
54153 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
54154 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
54155 seq_printf(m, "\nRenames: %d T2 Renames %d",
54156 - atomic_read(&tcon->stats.cifs_stats.num_renames),
54157 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
54158 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
54159 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
54160 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
54161 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
54162 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
54163 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
54164 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
54165 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
54166 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
54167 #endif
54168 }
54169
54170 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
54171 index f259e6c..ca948ff 100644
54172 --- a/fs/cifs/smb2ops.c
54173 +++ b/fs/cifs/smb2ops.c
54174 @@ -281,8 +281,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
54175 #ifdef CONFIG_CIFS_STATS
54176 int i;
54177 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
54178 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54179 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54180 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
54181 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
54182 }
54183 #endif
54184 }
54185 @@ -310,65 +310,65 @@ static void
54186 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
54187 {
54188 #ifdef CONFIG_CIFS_STATS
54189 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54190 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54191 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
54192 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
54193 seq_printf(m, "\nNegotiates: %d sent %d failed",
54194 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
54195 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
54196 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
54197 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
54198 seq_printf(m, "\nSessionSetups: %d sent %d failed",
54199 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
54200 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
54201 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
54202 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
54203 seq_printf(m, "\nLogoffs: %d sent %d failed",
54204 - atomic_read(&sent[SMB2_LOGOFF_HE]),
54205 - atomic_read(&failed[SMB2_LOGOFF_HE]));
54206 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
54207 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
54208 seq_printf(m, "\nTreeConnects: %d sent %d failed",
54209 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
54210 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
54211 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
54212 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
54213 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
54214 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
54215 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
54216 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
54217 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
54218 seq_printf(m, "\nCreates: %d sent %d failed",
54219 - atomic_read(&sent[SMB2_CREATE_HE]),
54220 - atomic_read(&failed[SMB2_CREATE_HE]));
54221 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
54222 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
54223 seq_printf(m, "\nCloses: %d sent %d failed",
54224 - atomic_read(&sent[SMB2_CLOSE_HE]),
54225 - atomic_read(&failed[SMB2_CLOSE_HE]));
54226 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
54227 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
54228 seq_printf(m, "\nFlushes: %d sent %d failed",
54229 - atomic_read(&sent[SMB2_FLUSH_HE]),
54230 - atomic_read(&failed[SMB2_FLUSH_HE]));
54231 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
54232 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
54233 seq_printf(m, "\nReads: %d sent %d failed",
54234 - atomic_read(&sent[SMB2_READ_HE]),
54235 - atomic_read(&failed[SMB2_READ_HE]));
54236 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
54237 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
54238 seq_printf(m, "\nWrites: %d sent %d failed",
54239 - atomic_read(&sent[SMB2_WRITE_HE]),
54240 - atomic_read(&failed[SMB2_WRITE_HE]));
54241 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
54242 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
54243 seq_printf(m, "\nLocks: %d sent %d failed",
54244 - atomic_read(&sent[SMB2_LOCK_HE]),
54245 - atomic_read(&failed[SMB2_LOCK_HE]));
54246 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
54247 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
54248 seq_printf(m, "\nIOCTLs: %d sent %d failed",
54249 - atomic_read(&sent[SMB2_IOCTL_HE]),
54250 - atomic_read(&failed[SMB2_IOCTL_HE]));
54251 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
54252 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
54253 seq_printf(m, "\nCancels: %d sent %d failed",
54254 - atomic_read(&sent[SMB2_CANCEL_HE]),
54255 - atomic_read(&failed[SMB2_CANCEL_HE]));
54256 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
54257 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
54258 seq_printf(m, "\nEchos: %d sent %d failed",
54259 - atomic_read(&sent[SMB2_ECHO_HE]),
54260 - atomic_read(&failed[SMB2_ECHO_HE]));
54261 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
54262 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
54263 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
54264 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
54265 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
54266 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
54267 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
54268 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
54269 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
54270 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
54271 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
54272 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
54273 seq_printf(m, "\nQueryInfos: %d sent %d failed",
54274 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
54275 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
54276 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
54277 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
54278 seq_printf(m, "\nSetInfos: %d sent %d failed",
54279 - atomic_read(&sent[SMB2_SET_INFO_HE]),
54280 - atomic_read(&failed[SMB2_SET_INFO_HE]));
54281 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
54282 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
54283 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
54284 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
54285 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
54286 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
54287 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
54288 #endif
54289 }
54290
54291 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
54292 index abc9c28..3fdae28 100644
54293 --- a/fs/cifs/smb2pdu.c
54294 +++ b/fs/cifs/smb2pdu.c
54295 @@ -1946,8 +1946,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
54296 default:
54297 cifs_dbg(VFS, "info level %u isn't supported\n",
54298 srch_inf->info_level);
54299 - rc = -EINVAL;
54300 - goto qdir_exit;
54301 + return -EINVAL;
54302 }
54303
54304 req->FileIndex = cpu_to_le32(index);
54305 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
54306 index 1da168c..8bc7ff6 100644
54307 --- a/fs/coda/cache.c
54308 +++ b/fs/coda/cache.c
54309 @@ -24,7 +24,7 @@
54310 #include "coda_linux.h"
54311 #include "coda_cache.h"
54312
54313 -static atomic_t permission_epoch = ATOMIC_INIT(0);
54314 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
54315
54316 /* replace or extend an acl cache hit */
54317 void coda_cache_enter(struct inode *inode, int mask)
54318 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
54319 struct coda_inode_info *cii = ITOC(inode);
54320
54321 spin_lock(&cii->c_lock);
54322 - cii->c_cached_epoch = atomic_read(&permission_epoch);
54323 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
54324 if (!uid_eq(cii->c_uid, current_fsuid())) {
54325 cii->c_uid = current_fsuid();
54326 cii->c_cached_perm = mask;
54327 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
54328 {
54329 struct coda_inode_info *cii = ITOC(inode);
54330 spin_lock(&cii->c_lock);
54331 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
54332 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
54333 spin_unlock(&cii->c_lock);
54334 }
54335
54336 /* remove all acl caches */
54337 void coda_cache_clear_all(struct super_block *sb)
54338 {
54339 - atomic_inc(&permission_epoch);
54340 + atomic_inc_unchecked(&permission_epoch);
54341 }
54342
54343
54344 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
54345 spin_lock(&cii->c_lock);
54346 hit = (mask & cii->c_cached_perm) == mask &&
54347 uid_eq(cii->c_uid, current_fsuid()) &&
54348 - cii->c_cached_epoch == atomic_read(&permission_epoch);
54349 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
54350 spin_unlock(&cii->c_lock);
54351
54352 return hit;
54353 diff --git a/fs/compat.c b/fs/compat.c
54354 index 6af20de..fec3fbb 100644
54355 --- a/fs/compat.c
54356 +++ b/fs/compat.c
54357 @@ -54,7 +54,7 @@
54358 #include <asm/ioctls.h>
54359 #include "internal.h"
54360
54361 -int compat_log = 1;
54362 +int compat_log = 0;
54363
54364 int compat_printk(const char *fmt, ...)
54365 {
54366 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
54367
54368 set_fs(KERNEL_DS);
54369 /* The __user pointer cast is valid because of the set_fs() */
54370 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
54371 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
54372 set_fs(oldfs);
54373 /* truncating is ok because it's a user address */
54374 if (!ret)
54375 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
54376 goto out;
54377
54378 ret = -EINVAL;
54379 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
54380 + if (nr_segs > UIO_MAXIOV)
54381 goto out;
54382 if (nr_segs > fast_segs) {
54383 ret = -ENOMEM;
54384 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
54385 struct compat_readdir_callback {
54386 struct dir_context ctx;
54387 struct compat_old_linux_dirent __user *dirent;
54388 + struct file * file;
54389 int result;
54390 };
54391
54392 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
54393 buf->result = -EOVERFLOW;
54394 return -EOVERFLOW;
54395 }
54396 +
54397 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54398 + return 0;
54399 +
54400 buf->result++;
54401 dirent = buf->dirent;
54402 if (!access_ok(VERIFY_WRITE, dirent,
54403 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
54404 if (!f.file)
54405 return -EBADF;
54406
54407 + buf.file = f.file;
54408 error = iterate_dir(f.file, &buf.ctx);
54409 if (buf.result)
54410 error = buf.result;
54411 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
54412 struct dir_context ctx;
54413 struct compat_linux_dirent __user *current_dir;
54414 struct compat_linux_dirent __user *previous;
54415 + struct file * file;
54416 int count;
54417 int error;
54418 };
54419 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
54420 buf->error = -EOVERFLOW;
54421 return -EOVERFLOW;
54422 }
54423 +
54424 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54425 + return 0;
54426 +
54427 dirent = buf->previous;
54428 if (dirent) {
54429 if (__put_user(offset, &dirent->d_off))
54430 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
54431 if (!f.file)
54432 return -EBADF;
54433
54434 + buf.file = f.file;
54435 error = iterate_dir(f.file, &buf.ctx);
54436 if (error >= 0)
54437 error = buf.error;
54438 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
54439 struct dir_context ctx;
54440 struct linux_dirent64 __user *current_dir;
54441 struct linux_dirent64 __user *previous;
54442 + struct file * file;
54443 int count;
54444 int error;
54445 };
54446 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
54447 buf->error = -EINVAL; /* only used if we fail.. */
54448 if (reclen > buf->count)
54449 return -EINVAL;
54450 +
54451 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
54452 + return 0;
54453 +
54454 dirent = buf->previous;
54455
54456 if (dirent) {
54457 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
54458 if (!f.file)
54459 return -EBADF;
54460
54461 + buf.file = f.file;
54462 error = iterate_dir(f.file, &buf.ctx);
54463 if (error >= 0)
54464 error = buf.error;
54465 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
54466 index a81147e..20bf2b5 100644
54467 --- a/fs/compat_binfmt_elf.c
54468 +++ b/fs/compat_binfmt_elf.c
54469 @@ -30,11 +30,13 @@
54470 #undef elf_phdr
54471 #undef elf_shdr
54472 #undef elf_note
54473 +#undef elf_dyn
54474 #undef elf_addr_t
54475 #define elfhdr elf32_hdr
54476 #define elf_phdr elf32_phdr
54477 #define elf_shdr elf32_shdr
54478 #define elf_note elf32_note
54479 +#define elf_dyn Elf32_Dyn
54480 #define elf_addr_t Elf32_Addr
54481
54482 /*
54483 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
54484 index 5d19acf..9ab093b 100644
54485 --- a/fs/compat_ioctl.c
54486 +++ b/fs/compat_ioctl.c
54487 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
54488 return -EFAULT;
54489 if (__get_user(udata, &ss32->iomem_base))
54490 return -EFAULT;
54491 - ss.iomem_base = compat_ptr(udata);
54492 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
54493 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
54494 __get_user(ss.port_high, &ss32->port_high))
54495 return -EFAULT;
54496 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
54497 for (i = 0; i < nmsgs; i++) {
54498 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
54499 return -EFAULT;
54500 - if (get_user(datap, &umsgs[i].buf) ||
54501 - put_user(compat_ptr(datap), &tmsgs[i].buf))
54502 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
54503 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
54504 return -EFAULT;
54505 }
54506 return sys_ioctl(fd, cmd, (unsigned long)tdata);
54507 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
54508 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
54509 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
54510 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
54511 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54512 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
54513 return -EFAULT;
54514
54515 return ioctl_preallocate(file, p);
54516 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
54517 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
54518 {
54519 unsigned int a, b;
54520 - a = *(unsigned int *)p;
54521 - b = *(unsigned int *)q;
54522 + a = *(const unsigned int *)p;
54523 + b = *(const unsigned int *)q;
54524 if (a > b)
54525 return 1;
54526 if (a < b)
54527 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
54528 index 277bd1b..f312c9e 100644
54529 --- a/fs/configfs/dir.c
54530 +++ b/fs/configfs/dir.c
54531 @@ -1546,7 +1546,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54532 }
54533 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
54534 struct configfs_dirent *next;
54535 - const char *name;
54536 + const unsigned char * name;
54537 + char d_name[sizeof(next->s_dentry->d_iname)];
54538 int len;
54539 struct inode *inode = NULL;
54540
54541 @@ -1555,7 +1556,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
54542 continue;
54543
54544 name = configfs_get_name(next);
54545 - len = strlen(name);
54546 + if (next->s_dentry && name == next->s_dentry->d_iname) {
54547 + len = next->s_dentry->d_name.len;
54548 + memcpy(d_name, name, len);
54549 + name = d_name;
54550 + } else
54551 + len = strlen(name);
54552
54553 /*
54554 * We'll have a dentry and an inode for
54555 diff --git a/fs/coredump.c b/fs/coredump.c
54556 index 72f816d..1ba8eff 100644
54557 --- a/fs/coredump.c
54558 +++ b/fs/coredump.c
54559 @@ -433,8 +433,8 @@ static void wait_for_dump_helpers(struct file *file)
54560 struct pipe_inode_info *pipe = file->private_data;
54561
54562 pipe_lock(pipe);
54563 - pipe->readers++;
54564 - pipe->writers--;
54565 + atomic_inc(&pipe->readers);
54566 + atomic_dec(&pipe->writers);
54567 wake_up_interruptible_sync(&pipe->wait);
54568 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54569 pipe_unlock(pipe);
54570 @@ -443,11 +443,11 @@ static void wait_for_dump_helpers(struct file *file)
54571 * We actually want wait_event_freezable() but then we need
54572 * to clear TIF_SIGPENDING and improve dump_interrupted().
54573 */
54574 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
54575 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
54576
54577 pipe_lock(pipe);
54578 - pipe->readers--;
54579 - pipe->writers++;
54580 + atomic_dec(&pipe->readers);
54581 + atomic_inc(&pipe->writers);
54582 pipe_unlock(pipe);
54583 }
54584
54585 @@ -494,7 +494,8 @@ void do_coredump(siginfo_t *siginfo)
54586 struct files_struct *displaced;
54587 bool need_nonrelative = false;
54588 bool core_dumped = false;
54589 - static atomic_t core_dump_count = ATOMIC_INIT(0);
54590 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
54591 + long signr = siginfo->si_signo;
54592 struct coredump_params cprm = {
54593 .siginfo = siginfo,
54594 .regs = signal_pt_regs(),
54595 @@ -507,7 +508,10 @@ void do_coredump(siginfo_t *siginfo)
54596 .mm_flags = mm->flags,
54597 };
54598
54599 - audit_core_dumps(siginfo->si_signo);
54600 + audit_core_dumps(signr);
54601 +
54602 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
54603 + gr_handle_brute_attach(cprm.mm_flags);
54604
54605 binfmt = mm->binfmt;
54606 if (!binfmt || !binfmt->core_dump)
54607 @@ -531,7 +535,7 @@ void do_coredump(siginfo_t *siginfo)
54608 need_nonrelative = true;
54609 }
54610
54611 - retval = coredump_wait(siginfo->si_signo, &core_state);
54612 + retval = coredump_wait(signr, &core_state);
54613 if (retval < 0)
54614 goto fail_creds;
54615
54616 @@ -574,7 +578,7 @@ void do_coredump(siginfo_t *siginfo)
54617 }
54618 cprm.limit = RLIM_INFINITY;
54619
54620 - dump_count = atomic_inc_return(&core_dump_count);
54621 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
54622 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
54623 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
54624 task_tgid_vnr(current), current->comm);
54625 @@ -606,6 +610,8 @@ void do_coredump(siginfo_t *siginfo)
54626 } else {
54627 struct inode *inode;
54628
54629 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
54630 +
54631 if (cprm.limit < binfmt->min_coredump)
54632 goto fail_unlock;
54633
54634 @@ -664,7 +670,7 @@ close_fail:
54635 filp_close(cprm.file, NULL);
54636 fail_dropcount:
54637 if (ispipe)
54638 - atomic_dec(&core_dump_count);
54639 + atomic_dec_unchecked(&core_dump_count);
54640 fail_unlock:
54641 kfree(cn.corename);
54642 coredump_finish(mm, core_dumped);
54643 @@ -684,7 +690,7 @@ int dump_write(struct file *file, const void *addr, int nr)
54644 {
54645 return !dump_interrupted() &&
54646 access_ok(VERIFY_READ, addr, nr) &&
54647 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
54648 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
54649 }
54650 EXPORT_SYMBOL(dump_write);
54651
54652 diff --git a/fs/dcache.c b/fs/dcache.c
54653 index b949af8..5978926 100644
54654 --- a/fs/dcache.c
54655 +++ b/fs/dcache.c
54656 @@ -3073,7 +3073,8 @@ void __init vfs_caches_init(unsigned long mempages)
54657 mempages -= reserve;
54658
54659 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
54660 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
54661 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
54662 + SLAB_NO_SANITIZE, NULL);
54663
54664 dcache_init();
54665 inode_init();
54666 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
54667 index c7c83ff..bda9461 100644
54668 --- a/fs/debugfs/inode.c
54669 +++ b/fs/debugfs/inode.c
54670 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
54671 */
54672 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
54673 {
54674 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
54675 + return __create_file(name, S_IFDIR | S_IRWXU,
54676 +#else
54677 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
54678 +#endif
54679 parent, NULL, NULL);
54680 }
54681 EXPORT_SYMBOL_GPL(debugfs_create_dir);
54682 diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
54683 index d107576..40db688 100644
54684 --- a/fs/ecryptfs/crypto.c
54685 +++ b/fs/ecryptfs/crypto.c
54686 @@ -408,7 +408,7 @@ static loff_t lower_offset_for_page(struct ecryptfs_crypt_stat *crypt_stat,
54687 struct page *page)
54688 {
54689 return ecryptfs_lower_header_size(crypt_stat) +
54690 - (page->index << PAGE_CACHE_SHIFT);
54691 + ((loff_t)page->index << PAGE_CACHE_SHIFT);
54692 }
54693
54694 /**
54695 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
54696 index 67e9b63..a9adb68 100644
54697 --- a/fs/ecryptfs/inode.c
54698 +++ b/fs/ecryptfs/inode.c
54699 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
54700 old_fs = get_fs();
54701 set_fs(get_ds());
54702 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
54703 - (char __user *)lower_buf,
54704 + (char __force_user *)lower_buf,
54705 PATH_MAX);
54706 set_fs(old_fs);
54707 if (rc < 0)
54708 @@ -706,7 +706,7 @@ out:
54709 static void
54710 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
54711 {
54712 - char *buf = nd_get_link(nd);
54713 + const char *buf = nd_get_link(nd);
54714 if (!IS_ERR(buf)) {
54715 /* Free the char* */
54716 kfree(buf);
54717 diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
54718 index 7d52806..4725a07 100644
54719 --- a/fs/ecryptfs/keystore.c
54720 +++ b/fs/ecryptfs/keystore.c
54721 @@ -1149,7 +1149,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
54722 struct ecryptfs_msg_ctx *msg_ctx;
54723 struct ecryptfs_message *msg = NULL;
54724 char *auth_tok_sig;
54725 - char *payload;
54726 + char *payload = NULL;
54727 size_t payload_len = 0;
54728 int rc;
54729
54730 @@ -1203,6 +1203,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
54731 }
54732 out:
54733 kfree(msg);
54734 + kfree(payload);
54735 return rc;
54736 }
54737
54738 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
54739 index e4141f2..d8263e8 100644
54740 --- a/fs/ecryptfs/miscdev.c
54741 +++ b/fs/ecryptfs/miscdev.c
54742 @@ -304,7 +304,7 @@ check_list:
54743 goto out_unlock_msg_ctx;
54744 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
54745 if (msg_ctx->msg) {
54746 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
54747 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
54748 goto out_unlock_msg_ctx;
54749 i += packet_length_size;
54750 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
54751 diff --git a/fs/exec.c b/fs/exec.c
54752 index fd774c7..1c6a7bf 100644
54753 --- a/fs/exec.c
54754 +++ b/fs/exec.c
54755 @@ -55,8 +55,20 @@
54756 #include <linux/pipe_fs_i.h>
54757 #include <linux/oom.h>
54758 #include <linux/compat.h>
54759 +#include <linux/random.h>
54760 +#include <linux/seq_file.h>
54761 +#include <linux/coredump.h>
54762 +#include <linux/mman.h>
54763 +
54764 +#ifdef CONFIG_PAX_REFCOUNT
54765 +#include <linux/kallsyms.h>
54766 +#include <linux/kdebug.h>
54767 +#endif
54768 +
54769 +#include <trace/events/fs.h>
54770
54771 #include <asm/uaccess.h>
54772 +#include <asm/sections.h>
54773 #include <asm/mmu_context.h>
54774 #include <asm/tlb.h>
54775
54776 @@ -66,17 +78,32 @@
54777
54778 #include <trace/events/sched.h>
54779
54780 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54781 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
54782 +{
54783 + 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");
54784 +}
54785 +#endif
54786 +
54787 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
54788 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
54789 +EXPORT_SYMBOL(pax_set_initial_flags_func);
54790 +#endif
54791 +
54792 int suid_dumpable = 0;
54793
54794 static LIST_HEAD(formats);
54795 static DEFINE_RWLOCK(binfmt_lock);
54796
54797 +extern int gr_process_kernel_exec_ban(void);
54798 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
54799 +
54800 void __register_binfmt(struct linux_binfmt * fmt, int insert)
54801 {
54802 BUG_ON(!fmt);
54803 write_lock(&binfmt_lock);
54804 - insert ? list_add(&fmt->lh, &formats) :
54805 - list_add_tail(&fmt->lh, &formats);
54806 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
54807 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
54808 write_unlock(&binfmt_lock);
54809 }
54810
54811 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
54812 void unregister_binfmt(struct linux_binfmt * fmt)
54813 {
54814 write_lock(&binfmt_lock);
54815 - list_del(&fmt->lh);
54816 + pax_list_del((struct list_head *)&fmt->lh);
54817 write_unlock(&binfmt_lock);
54818 }
54819
54820 @@ -181,18 +208,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54821 int write)
54822 {
54823 struct page *page;
54824 - int ret;
54825
54826 -#ifdef CONFIG_STACK_GROWSUP
54827 - if (write) {
54828 - ret = expand_downwards(bprm->vma, pos);
54829 - if (ret < 0)
54830 - return NULL;
54831 - }
54832 -#endif
54833 - ret = get_user_pages(current, bprm->mm, pos,
54834 - 1, write, 1, &page, NULL);
54835 - if (ret <= 0)
54836 + if (0 > expand_downwards(bprm->vma, pos))
54837 + return NULL;
54838 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
54839 return NULL;
54840
54841 if (write) {
54842 @@ -208,6 +227,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
54843 if (size <= ARG_MAX)
54844 return page;
54845
54846 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54847 + // only allow 512KB for argv+env on suid/sgid binaries
54848 + // to prevent easy ASLR exhaustion
54849 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
54850 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
54851 + (size > (512 * 1024))) {
54852 + put_page(page);
54853 + return NULL;
54854 + }
54855 +#endif
54856 +
54857 /*
54858 * Limit to 1/4-th the stack size for the argv+env strings.
54859 * This ensures that:
54860 @@ -267,6 +297,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54861 vma->vm_end = STACK_TOP_MAX;
54862 vma->vm_start = vma->vm_end - PAGE_SIZE;
54863 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
54864 +
54865 +#ifdef CONFIG_PAX_SEGMEXEC
54866 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
54867 +#endif
54868 +
54869 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
54870 INIT_LIST_HEAD(&vma->anon_vma_chain);
54871
54872 @@ -277,6 +312,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
54873 mm->stack_vm = mm->total_vm = 1;
54874 up_write(&mm->mmap_sem);
54875 bprm->p = vma->vm_end - sizeof(void *);
54876 +
54877 +#ifdef CONFIG_PAX_RANDUSTACK
54878 + if (randomize_va_space)
54879 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
54880 +#endif
54881 +
54882 return 0;
54883 err:
54884 up_write(&mm->mmap_sem);
54885 @@ -397,7 +438,7 @@ struct user_arg_ptr {
54886 } ptr;
54887 };
54888
54889 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54890 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54891 {
54892 const char __user *native;
54893
54894 @@ -406,14 +447,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
54895 compat_uptr_t compat;
54896
54897 if (get_user(compat, argv.ptr.compat + nr))
54898 - return ERR_PTR(-EFAULT);
54899 + return (const char __force_user *)ERR_PTR(-EFAULT);
54900
54901 return compat_ptr(compat);
54902 }
54903 #endif
54904
54905 if (get_user(native, argv.ptr.native + nr))
54906 - return ERR_PTR(-EFAULT);
54907 + return (const char __force_user *)ERR_PTR(-EFAULT);
54908
54909 return native;
54910 }
54911 @@ -432,7 +473,7 @@ static int count(struct user_arg_ptr argv, int max)
54912 if (!p)
54913 break;
54914
54915 - if (IS_ERR(p))
54916 + if (IS_ERR((const char __force_kernel *)p))
54917 return -EFAULT;
54918
54919 if (i >= max)
54920 @@ -467,7 +508,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
54921
54922 ret = -EFAULT;
54923 str = get_user_arg_ptr(argv, argc);
54924 - if (IS_ERR(str))
54925 + if (IS_ERR((const char __force_kernel *)str))
54926 goto out;
54927
54928 len = strnlen_user(str, MAX_ARG_STRLEN);
54929 @@ -549,7 +590,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
54930 int r;
54931 mm_segment_t oldfs = get_fs();
54932 struct user_arg_ptr argv = {
54933 - .ptr.native = (const char __user *const __user *)__argv,
54934 + .ptr.native = (const char __force_user * const __force_user *)__argv,
54935 };
54936
54937 set_fs(KERNEL_DS);
54938 @@ -584,7 +625,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54939 unsigned long new_end = old_end - shift;
54940 struct mmu_gather tlb;
54941
54942 - BUG_ON(new_start > new_end);
54943 + if (new_start >= new_end || new_start < mmap_min_addr)
54944 + return -ENOMEM;
54945
54946 /*
54947 * ensure there are no vmas between where we want to go
54948 @@ -593,6 +635,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
54949 if (vma != find_vma(mm, new_start))
54950 return -EFAULT;
54951
54952 +#ifdef CONFIG_PAX_SEGMEXEC
54953 + BUG_ON(pax_find_mirror_vma(vma));
54954 +#endif
54955 +
54956 /*
54957 * cover the whole range: [new_start, old_end)
54958 */
54959 @@ -673,10 +719,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
54960 stack_top = arch_align_stack(stack_top);
54961 stack_top = PAGE_ALIGN(stack_top);
54962
54963 - if (unlikely(stack_top < mmap_min_addr) ||
54964 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
54965 - return -ENOMEM;
54966 -
54967 stack_shift = vma->vm_end - stack_top;
54968
54969 bprm->p -= stack_shift;
54970 @@ -688,8 +730,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
54971 bprm->exec -= stack_shift;
54972
54973 down_write(&mm->mmap_sem);
54974 +
54975 + /* Move stack pages down in memory. */
54976 + if (stack_shift) {
54977 + ret = shift_arg_pages(vma, stack_shift);
54978 + if (ret)
54979 + goto out_unlock;
54980 + }
54981 +
54982 vm_flags = VM_STACK_FLAGS;
54983
54984 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54985 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54986 + vm_flags &= ~VM_EXEC;
54987 +
54988 +#ifdef CONFIG_PAX_MPROTECT
54989 + if (mm->pax_flags & MF_PAX_MPROTECT)
54990 + vm_flags &= ~VM_MAYEXEC;
54991 +#endif
54992 +
54993 + }
54994 +#endif
54995 +
54996 /*
54997 * Adjust stack execute permissions; explicitly enable for
54998 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
54999 @@ -708,13 +770,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
55000 goto out_unlock;
55001 BUG_ON(prev != vma);
55002
55003 - /* Move stack pages down in memory. */
55004 - if (stack_shift) {
55005 - ret = shift_arg_pages(vma, stack_shift);
55006 - if (ret)
55007 - goto out_unlock;
55008 - }
55009 -
55010 /* mprotect_fixup is overkill to remove the temporary stack flags */
55011 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
55012
55013 @@ -738,6 +793,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
55014 #endif
55015 current->mm->start_stack = bprm->p;
55016 ret = expand_stack(vma, stack_base);
55017 +
55018 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
55019 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
55020 + unsigned long size;
55021 + vm_flags_t vm_flags;
55022 +
55023 + size = STACK_TOP - vma->vm_end;
55024 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
55025 +
55026 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
55027 +
55028 +#ifdef CONFIG_X86
55029 + if (!ret) {
55030 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
55031 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
55032 + }
55033 +#endif
55034 +
55035 + }
55036 +#endif
55037 +
55038 if (ret)
55039 ret = -EFAULT;
55040
55041 @@ -774,6 +850,8 @@ struct file *open_exec(const char *name)
55042
55043 fsnotify_open(file);
55044
55045 + trace_open_exec(name);
55046 +
55047 err = deny_write_access(file);
55048 if (err)
55049 goto exit;
55050 @@ -797,7 +875,7 @@ int kernel_read(struct file *file, loff_t offset,
55051 old_fs = get_fs();
55052 set_fs(get_ds());
55053 /* The cast to a user pointer is valid due to the set_fs() */
55054 - result = vfs_read(file, (void __user *)addr, count, &pos);
55055 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
55056 set_fs(old_fs);
55057 return result;
55058 }
55059 @@ -1253,7 +1331,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
55060 }
55061 rcu_read_unlock();
55062
55063 - if (p->fs->users > n_fs) {
55064 + if (atomic_read(&p->fs->users) > n_fs) {
55065 bprm->unsafe |= LSM_UNSAFE_SHARE;
55066 } else {
55067 res = -EAGAIN;
55068 @@ -1453,6 +1531,31 @@ int search_binary_handler(struct linux_binprm *bprm)
55069
55070 EXPORT_SYMBOL(search_binary_handler);
55071
55072 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55073 +static DEFINE_PER_CPU(u64, exec_counter);
55074 +static int __init init_exec_counters(void)
55075 +{
55076 + unsigned int cpu;
55077 +
55078 + for_each_possible_cpu(cpu) {
55079 + per_cpu(exec_counter, cpu) = (u64)cpu;
55080 + }
55081 +
55082 + return 0;
55083 +}
55084 +early_initcall(init_exec_counters);
55085 +static inline void increment_exec_counter(void)
55086 +{
55087 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
55088 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
55089 +}
55090 +#else
55091 +static inline void increment_exec_counter(void) {}
55092 +#endif
55093 +
55094 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
55095 + struct user_arg_ptr argv);
55096 +
55097 /*
55098 * sys_execve() executes a new program.
55099 */
55100 @@ -1460,12 +1563,19 @@ static int do_execve_common(const char *filename,
55101 struct user_arg_ptr argv,
55102 struct user_arg_ptr envp)
55103 {
55104 +#ifdef CONFIG_GRKERNSEC
55105 + struct file *old_exec_file;
55106 + struct acl_subject_label *old_acl;
55107 + struct rlimit old_rlim[RLIM_NLIMITS];
55108 +#endif
55109 struct linux_binprm *bprm;
55110 struct file *file;
55111 struct files_struct *displaced;
55112 bool clear_in_exec;
55113 int retval;
55114
55115 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
55116 +
55117 /*
55118 * We move the actual failure in case of RLIMIT_NPROC excess from
55119 * set*uid() to execve() because too many poorly written programs
55120 @@ -1506,12 +1616,22 @@ static int do_execve_common(const char *filename,
55121 if (IS_ERR(file))
55122 goto out_unmark;
55123
55124 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
55125 + retval = -EPERM;
55126 + goto out_file;
55127 + }
55128 +
55129 sched_exec();
55130
55131 bprm->file = file;
55132 bprm->filename = filename;
55133 bprm->interp = filename;
55134
55135 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
55136 + retval = -EACCES;
55137 + goto out_file;
55138 + }
55139 +
55140 retval = bprm_mm_init(bprm);
55141 if (retval)
55142 goto out_file;
55143 @@ -1528,24 +1648,70 @@ static int do_execve_common(const char *filename,
55144 if (retval < 0)
55145 goto out;
55146
55147 +#ifdef CONFIG_GRKERNSEC
55148 + old_acl = current->acl;
55149 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
55150 + old_exec_file = current->exec_file;
55151 + get_file(file);
55152 + current->exec_file = file;
55153 +#endif
55154 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55155 + /* limit suid stack to 8MB
55156 + * we saved the old limits above and will restore them if this exec fails
55157 + */
55158 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
55159 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
55160 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
55161 +#endif
55162 +
55163 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
55164 + retval = -EPERM;
55165 + goto out_fail;
55166 + }
55167 +
55168 + if (!gr_tpe_allow(file)) {
55169 + retval = -EACCES;
55170 + goto out_fail;
55171 + }
55172 +
55173 + if (gr_check_crash_exec(file)) {
55174 + retval = -EACCES;
55175 + goto out_fail;
55176 + }
55177 +
55178 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
55179 + bprm->unsafe);
55180 + if (retval < 0)
55181 + goto out_fail;
55182 +
55183 retval = copy_strings_kernel(1, &bprm->filename, bprm);
55184 if (retval < 0)
55185 - goto out;
55186 + goto out_fail;
55187
55188 bprm->exec = bprm->p;
55189 retval = copy_strings(bprm->envc, envp, bprm);
55190 if (retval < 0)
55191 - goto out;
55192 + goto out_fail;
55193
55194 retval = copy_strings(bprm->argc, argv, bprm);
55195 if (retval < 0)
55196 - goto out;
55197 + goto out_fail;
55198 +
55199 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
55200 +
55201 + gr_handle_exec_args(bprm, argv);
55202
55203 retval = search_binary_handler(bprm);
55204 if (retval < 0)
55205 - goto out;
55206 + goto out_fail;
55207 +#ifdef CONFIG_GRKERNSEC
55208 + if (old_exec_file)
55209 + fput(old_exec_file);
55210 +#endif
55211
55212 /* execve succeeded */
55213 +
55214 + increment_exec_counter();
55215 current->fs->in_exec = 0;
55216 current->in_execve = 0;
55217 acct_update_integrals(current);
55218 @@ -1554,6 +1720,14 @@ static int do_execve_common(const char *filename,
55219 put_files_struct(displaced);
55220 return retval;
55221
55222 +out_fail:
55223 +#ifdef CONFIG_GRKERNSEC
55224 + current->acl = old_acl;
55225 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
55226 + fput(current->exec_file);
55227 + current->exec_file = old_exec_file;
55228 +#endif
55229 +
55230 out:
55231 if (bprm->mm) {
55232 acct_arg_size(bprm, 0);
55233 @@ -1702,3 +1876,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
55234 return error;
55235 }
55236 #endif
55237 +
55238 +int pax_check_flags(unsigned long *flags)
55239 +{
55240 + int retval = 0;
55241 +
55242 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
55243 + if (*flags & MF_PAX_SEGMEXEC)
55244 + {
55245 + *flags &= ~MF_PAX_SEGMEXEC;
55246 + retval = -EINVAL;
55247 + }
55248 +#endif
55249 +
55250 + if ((*flags & MF_PAX_PAGEEXEC)
55251 +
55252 +#ifdef CONFIG_PAX_PAGEEXEC
55253 + && (*flags & MF_PAX_SEGMEXEC)
55254 +#endif
55255 +
55256 + )
55257 + {
55258 + *flags &= ~MF_PAX_PAGEEXEC;
55259 + retval = -EINVAL;
55260 + }
55261 +
55262 + if ((*flags & MF_PAX_MPROTECT)
55263 +
55264 +#ifdef CONFIG_PAX_MPROTECT
55265 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55266 +#endif
55267 +
55268 + )
55269 + {
55270 + *flags &= ~MF_PAX_MPROTECT;
55271 + retval = -EINVAL;
55272 + }
55273 +
55274 + if ((*flags & MF_PAX_EMUTRAMP)
55275 +
55276 +#ifdef CONFIG_PAX_EMUTRAMP
55277 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
55278 +#endif
55279 +
55280 + )
55281 + {
55282 + *flags &= ~MF_PAX_EMUTRAMP;
55283 + retval = -EINVAL;
55284 + }
55285 +
55286 + return retval;
55287 +}
55288 +
55289 +EXPORT_SYMBOL(pax_check_flags);
55290 +
55291 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
55292 +char *pax_get_path(const struct path *path, char *buf, int buflen)
55293 +{
55294 + char *pathname = d_path(path, buf, buflen);
55295 +
55296 + if (IS_ERR(pathname))
55297 + goto toolong;
55298 +
55299 + pathname = mangle_path(buf, pathname, "\t\n\\");
55300 + if (!pathname)
55301 + goto toolong;
55302 +
55303 + *pathname = 0;
55304 + return buf;
55305 +
55306 +toolong:
55307 + return "<path too long>";
55308 +}
55309 +EXPORT_SYMBOL(pax_get_path);
55310 +
55311 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
55312 +{
55313 + struct task_struct *tsk = current;
55314 + struct mm_struct *mm = current->mm;
55315 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
55316 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
55317 + char *path_exec = NULL;
55318 + char *path_fault = NULL;
55319 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
55320 + siginfo_t info = { };
55321 +
55322 + if (buffer_exec && buffer_fault) {
55323 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
55324 +
55325 + down_read(&mm->mmap_sem);
55326 + vma = mm->mmap;
55327 + while (vma && (!vma_exec || !vma_fault)) {
55328 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
55329 + vma_exec = vma;
55330 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
55331 + vma_fault = vma;
55332 + vma = vma->vm_next;
55333 + }
55334 + if (vma_exec)
55335 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
55336 + if (vma_fault) {
55337 + start = vma_fault->vm_start;
55338 + end = vma_fault->vm_end;
55339 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
55340 + if (vma_fault->vm_file)
55341 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
55342 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
55343 + path_fault = "<heap>";
55344 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
55345 + path_fault = "<stack>";
55346 + else
55347 + path_fault = "<anonymous mapping>";
55348 + }
55349 + up_read(&mm->mmap_sem);
55350 + }
55351 + if (tsk->signal->curr_ip)
55352 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
55353 + else
55354 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
55355 + 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),
55356 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
55357 + free_page((unsigned long)buffer_exec);
55358 + free_page((unsigned long)buffer_fault);
55359 + pax_report_insns(regs, pc, sp);
55360 + info.si_signo = SIGKILL;
55361 + info.si_errno = 0;
55362 + info.si_code = SI_KERNEL;
55363 + info.si_pid = 0;
55364 + info.si_uid = 0;
55365 + do_coredump(&info);
55366 +}
55367 +#endif
55368 +
55369 +#ifdef CONFIG_PAX_REFCOUNT
55370 +void pax_report_refcount_overflow(struct pt_regs *regs)
55371 +{
55372 + if (current->signal->curr_ip)
55373 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
55374 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
55375 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55376 + else
55377 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
55378 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
55379 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
55380 + preempt_disable();
55381 + show_regs(regs);
55382 + preempt_enable();
55383 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
55384 +}
55385 +#endif
55386 +
55387 +#ifdef CONFIG_PAX_USERCOPY
55388 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
55389 +static noinline int check_stack_object(const void *obj, unsigned long len)
55390 +{
55391 + const void * const stack = task_stack_page(current);
55392 + const void * const stackend = stack + THREAD_SIZE;
55393 +
55394 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55395 + const void *frame = NULL;
55396 + const void *oldframe;
55397 +#endif
55398 +
55399 + if (obj + len < obj)
55400 + return -1;
55401 +
55402 + if (obj + len <= stack || stackend <= obj)
55403 + return 0;
55404 +
55405 + if (obj < stack || stackend < obj + len)
55406 + return -1;
55407 +
55408 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
55409 + oldframe = __builtin_frame_address(1);
55410 + if (oldframe)
55411 + frame = __builtin_frame_address(2);
55412 + /*
55413 + low ----------------------------------------------> high
55414 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
55415 + ^----------------^
55416 + allow copies only within here
55417 + */
55418 + while (stack <= frame && frame < stackend) {
55419 + /* if obj + len extends past the last frame, this
55420 + check won't pass and the next frame will be 0,
55421 + causing us to bail out and correctly report
55422 + the copy as invalid
55423 + */
55424 + if (obj + len <= frame)
55425 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
55426 + oldframe = frame;
55427 + frame = *(const void * const *)frame;
55428 + }
55429 + return -1;
55430 +#else
55431 + return 1;
55432 +#endif
55433 +}
55434 +
55435 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
55436 +{
55437 + if (current->signal->curr_ip)
55438 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55439 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55440 + else
55441 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
55442 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
55443 + dump_stack();
55444 + gr_handle_kernel_exploit();
55445 + do_group_exit(SIGKILL);
55446 +}
55447 +#endif
55448 +
55449 +#ifdef CONFIG_PAX_USERCOPY
55450 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
55451 +{
55452 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
55453 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
55454 +#ifdef CONFIG_MODULES
55455 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
55456 +#else
55457 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
55458 +#endif
55459 +
55460 +#else
55461 + unsigned long textlow = (unsigned long)_stext;
55462 + unsigned long texthigh = (unsigned long)_etext;
55463 +#endif
55464 +
55465 + if (high <= textlow || low > texthigh)
55466 + return false;
55467 + else
55468 + return true;
55469 +}
55470 +#endif
55471 +
55472 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
55473 +{
55474 +
55475 +#ifdef CONFIG_PAX_USERCOPY
55476 + const char *type;
55477 +
55478 + if (!n)
55479 + return;
55480 +
55481 + type = check_heap_object(ptr, n);
55482 + if (!type) {
55483 + int ret = check_stack_object(ptr, n);
55484 + if (ret == 1 || ret == 2)
55485 + return;
55486 + if (ret == 0) {
55487 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
55488 + type = "<kernel text>";
55489 + else
55490 + return;
55491 + } else
55492 + type = "<process stack>";
55493 + }
55494 +
55495 + pax_report_usercopy(ptr, n, to_user, type);
55496 +#endif
55497 +
55498 +}
55499 +EXPORT_SYMBOL(__check_object_size);
55500 +
55501 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
55502 +void pax_track_stack(void)
55503 +{
55504 + unsigned long sp = (unsigned long)&sp;
55505 + if (sp < current_thread_info()->lowest_stack &&
55506 + sp > (unsigned long)task_stack_page(current))
55507 + current_thread_info()->lowest_stack = sp;
55508 +}
55509 +EXPORT_SYMBOL(pax_track_stack);
55510 +#endif
55511 +
55512 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
55513 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
55514 +{
55515 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
55516 + dump_stack();
55517 + do_group_exit(SIGKILL);
55518 +}
55519 +EXPORT_SYMBOL(report_size_overflow);
55520 +#endif
55521 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
55522 index 9f9992b..8b59411 100644
55523 --- a/fs/ext2/balloc.c
55524 +++ b/fs/ext2/balloc.c
55525 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
55526
55527 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55528 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55529 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55530 + if (free_blocks < root_blocks + 1 &&
55531 !uid_eq(sbi->s_resuid, current_fsuid()) &&
55532 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55533 - !in_group_p (sbi->s_resgid))) {
55534 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55535 return 0;
55536 }
55537 return 1;
55538 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
55539 index 22548f5..41521d8 100644
55540 --- a/fs/ext3/balloc.c
55541 +++ b/fs/ext3/balloc.c
55542 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
55543
55544 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
55545 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
55546 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
55547 + if (free_blocks < root_blocks + 1 &&
55548 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
55549 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
55550 - !in_group_p (sbi->s_resgid))) {
55551 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
55552 return 0;
55553 }
55554 return 1;
55555 diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
55556 index 1194b1f..f8cde46 100644
55557 --- a/fs/ext3/namei.c
55558 +++ b/fs/ext3/namei.c
55559 @@ -1783,7 +1783,7 @@ retry:
55560 d_tmpfile(dentry, inode);
55561 err = ext3_orphan_add(handle, inode);
55562 if (err)
55563 - goto err_drop_inode;
55564 + goto err_unlock_inode;
55565 mark_inode_dirty(inode);
55566 unlock_new_inode(inode);
55567 }
55568 @@ -1791,10 +1791,9 @@ retry:
55569 if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries))
55570 goto retry;
55571 return err;
55572 -err_drop_inode:
55573 +err_unlock_inode:
55574 ext3_journal_stop(handle);
55575 unlock_new_inode(inode);
55576 - iput(inode);
55577 return err;
55578 }
55579
55580 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
55581 index ddd715e..c772f88 100644
55582 --- a/fs/ext4/balloc.c
55583 +++ b/fs/ext4/balloc.c
55584 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
55585 /* Hm, nope. Are (enough) root reserved clusters available? */
55586 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
55587 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
55588 - capable(CAP_SYS_RESOURCE) ||
55589 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
55590 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
55591 + capable_nolog(CAP_SYS_RESOURCE)) {
55592
55593 if (free_clusters >= (nclusters + dirty_clusters +
55594 resv_clusters))
55595 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
55596 index 0ab26fb..b6ecb39 100644
55597 --- a/fs/ext4/ext4.h
55598 +++ b/fs/ext4/ext4.h
55599 @@ -1247,19 +1247,19 @@ struct ext4_sb_info {
55600 unsigned long s_mb_last_start;
55601
55602 /* stats for buddy allocator */
55603 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
55604 - atomic_t s_bal_success; /* we found long enough chunks */
55605 - atomic_t s_bal_allocated; /* in blocks */
55606 - atomic_t s_bal_ex_scanned; /* total extents scanned */
55607 - atomic_t s_bal_goals; /* goal hits */
55608 - atomic_t s_bal_breaks; /* too long searches */
55609 - atomic_t s_bal_2orders; /* 2^order hits */
55610 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
55611 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
55612 + atomic_unchecked_t s_bal_allocated; /* in blocks */
55613 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
55614 + atomic_unchecked_t s_bal_goals; /* goal hits */
55615 + atomic_unchecked_t s_bal_breaks; /* too long searches */
55616 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
55617 spinlock_t s_bal_lock;
55618 unsigned long s_mb_buddies_generated;
55619 unsigned long long s_mb_generation_time;
55620 - atomic_t s_mb_lost_chunks;
55621 - atomic_t s_mb_preallocated;
55622 - atomic_t s_mb_discarded;
55623 + atomic_unchecked_t s_mb_lost_chunks;
55624 + atomic_unchecked_t s_mb_preallocated;
55625 + atomic_unchecked_t s_mb_discarded;
55626 atomic_t s_lock_busy;
55627
55628 /* locality groups */
55629 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
55630 index 4bbbf13b..dcceaeb 100644
55631 --- a/fs/ext4/mballoc.c
55632 +++ b/fs/ext4/mballoc.c
55633 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
55634 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
55635
55636 if (EXT4_SB(sb)->s_mb_stats)
55637 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
55638 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
55639
55640 break;
55641 }
55642 @@ -2171,7 +2171,7 @@ repeat:
55643 ac->ac_status = AC_STATUS_CONTINUE;
55644 ac->ac_flags |= EXT4_MB_HINT_FIRST;
55645 cr = 3;
55646 - atomic_inc(&sbi->s_mb_lost_chunks);
55647 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
55648 goto repeat;
55649 }
55650 }
55651 @@ -2679,25 +2679,25 @@ int ext4_mb_release(struct super_block *sb)
55652 if (sbi->s_mb_stats) {
55653 ext4_msg(sb, KERN_INFO,
55654 "mballoc: %u blocks %u reqs (%u success)",
55655 - atomic_read(&sbi->s_bal_allocated),
55656 - atomic_read(&sbi->s_bal_reqs),
55657 - atomic_read(&sbi->s_bal_success));
55658 + atomic_read_unchecked(&sbi->s_bal_allocated),
55659 + atomic_read_unchecked(&sbi->s_bal_reqs),
55660 + atomic_read_unchecked(&sbi->s_bal_success));
55661 ext4_msg(sb, KERN_INFO,
55662 "mballoc: %u extents scanned, %u goal hits, "
55663 "%u 2^N hits, %u breaks, %u lost",
55664 - atomic_read(&sbi->s_bal_ex_scanned),
55665 - atomic_read(&sbi->s_bal_goals),
55666 - atomic_read(&sbi->s_bal_2orders),
55667 - atomic_read(&sbi->s_bal_breaks),
55668 - atomic_read(&sbi->s_mb_lost_chunks));
55669 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
55670 + atomic_read_unchecked(&sbi->s_bal_goals),
55671 + atomic_read_unchecked(&sbi->s_bal_2orders),
55672 + atomic_read_unchecked(&sbi->s_bal_breaks),
55673 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
55674 ext4_msg(sb, KERN_INFO,
55675 "mballoc: %lu generated and it took %Lu",
55676 sbi->s_mb_buddies_generated,
55677 sbi->s_mb_generation_time);
55678 ext4_msg(sb, KERN_INFO,
55679 "mballoc: %u preallocated, %u discarded",
55680 - atomic_read(&sbi->s_mb_preallocated),
55681 - atomic_read(&sbi->s_mb_discarded));
55682 + atomic_read_unchecked(&sbi->s_mb_preallocated),
55683 + atomic_read_unchecked(&sbi->s_mb_discarded));
55684 }
55685
55686 free_percpu(sbi->s_locality_groups);
55687 @@ -3151,16 +3151,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
55688 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
55689
55690 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
55691 - atomic_inc(&sbi->s_bal_reqs);
55692 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55693 + atomic_inc_unchecked(&sbi->s_bal_reqs);
55694 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
55695 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
55696 - atomic_inc(&sbi->s_bal_success);
55697 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
55698 + atomic_inc_unchecked(&sbi->s_bal_success);
55699 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
55700 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
55701 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
55702 - atomic_inc(&sbi->s_bal_goals);
55703 + atomic_inc_unchecked(&sbi->s_bal_goals);
55704 if (ac->ac_found > sbi->s_mb_max_to_scan)
55705 - atomic_inc(&sbi->s_bal_breaks);
55706 + atomic_inc_unchecked(&sbi->s_bal_breaks);
55707 }
55708
55709 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
55710 @@ -3560,7 +3560,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
55711 trace_ext4_mb_new_inode_pa(ac, pa);
55712
55713 ext4_mb_use_inode_pa(ac, pa);
55714 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
55715 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
55716
55717 ei = EXT4_I(ac->ac_inode);
55718 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55719 @@ -3620,7 +3620,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
55720 trace_ext4_mb_new_group_pa(ac, pa);
55721
55722 ext4_mb_use_group_pa(ac, pa);
55723 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55724 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
55725
55726 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
55727 lg = ac->ac_lg;
55728 @@ -3709,7 +3709,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
55729 * from the bitmap and continue.
55730 */
55731 }
55732 - atomic_add(free, &sbi->s_mb_discarded);
55733 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
55734
55735 return err;
55736 }
55737 @@ -3727,7 +3727,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
55738 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
55739 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
55740 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
55741 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55742 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
55743 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
55744
55745 return 0;
55746 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
55747 index 214461e..3614c89 100644
55748 --- a/fs/ext4/mmp.c
55749 +++ b/fs/ext4/mmp.c
55750 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
55751 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
55752 const char *function, unsigned int line, const char *msg)
55753 {
55754 - __ext4_warning(sb, function, line, msg);
55755 + __ext4_warning(sb, function, line, "%s", msg);
55756 __ext4_warning(sb, function, line,
55757 "MMP failure info: last update time: %llu, last update "
55758 "node: %s, last update device: %s\n",
55759 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
55760 index 35f55a0..b53cbc6 100644
55761 --- a/fs/ext4/namei.c
55762 +++ b/fs/ext4/namei.c
55763 @@ -2319,7 +2319,7 @@ retry:
55764 d_tmpfile(dentry, inode);
55765 err = ext4_orphan_add(handle, inode);
55766 if (err)
55767 - goto err_drop_inode;
55768 + goto err_unlock_inode;
55769 mark_inode_dirty(inode);
55770 unlock_new_inode(inode);
55771 }
55772 @@ -2328,10 +2328,9 @@ retry:
55773 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
55774 goto retry;
55775 return err;
55776 -err_drop_inode:
55777 +err_unlock_inode:
55778 ext4_journal_stop(handle);
55779 unlock_new_inode(inode);
55780 - iput(inode);
55781 return err;
55782 }
55783
55784 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
55785 index b59373b..f41c2b5 100644
55786 --- a/fs/ext4/super.c
55787 +++ b/fs/ext4/super.c
55788 @@ -1254,7 +1254,7 @@ static ext4_fsblk_t get_sb_block(void **data)
55789 }
55790
55791 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
55792 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55793 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
55794 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
55795
55796 #ifdef CONFIG_QUOTA
55797 @@ -2394,7 +2394,7 @@ struct ext4_attr {
55798 int offset;
55799 int deprecated_val;
55800 } u;
55801 -};
55802 +} __do_const;
55803
55804 static int parse_strtoull(const char *buf,
55805 unsigned long long max, unsigned long long *value)
55806 diff --git a/fs/fcntl.c b/fs/fcntl.c
55807 index 65343c3..9969dcf 100644
55808 --- a/fs/fcntl.c
55809 +++ b/fs/fcntl.c
55810 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
55811 if (err)
55812 return err;
55813
55814 + if (gr_handle_chroot_fowner(pid, type))
55815 + return -ENOENT;
55816 + if (gr_check_protected_task_fowner(pid, type))
55817 + return -EACCES;
55818 +
55819 f_modown(filp, pid, type, force);
55820 return 0;
55821 }
55822 diff --git a/fs/fhandle.c b/fs/fhandle.c
55823 index 999ff5c..41f4109 100644
55824 --- a/fs/fhandle.c
55825 +++ b/fs/fhandle.c
55826 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
55827 } else
55828 retval = 0;
55829 /* copy the mount id */
55830 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
55831 - sizeof(*mnt_id)) ||
55832 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
55833 copy_to_user(ufh, handle,
55834 sizeof(struct file_handle) + handle_bytes))
55835 retval = -EFAULT;
55836 diff --git a/fs/file.c b/fs/file.c
55837 index 4a78f98..9447397 100644
55838 --- a/fs/file.c
55839 +++ b/fs/file.c
55840 @@ -16,6 +16,7 @@
55841 #include <linux/slab.h>
55842 #include <linux/vmalloc.h>
55843 #include <linux/file.h>
55844 +#include <linux/security.h>
55845 #include <linux/fdtable.h>
55846 #include <linux/bitops.h>
55847 #include <linux/interrupt.h>
55848 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
55849 if (!file)
55850 return __close_fd(files, fd);
55851
55852 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
55853 if (fd >= rlimit(RLIMIT_NOFILE))
55854 return -EBADF;
55855
55856 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
55857 if (unlikely(oldfd == newfd))
55858 return -EINVAL;
55859
55860 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
55861 if (newfd >= rlimit(RLIMIT_NOFILE))
55862 return -EBADF;
55863
55864 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
55865 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
55866 {
55867 int err;
55868 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
55869 if (from >= rlimit(RLIMIT_NOFILE))
55870 return -EINVAL;
55871 err = alloc_fd(from, flags);
55872 diff --git a/fs/filesystems.c b/fs/filesystems.c
55873 index 92567d9..fcd8cbf 100644
55874 --- a/fs/filesystems.c
55875 +++ b/fs/filesystems.c
55876 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
55877 int len = dot ? dot - name : strlen(name);
55878
55879 fs = __get_fs_type(name, len);
55880 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
55881 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
55882 +#else
55883 if (!fs && (request_module("fs-%.*s", len, name) == 0))
55884 +#endif
55885 fs = __get_fs_type(name, len);
55886
55887 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
55888 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
55889 index d8ac61d..79a36f0 100644
55890 --- a/fs/fs_struct.c
55891 +++ b/fs/fs_struct.c
55892 @@ -4,6 +4,7 @@
55893 #include <linux/path.h>
55894 #include <linux/slab.h>
55895 #include <linux/fs_struct.h>
55896 +#include <linux/grsecurity.h>
55897 #include "internal.h"
55898
55899 /*
55900 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
55901 write_seqcount_begin(&fs->seq);
55902 old_root = fs->root;
55903 fs->root = *path;
55904 + gr_set_chroot_entries(current, path);
55905 write_seqcount_end(&fs->seq);
55906 spin_unlock(&fs->lock);
55907 if (old_root.dentry)
55908 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
55909 int hits = 0;
55910 spin_lock(&fs->lock);
55911 write_seqcount_begin(&fs->seq);
55912 + /* this root replacement is only done by pivot_root,
55913 + leave grsec's chroot tagging alone for this task
55914 + so that a pivoted root isn't treated as a chroot
55915 + */
55916 hits += replace_path(&fs->root, old_root, new_root);
55917 hits += replace_path(&fs->pwd, old_root, new_root);
55918 write_seqcount_end(&fs->seq);
55919 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
55920 task_lock(tsk);
55921 spin_lock(&fs->lock);
55922 tsk->fs = NULL;
55923 - kill = !--fs->users;
55924 + gr_clear_chroot_entries(tsk);
55925 + kill = !atomic_dec_return(&fs->users);
55926 spin_unlock(&fs->lock);
55927 task_unlock(tsk);
55928 if (kill)
55929 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55930 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
55931 /* We don't need to lock fs - think why ;-) */
55932 if (fs) {
55933 - fs->users = 1;
55934 + atomic_set(&fs->users, 1);
55935 fs->in_exec = 0;
55936 spin_lock_init(&fs->lock);
55937 seqcount_init(&fs->seq);
55938 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
55939 spin_lock(&old->lock);
55940 fs->root = old->root;
55941 path_get(&fs->root);
55942 + /* instead of calling gr_set_chroot_entries here,
55943 + we call it from every caller of this function
55944 + */
55945 fs->pwd = old->pwd;
55946 path_get(&fs->pwd);
55947 spin_unlock(&old->lock);
55948 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
55949
55950 task_lock(current);
55951 spin_lock(&fs->lock);
55952 - kill = !--fs->users;
55953 + kill = !atomic_dec_return(&fs->users);
55954 current->fs = new_fs;
55955 + gr_set_chroot_entries(current, &new_fs->root);
55956 spin_unlock(&fs->lock);
55957 task_unlock(current);
55958
55959 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
55960
55961 int current_umask(void)
55962 {
55963 - return current->fs->umask;
55964 + return current->fs->umask | gr_acl_umask();
55965 }
55966 EXPORT_SYMBOL(current_umask);
55967
55968 /* to be mentioned only in INIT_TASK */
55969 struct fs_struct init_fs = {
55970 - .users = 1,
55971 + .users = ATOMIC_INIT(1),
55972 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
55973 .seq = SEQCNT_ZERO,
55974 .umask = 0022,
55975 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
55976 index 0e91a3c..6c6d2e0 100644
55977 --- a/fs/fscache/cookie.c
55978 +++ b/fs/fscache/cookie.c
55979 @@ -19,7 +19,7 @@
55980
55981 struct kmem_cache *fscache_cookie_jar;
55982
55983 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
55984 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
55985
55986 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
55987 static int fscache_alloc_object(struct fscache_cache *cache,
55988 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
55989 parent ? (char *) parent->def->name : "<no-parent>",
55990 def->name, netfs_data);
55991
55992 - fscache_stat(&fscache_n_acquires);
55993 + fscache_stat_unchecked(&fscache_n_acquires);
55994
55995 /* if there's no parent cookie, then we don't create one here either */
55996 if (!parent) {
55997 - fscache_stat(&fscache_n_acquires_null);
55998 + fscache_stat_unchecked(&fscache_n_acquires_null);
55999 _leave(" [no parent]");
56000 return NULL;
56001 }
56002 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
56003 /* allocate and initialise a cookie */
56004 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
56005 if (!cookie) {
56006 - fscache_stat(&fscache_n_acquires_oom);
56007 + fscache_stat_unchecked(&fscache_n_acquires_oom);
56008 _leave(" [ENOMEM]");
56009 return NULL;
56010 }
56011 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56012
56013 switch (cookie->def->type) {
56014 case FSCACHE_COOKIE_TYPE_INDEX:
56015 - fscache_stat(&fscache_n_cookie_index);
56016 + fscache_stat_unchecked(&fscache_n_cookie_index);
56017 break;
56018 case FSCACHE_COOKIE_TYPE_DATAFILE:
56019 - fscache_stat(&fscache_n_cookie_data);
56020 + fscache_stat_unchecked(&fscache_n_cookie_data);
56021 break;
56022 default:
56023 - fscache_stat(&fscache_n_cookie_special);
56024 + fscache_stat_unchecked(&fscache_n_cookie_special);
56025 break;
56026 }
56027
56028 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
56029 if (fscache_acquire_non_index_cookie(cookie) < 0) {
56030 atomic_dec(&parent->n_children);
56031 __fscache_cookie_put(cookie);
56032 - fscache_stat(&fscache_n_acquires_nobufs);
56033 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
56034 _leave(" = NULL");
56035 return NULL;
56036 }
56037 }
56038
56039 - fscache_stat(&fscache_n_acquires_ok);
56040 + fscache_stat_unchecked(&fscache_n_acquires_ok);
56041 _leave(" = %p", cookie);
56042 return cookie;
56043 }
56044 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
56045 cache = fscache_select_cache_for_object(cookie->parent);
56046 if (!cache) {
56047 up_read(&fscache_addremove_sem);
56048 - fscache_stat(&fscache_n_acquires_no_cache);
56049 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
56050 _leave(" = -ENOMEDIUM [no cache]");
56051 return -ENOMEDIUM;
56052 }
56053 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
56054 object = cache->ops->alloc_object(cache, cookie);
56055 fscache_stat_d(&fscache_n_cop_alloc_object);
56056 if (IS_ERR(object)) {
56057 - fscache_stat(&fscache_n_object_no_alloc);
56058 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
56059 ret = PTR_ERR(object);
56060 goto error;
56061 }
56062
56063 - fscache_stat(&fscache_n_object_alloc);
56064 + fscache_stat_unchecked(&fscache_n_object_alloc);
56065
56066 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
56067 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
56068
56069 _debug("ALLOC OBJ%x: %s {%lx}",
56070 object->debug_id, cookie->def->name, object->events);
56071 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
56072
56073 _enter("{%s}", cookie->def->name);
56074
56075 - fscache_stat(&fscache_n_invalidates);
56076 + fscache_stat_unchecked(&fscache_n_invalidates);
56077
56078 /* Only permit invalidation of data files. Invalidating an index will
56079 * require the caller to release all its attachments to the tree rooted
56080 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
56081 {
56082 struct fscache_object *object;
56083
56084 - fscache_stat(&fscache_n_updates);
56085 + fscache_stat_unchecked(&fscache_n_updates);
56086
56087 if (!cookie) {
56088 - fscache_stat(&fscache_n_updates_null);
56089 + fscache_stat_unchecked(&fscache_n_updates_null);
56090 _leave(" [no cookie]");
56091 return;
56092 }
56093 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
56094 {
56095 struct fscache_object *object;
56096
56097 - fscache_stat(&fscache_n_relinquishes);
56098 + fscache_stat_unchecked(&fscache_n_relinquishes);
56099 if (retire)
56100 - fscache_stat(&fscache_n_relinquishes_retire);
56101 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
56102
56103 if (!cookie) {
56104 - fscache_stat(&fscache_n_relinquishes_null);
56105 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
56106 _leave(" [no cookie]");
56107 return;
56108 }
56109 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
56110 index 12d505b..86473a3 100644
56111 --- a/fs/fscache/internal.h
56112 +++ b/fs/fscache/internal.h
56113 @@ -147,101 +147,101 @@ extern void fscache_proc_cleanup(void);
56114 * stats.c
56115 */
56116 #ifdef CONFIG_FSCACHE_STATS
56117 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56118 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56119 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
56120 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
56121
56122 -extern atomic_t fscache_n_op_pend;
56123 -extern atomic_t fscache_n_op_run;
56124 -extern atomic_t fscache_n_op_enqueue;
56125 -extern atomic_t fscache_n_op_deferred_release;
56126 -extern atomic_t fscache_n_op_release;
56127 -extern atomic_t fscache_n_op_gc;
56128 -extern atomic_t fscache_n_op_cancelled;
56129 -extern atomic_t fscache_n_op_rejected;
56130 +extern atomic_unchecked_t fscache_n_op_pend;
56131 +extern atomic_unchecked_t fscache_n_op_run;
56132 +extern atomic_unchecked_t fscache_n_op_enqueue;
56133 +extern atomic_unchecked_t fscache_n_op_deferred_release;
56134 +extern atomic_unchecked_t fscache_n_op_release;
56135 +extern atomic_unchecked_t fscache_n_op_gc;
56136 +extern atomic_unchecked_t fscache_n_op_cancelled;
56137 +extern atomic_unchecked_t fscache_n_op_rejected;
56138
56139 -extern atomic_t fscache_n_attr_changed;
56140 -extern atomic_t fscache_n_attr_changed_ok;
56141 -extern atomic_t fscache_n_attr_changed_nobufs;
56142 -extern atomic_t fscache_n_attr_changed_nomem;
56143 -extern atomic_t fscache_n_attr_changed_calls;
56144 +extern atomic_unchecked_t fscache_n_attr_changed;
56145 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
56146 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
56147 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
56148 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
56149
56150 -extern atomic_t fscache_n_allocs;
56151 -extern atomic_t fscache_n_allocs_ok;
56152 -extern atomic_t fscache_n_allocs_wait;
56153 -extern atomic_t fscache_n_allocs_nobufs;
56154 -extern atomic_t fscache_n_allocs_intr;
56155 -extern atomic_t fscache_n_allocs_object_dead;
56156 -extern atomic_t fscache_n_alloc_ops;
56157 -extern atomic_t fscache_n_alloc_op_waits;
56158 +extern atomic_unchecked_t fscache_n_allocs;
56159 +extern atomic_unchecked_t fscache_n_allocs_ok;
56160 +extern atomic_unchecked_t fscache_n_allocs_wait;
56161 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
56162 +extern atomic_unchecked_t fscache_n_allocs_intr;
56163 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
56164 +extern atomic_unchecked_t fscache_n_alloc_ops;
56165 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
56166
56167 -extern atomic_t fscache_n_retrievals;
56168 -extern atomic_t fscache_n_retrievals_ok;
56169 -extern atomic_t fscache_n_retrievals_wait;
56170 -extern atomic_t fscache_n_retrievals_nodata;
56171 -extern atomic_t fscache_n_retrievals_nobufs;
56172 -extern atomic_t fscache_n_retrievals_intr;
56173 -extern atomic_t fscache_n_retrievals_nomem;
56174 -extern atomic_t fscache_n_retrievals_object_dead;
56175 -extern atomic_t fscache_n_retrieval_ops;
56176 -extern atomic_t fscache_n_retrieval_op_waits;
56177 +extern atomic_unchecked_t fscache_n_retrievals;
56178 +extern atomic_unchecked_t fscache_n_retrievals_ok;
56179 +extern atomic_unchecked_t fscache_n_retrievals_wait;
56180 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
56181 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
56182 +extern atomic_unchecked_t fscache_n_retrievals_intr;
56183 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
56184 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
56185 +extern atomic_unchecked_t fscache_n_retrieval_ops;
56186 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
56187
56188 -extern atomic_t fscache_n_stores;
56189 -extern atomic_t fscache_n_stores_ok;
56190 -extern atomic_t fscache_n_stores_again;
56191 -extern atomic_t fscache_n_stores_nobufs;
56192 -extern atomic_t fscache_n_stores_oom;
56193 -extern atomic_t fscache_n_store_ops;
56194 -extern atomic_t fscache_n_store_calls;
56195 -extern atomic_t fscache_n_store_pages;
56196 -extern atomic_t fscache_n_store_radix_deletes;
56197 -extern atomic_t fscache_n_store_pages_over_limit;
56198 +extern atomic_unchecked_t fscache_n_stores;
56199 +extern atomic_unchecked_t fscache_n_stores_ok;
56200 +extern atomic_unchecked_t fscache_n_stores_again;
56201 +extern atomic_unchecked_t fscache_n_stores_nobufs;
56202 +extern atomic_unchecked_t fscache_n_stores_oom;
56203 +extern atomic_unchecked_t fscache_n_store_ops;
56204 +extern atomic_unchecked_t fscache_n_store_calls;
56205 +extern atomic_unchecked_t fscache_n_store_pages;
56206 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
56207 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
56208
56209 -extern atomic_t fscache_n_store_vmscan_not_storing;
56210 -extern atomic_t fscache_n_store_vmscan_gone;
56211 -extern atomic_t fscache_n_store_vmscan_busy;
56212 -extern atomic_t fscache_n_store_vmscan_cancelled;
56213 -extern atomic_t fscache_n_store_vmscan_wait;
56214 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
56215 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
56216 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
56217 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
56218 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
56219
56220 -extern atomic_t fscache_n_marks;
56221 -extern atomic_t fscache_n_uncaches;
56222 +extern atomic_unchecked_t fscache_n_marks;
56223 +extern atomic_unchecked_t fscache_n_uncaches;
56224
56225 -extern atomic_t fscache_n_acquires;
56226 -extern atomic_t fscache_n_acquires_null;
56227 -extern atomic_t fscache_n_acquires_no_cache;
56228 -extern atomic_t fscache_n_acquires_ok;
56229 -extern atomic_t fscache_n_acquires_nobufs;
56230 -extern atomic_t fscache_n_acquires_oom;
56231 +extern atomic_unchecked_t fscache_n_acquires;
56232 +extern atomic_unchecked_t fscache_n_acquires_null;
56233 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
56234 +extern atomic_unchecked_t fscache_n_acquires_ok;
56235 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
56236 +extern atomic_unchecked_t fscache_n_acquires_oom;
56237
56238 -extern atomic_t fscache_n_invalidates;
56239 -extern atomic_t fscache_n_invalidates_run;
56240 +extern atomic_unchecked_t fscache_n_invalidates;
56241 +extern atomic_unchecked_t fscache_n_invalidates_run;
56242
56243 -extern atomic_t fscache_n_updates;
56244 -extern atomic_t fscache_n_updates_null;
56245 -extern atomic_t fscache_n_updates_run;
56246 +extern atomic_unchecked_t fscache_n_updates;
56247 +extern atomic_unchecked_t fscache_n_updates_null;
56248 +extern atomic_unchecked_t fscache_n_updates_run;
56249
56250 -extern atomic_t fscache_n_relinquishes;
56251 -extern atomic_t fscache_n_relinquishes_null;
56252 -extern atomic_t fscache_n_relinquishes_waitcrt;
56253 -extern atomic_t fscache_n_relinquishes_retire;
56254 +extern atomic_unchecked_t fscache_n_relinquishes;
56255 +extern atomic_unchecked_t fscache_n_relinquishes_null;
56256 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
56257 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
56258
56259 -extern atomic_t fscache_n_cookie_index;
56260 -extern atomic_t fscache_n_cookie_data;
56261 -extern atomic_t fscache_n_cookie_special;
56262 +extern atomic_unchecked_t fscache_n_cookie_index;
56263 +extern atomic_unchecked_t fscache_n_cookie_data;
56264 +extern atomic_unchecked_t fscache_n_cookie_special;
56265
56266 -extern atomic_t fscache_n_object_alloc;
56267 -extern atomic_t fscache_n_object_no_alloc;
56268 -extern atomic_t fscache_n_object_lookups;
56269 -extern atomic_t fscache_n_object_lookups_negative;
56270 -extern atomic_t fscache_n_object_lookups_positive;
56271 -extern atomic_t fscache_n_object_lookups_timed_out;
56272 -extern atomic_t fscache_n_object_created;
56273 -extern atomic_t fscache_n_object_avail;
56274 -extern atomic_t fscache_n_object_dead;
56275 +extern atomic_unchecked_t fscache_n_object_alloc;
56276 +extern atomic_unchecked_t fscache_n_object_no_alloc;
56277 +extern atomic_unchecked_t fscache_n_object_lookups;
56278 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
56279 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
56280 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
56281 +extern atomic_unchecked_t fscache_n_object_created;
56282 +extern atomic_unchecked_t fscache_n_object_avail;
56283 +extern atomic_unchecked_t fscache_n_object_dead;
56284
56285 -extern atomic_t fscache_n_checkaux_none;
56286 -extern atomic_t fscache_n_checkaux_okay;
56287 -extern atomic_t fscache_n_checkaux_update;
56288 -extern atomic_t fscache_n_checkaux_obsolete;
56289 +extern atomic_unchecked_t fscache_n_checkaux_none;
56290 +extern atomic_unchecked_t fscache_n_checkaux_okay;
56291 +extern atomic_unchecked_t fscache_n_checkaux_update;
56292 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
56293
56294 extern atomic_t fscache_n_cop_alloc_object;
56295 extern atomic_t fscache_n_cop_lookup_object;
56296 @@ -266,6 +266,11 @@ static inline void fscache_stat(atomic_t *stat)
56297 atomic_inc(stat);
56298 }
56299
56300 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
56301 +{
56302 + atomic_inc_unchecked(stat);
56303 +}
56304 +
56305 static inline void fscache_stat_d(atomic_t *stat)
56306 {
56307 atomic_dec(stat);
56308 @@ -278,6 +283,7 @@ extern const struct file_operations fscache_stats_fops;
56309
56310 #define __fscache_stat(stat) (NULL)
56311 #define fscache_stat(stat) do {} while (0)
56312 +#define fscache_stat_unchecked(stat) do {} while (0)
56313 #define fscache_stat_d(stat) do {} while (0)
56314 #endif
56315
56316 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
56317 index 86d75a6..5f3d7a0 100644
56318 --- a/fs/fscache/object.c
56319 +++ b/fs/fscache/object.c
56320 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56321 _debug("LOOKUP \"%s\" in \"%s\"",
56322 cookie->def->name, object->cache->tag->name);
56323
56324 - fscache_stat(&fscache_n_object_lookups);
56325 + fscache_stat_unchecked(&fscache_n_object_lookups);
56326 fscache_stat(&fscache_n_cop_lookup_object);
56327 ret = object->cache->ops->lookup_object(object);
56328 fscache_stat_d(&fscache_n_cop_lookup_object);
56329 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
56330 if (ret == -ETIMEDOUT) {
56331 /* probably stuck behind another object, so move this one to
56332 * the back of the queue */
56333 - fscache_stat(&fscache_n_object_lookups_timed_out);
56334 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
56335 _leave(" [timeout]");
56336 return NO_TRANSIT;
56337 }
56338 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
56339 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
56340
56341 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56342 - fscache_stat(&fscache_n_object_lookups_negative);
56343 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
56344
56345 /* Allow write requests to begin stacking up and read requests to begin
56346 * returning ENODATA.
56347 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
56348 /* if we were still looking up, then we must have a positive lookup
56349 * result, in which case there may be data available */
56350 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
56351 - fscache_stat(&fscache_n_object_lookups_positive);
56352 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
56353
56354 /* We do (presumably) have data */
56355 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
56356 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
56357 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
56358 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
56359 } else {
56360 - fscache_stat(&fscache_n_object_created);
56361 + fscache_stat_unchecked(&fscache_n_object_created);
56362 }
56363
56364 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
56365 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
56366 fscache_stat_d(&fscache_n_cop_lookup_complete);
56367
56368 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
56369 - fscache_stat(&fscache_n_object_avail);
56370 + fscache_stat_unchecked(&fscache_n_object_avail);
56371
56372 _leave("");
56373 return transit_to(JUMPSTART_DEPS);
56374 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
56375
56376 /* this just shifts the object release to the work processor */
56377 fscache_put_object(object);
56378 - fscache_stat(&fscache_n_object_dead);
56379 + fscache_stat_unchecked(&fscache_n_object_dead);
56380
56381 _leave("");
56382 return transit_to(OBJECT_DEAD);
56383 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56384 enum fscache_checkaux result;
56385
56386 if (!object->cookie->def->check_aux) {
56387 - fscache_stat(&fscache_n_checkaux_none);
56388 + fscache_stat_unchecked(&fscache_n_checkaux_none);
56389 return FSCACHE_CHECKAUX_OKAY;
56390 }
56391
56392 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
56393 switch (result) {
56394 /* entry okay as is */
56395 case FSCACHE_CHECKAUX_OKAY:
56396 - fscache_stat(&fscache_n_checkaux_okay);
56397 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
56398 break;
56399
56400 /* entry requires update */
56401 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
56402 - fscache_stat(&fscache_n_checkaux_update);
56403 + fscache_stat_unchecked(&fscache_n_checkaux_update);
56404 break;
56405
56406 /* entry requires deletion */
56407 case FSCACHE_CHECKAUX_OBSOLETE:
56408 - fscache_stat(&fscache_n_checkaux_obsolete);
56409 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
56410 break;
56411
56412 default:
56413 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
56414 {
56415 const struct fscache_state *s;
56416
56417 - fscache_stat(&fscache_n_invalidates_run);
56418 + fscache_stat_unchecked(&fscache_n_invalidates_run);
56419 fscache_stat(&fscache_n_cop_invalidate_object);
56420 s = _fscache_invalidate_object(object, event);
56421 fscache_stat_d(&fscache_n_cop_invalidate_object);
56422 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
56423 {
56424 _enter("{OBJ%x},%d", object->debug_id, event);
56425
56426 - fscache_stat(&fscache_n_updates_run);
56427 + fscache_stat_unchecked(&fscache_n_updates_run);
56428 fscache_stat(&fscache_n_cop_update_object);
56429 object->cache->ops->update_object(object);
56430 fscache_stat_d(&fscache_n_cop_update_object);
56431 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
56432 index 318071a..379938b 100644
56433 --- a/fs/fscache/operation.c
56434 +++ b/fs/fscache/operation.c
56435 @@ -17,7 +17,7 @@
56436 #include <linux/slab.h>
56437 #include "internal.h"
56438
56439 -atomic_t fscache_op_debug_id;
56440 +atomic_unchecked_t fscache_op_debug_id;
56441 EXPORT_SYMBOL(fscache_op_debug_id);
56442
56443 /**
56444 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
56445 ASSERTCMP(atomic_read(&op->usage), >, 0);
56446 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
56447
56448 - fscache_stat(&fscache_n_op_enqueue);
56449 + fscache_stat_unchecked(&fscache_n_op_enqueue);
56450 switch (op->flags & FSCACHE_OP_TYPE) {
56451 case FSCACHE_OP_ASYNC:
56452 _debug("queue async");
56453 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
56454 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
56455 if (op->processor)
56456 fscache_enqueue_operation(op);
56457 - fscache_stat(&fscache_n_op_run);
56458 + fscache_stat_unchecked(&fscache_n_op_run);
56459 }
56460
56461 /*
56462 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56463 if (object->n_in_progress > 0) {
56464 atomic_inc(&op->usage);
56465 list_add_tail(&op->pend_link, &object->pending_ops);
56466 - fscache_stat(&fscache_n_op_pend);
56467 + fscache_stat_unchecked(&fscache_n_op_pend);
56468 } else if (!list_empty(&object->pending_ops)) {
56469 atomic_inc(&op->usage);
56470 list_add_tail(&op->pend_link, &object->pending_ops);
56471 - fscache_stat(&fscache_n_op_pend);
56472 + fscache_stat_unchecked(&fscache_n_op_pend);
56473 fscache_start_operations(object);
56474 } else {
56475 ASSERTCMP(object->n_in_progress, ==, 0);
56476 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
56477 object->n_exclusive++; /* reads and writes must wait */
56478 atomic_inc(&op->usage);
56479 list_add_tail(&op->pend_link, &object->pending_ops);
56480 - fscache_stat(&fscache_n_op_pend);
56481 + fscache_stat_unchecked(&fscache_n_op_pend);
56482 ret = 0;
56483 } else {
56484 /* If we're in any other state, there must have been an I/O
56485 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
56486 if (object->n_exclusive > 0) {
56487 atomic_inc(&op->usage);
56488 list_add_tail(&op->pend_link, &object->pending_ops);
56489 - fscache_stat(&fscache_n_op_pend);
56490 + fscache_stat_unchecked(&fscache_n_op_pend);
56491 } else if (!list_empty(&object->pending_ops)) {
56492 atomic_inc(&op->usage);
56493 list_add_tail(&op->pend_link, &object->pending_ops);
56494 - fscache_stat(&fscache_n_op_pend);
56495 + fscache_stat_unchecked(&fscache_n_op_pend);
56496 fscache_start_operations(object);
56497 } else {
56498 ASSERTCMP(object->n_exclusive, ==, 0);
56499 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
56500 object->n_ops++;
56501 atomic_inc(&op->usage);
56502 list_add_tail(&op->pend_link, &object->pending_ops);
56503 - fscache_stat(&fscache_n_op_pend);
56504 + fscache_stat_unchecked(&fscache_n_op_pend);
56505 ret = 0;
56506 } else if (fscache_object_is_dying(object)) {
56507 - fscache_stat(&fscache_n_op_rejected);
56508 + fscache_stat_unchecked(&fscache_n_op_rejected);
56509 op->state = FSCACHE_OP_ST_CANCELLED;
56510 ret = -ENOBUFS;
56511 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
56512 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
56513 ret = -EBUSY;
56514 if (op->state == FSCACHE_OP_ST_PENDING) {
56515 ASSERT(!list_empty(&op->pend_link));
56516 - fscache_stat(&fscache_n_op_cancelled);
56517 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56518 list_del_init(&op->pend_link);
56519 if (do_cancel)
56520 do_cancel(op);
56521 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
56522 while (!list_empty(&object->pending_ops)) {
56523 op = list_entry(object->pending_ops.next,
56524 struct fscache_operation, pend_link);
56525 - fscache_stat(&fscache_n_op_cancelled);
56526 + fscache_stat_unchecked(&fscache_n_op_cancelled);
56527 list_del_init(&op->pend_link);
56528
56529 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
56530 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
56531 op->state, ==, FSCACHE_OP_ST_CANCELLED);
56532 op->state = FSCACHE_OP_ST_DEAD;
56533
56534 - fscache_stat(&fscache_n_op_release);
56535 + fscache_stat_unchecked(&fscache_n_op_release);
56536
56537 if (op->release) {
56538 op->release(op);
56539 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
56540 * lock, and defer it otherwise */
56541 if (!spin_trylock(&object->lock)) {
56542 _debug("defer put");
56543 - fscache_stat(&fscache_n_op_deferred_release);
56544 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
56545
56546 cache = object->cache;
56547 spin_lock(&cache->op_gc_list_lock);
56548 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
56549
56550 _debug("GC DEFERRED REL OBJ%x OP%x",
56551 object->debug_id, op->debug_id);
56552 - fscache_stat(&fscache_n_op_gc);
56553 + fscache_stat_unchecked(&fscache_n_op_gc);
56554
56555 ASSERTCMP(atomic_read(&op->usage), ==, 0);
56556 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
56557 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
56558 index d479ab3..727a7f2 100644
56559 --- a/fs/fscache/page.c
56560 +++ b/fs/fscache/page.c
56561 @@ -61,7 +61,7 @@ try_again:
56562 val = radix_tree_lookup(&cookie->stores, page->index);
56563 if (!val) {
56564 rcu_read_unlock();
56565 - fscache_stat(&fscache_n_store_vmscan_not_storing);
56566 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
56567 __fscache_uncache_page(cookie, page);
56568 return true;
56569 }
56570 @@ -91,11 +91,11 @@ try_again:
56571 spin_unlock(&cookie->stores_lock);
56572
56573 if (xpage) {
56574 - fscache_stat(&fscache_n_store_vmscan_cancelled);
56575 - fscache_stat(&fscache_n_store_radix_deletes);
56576 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
56577 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56578 ASSERTCMP(xpage, ==, page);
56579 } else {
56580 - fscache_stat(&fscache_n_store_vmscan_gone);
56581 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
56582 }
56583
56584 wake_up_bit(&cookie->flags, 0);
56585 @@ -110,11 +110,11 @@ page_busy:
56586 * sleeping on memory allocation, so we may need to impose a timeout
56587 * too. */
56588 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
56589 - fscache_stat(&fscache_n_store_vmscan_busy);
56590 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
56591 return false;
56592 }
56593
56594 - fscache_stat(&fscache_n_store_vmscan_wait);
56595 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
56596 __fscache_wait_on_page_write(cookie, page);
56597 gfp &= ~__GFP_WAIT;
56598 goto try_again;
56599 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
56600 FSCACHE_COOKIE_STORING_TAG);
56601 if (!radix_tree_tag_get(&cookie->stores, page->index,
56602 FSCACHE_COOKIE_PENDING_TAG)) {
56603 - fscache_stat(&fscache_n_store_radix_deletes);
56604 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
56605 xpage = radix_tree_delete(&cookie->stores, page->index);
56606 }
56607 spin_unlock(&cookie->stores_lock);
56608 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
56609
56610 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
56611
56612 - fscache_stat(&fscache_n_attr_changed_calls);
56613 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
56614
56615 if (fscache_object_is_active(object) &&
56616 fscache_use_cookie(object)) {
56617 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56618
56619 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56620
56621 - fscache_stat(&fscache_n_attr_changed);
56622 + fscache_stat_unchecked(&fscache_n_attr_changed);
56623
56624 op = kzalloc(sizeof(*op), GFP_KERNEL);
56625 if (!op) {
56626 - fscache_stat(&fscache_n_attr_changed_nomem);
56627 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
56628 _leave(" = -ENOMEM");
56629 return -ENOMEM;
56630 }
56631 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56632 if (fscache_submit_exclusive_op(object, op) < 0)
56633 goto nobufs;
56634 spin_unlock(&cookie->lock);
56635 - fscache_stat(&fscache_n_attr_changed_ok);
56636 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
56637 fscache_put_operation(op);
56638 _leave(" = 0");
56639 return 0;
56640 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
56641 nobufs:
56642 spin_unlock(&cookie->lock);
56643 kfree(op);
56644 - fscache_stat(&fscache_n_attr_changed_nobufs);
56645 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
56646 _leave(" = %d", -ENOBUFS);
56647 return -ENOBUFS;
56648 }
56649 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
56650 /* allocate a retrieval operation and attempt to submit it */
56651 op = kzalloc(sizeof(*op), GFP_NOIO);
56652 if (!op) {
56653 - fscache_stat(&fscache_n_retrievals_nomem);
56654 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56655 return NULL;
56656 }
56657
56658 @@ -289,13 +289,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
56659 return 0;
56660 }
56661
56662 - fscache_stat(&fscache_n_retrievals_wait);
56663 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
56664
56665 jif = jiffies;
56666 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
56667 fscache_wait_bit_interruptible,
56668 TASK_INTERRUPTIBLE) != 0) {
56669 - fscache_stat(&fscache_n_retrievals_intr);
56670 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56671 _leave(" = -ERESTARTSYS");
56672 return -ERESTARTSYS;
56673 }
56674 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
56675 */
56676 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56677 struct fscache_retrieval *op,
56678 - atomic_t *stat_op_waits,
56679 - atomic_t *stat_object_dead)
56680 + atomic_unchecked_t *stat_op_waits,
56681 + atomic_unchecked_t *stat_object_dead)
56682 {
56683 int ret;
56684
56685 @@ -333,7 +333,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56686 goto check_if_dead;
56687
56688 _debug(">>> WT");
56689 - fscache_stat(stat_op_waits);
56690 + fscache_stat_unchecked(stat_op_waits);
56691 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
56692 fscache_wait_bit_interruptible,
56693 TASK_INTERRUPTIBLE) != 0) {
56694 @@ -350,14 +350,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
56695
56696 check_if_dead:
56697 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
56698 - fscache_stat(stat_object_dead);
56699 + fscache_stat_unchecked(stat_object_dead);
56700 _leave(" = -ENOBUFS [cancelled]");
56701 return -ENOBUFS;
56702 }
56703 if (unlikely(fscache_object_is_dead(object))) {
56704 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
56705 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
56706 - fscache_stat(stat_object_dead);
56707 + fscache_stat_unchecked(stat_object_dead);
56708 return -ENOBUFS;
56709 }
56710 return 0;
56711 @@ -384,7 +384,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56712
56713 _enter("%p,%p,,,", cookie, page);
56714
56715 - fscache_stat(&fscache_n_retrievals);
56716 + fscache_stat_unchecked(&fscache_n_retrievals);
56717
56718 if (hlist_empty(&cookie->backing_objects))
56719 goto nobufs;
56720 @@ -424,7 +424,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56721 goto nobufs_unlock_dec;
56722 spin_unlock(&cookie->lock);
56723
56724 - fscache_stat(&fscache_n_retrieval_ops);
56725 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56726
56727 /* pin the netfs read context in case we need to do the actual netfs
56728 * read because we've encountered a cache read failure */
56729 @@ -454,15 +454,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
56730
56731 error:
56732 if (ret == -ENOMEM)
56733 - fscache_stat(&fscache_n_retrievals_nomem);
56734 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56735 else if (ret == -ERESTARTSYS)
56736 - fscache_stat(&fscache_n_retrievals_intr);
56737 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56738 else if (ret == -ENODATA)
56739 - fscache_stat(&fscache_n_retrievals_nodata);
56740 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56741 else if (ret < 0)
56742 - fscache_stat(&fscache_n_retrievals_nobufs);
56743 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56744 else
56745 - fscache_stat(&fscache_n_retrievals_ok);
56746 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56747
56748 fscache_put_retrieval(op);
56749 _leave(" = %d", ret);
56750 @@ -475,7 +475,7 @@ nobufs_unlock:
56751 atomic_dec(&cookie->n_active);
56752 kfree(op);
56753 nobufs:
56754 - fscache_stat(&fscache_n_retrievals_nobufs);
56755 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56756 _leave(" = -ENOBUFS");
56757 return -ENOBUFS;
56758 }
56759 @@ -513,7 +513,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56760
56761 _enter("%p,,%d,,,", cookie, *nr_pages);
56762
56763 - fscache_stat(&fscache_n_retrievals);
56764 + fscache_stat_unchecked(&fscache_n_retrievals);
56765
56766 if (hlist_empty(&cookie->backing_objects))
56767 goto nobufs;
56768 @@ -549,7 +549,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56769 goto nobufs_unlock_dec;
56770 spin_unlock(&cookie->lock);
56771
56772 - fscache_stat(&fscache_n_retrieval_ops);
56773 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
56774
56775 /* pin the netfs read context in case we need to do the actual netfs
56776 * read because we've encountered a cache read failure */
56777 @@ -579,15 +579,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
56778
56779 error:
56780 if (ret == -ENOMEM)
56781 - fscache_stat(&fscache_n_retrievals_nomem);
56782 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
56783 else if (ret == -ERESTARTSYS)
56784 - fscache_stat(&fscache_n_retrievals_intr);
56785 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
56786 else if (ret == -ENODATA)
56787 - fscache_stat(&fscache_n_retrievals_nodata);
56788 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
56789 else if (ret < 0)
56790 - fscache_stat(&fscache_n_retrievals_nobufs);
56791 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56792 else
56793 - fscache_stat(&fscache_n_retrievals_ok);
56794 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
56795
56796 fscache_put_retrieval(op);
56797 _leave(" = %d", ret);
56798 @@ -600,7 +600,7 @@ nobufs_unlock:
56799 atomic_dec(&cookie->n_active);
56800 kfree(op);
56801 nobufs:
56802 - fscache_stat(&fscache_n_retrievals_nobufs);
56803 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
56804 _leave(" = -ENOBUFS");
56805 return -ENOBUFS;
56806 }
56807 @@ -624,7 +624,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56808
56809 _enter("%p,%p,,,", cookie, page);
56810
56811 - fscache_stat(&fscache_n_allocs);
56812 + fscache_stat_unchecked(&fscache_n_allocs);
56813
56814 if (hlist_empty(&cookie->backing_objects))
56815 goto nobufs;
56816 @@ -656,7 +656,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56817 goto nobufs_unlock;
56818 spin_unlock(&cookie->lock);
56819
56820 - fscache_stat(&fscache_n_alloc_ops);
56821 + fscache_stat_unchecked(&fscache_n_alloc_ops);
56822
56823 ret = fscache_wait_for_retrieval_activation(
56824 object, op,
56825 @@ -672,11 +672,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
56826
56827 error:
56828 if (ret == -ERESTARTSYS)
56829 - fscache_stat(&fscache_n_allocs_intr);
56830 + fscache_stat_unchecked(&fscache_n_allocs_intr);
56831 else if (ret < 0)
56832 - fscache_stat(&fscache_n_allocs_nobufs);
56833 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56834 else
56835 - fscache_stat(&fscache_n_allocs_ok);
56836 + fscache_stat_unchecked(&fscache_n_allocs_ok);
56837
56838 fscache_put_retrieval(op);
56839 _leave(" = %d", ret);
56840 @@ -687,7 +687,7 @@ nobufs_unlock:
56841 atomic_dec(&cookie->n_active);
56842 kfree(op);
56843 nobufs:
56844 - fscache_stat(&fscache_n_allocs_nobufs);
56845 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
56846 _leave(" = -ENOBUFS");
56847 return -ENOBUFS;
56848 }
56849 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56850
56851 spin_lock(&cookie->stores_lock);
56852
56853 - fscache_stat(&fscache_n_store_calls);
56854 + fscache_stat_unchecked(&fscache_n_store_calls);
56855
56856 /* find a page to store */
56857 page = NULL;
56858 @@ -758,7 +758,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56859 page = results[0];
56860 _debug("gang %d [%lx]", n, page->index);
56861 if (page->index > op->store_limit) {
56862 - fscache_stat(&fscache_n_store_pages_over_limit);
56863 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
56864 goto superseded;
56865 }
56866
56867 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
56868 spin_unlock(&cookie->stores_lock);
56869 spin_unlock(&object->lock);
56870
56871 - fscache_stat(&fscache_n_store_pages);
56872 + fscache_stat_unchecked(&fscache_n_store_pages);
56873 fscache_stat(&fscache_n_cop_write_page);
56874 ret = object->cache->ops->write_page(op, page);
56875 fscache_stat_d(&fscache_n_cop_write_page);
56876 @@ -873,7 +873,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56877 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56878 ASSERT(PageFsCache(page));
56879
56880 - fscache_stat(&fscache_n_stores);
56881 + fscache_stat_unchecked(&fscache_n_stores);
56882
56883 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
56884 _leave(" = -ENOBUFS [invalidating]");
56885 @@ -931,7 +931,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56886 spin_unlock(&cookie->stores_lock);
56887 spin_unlock(&object->lock);
56888
56889 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
56890 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
56891 op->store_limit = object->store_limit;
56892
56893 atomic_inc(&cookie->n_active);
56894 @@ -940,8 +940,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56895
56896 spin_unlock(&cookie->lock);
56897 radix_tree_preload_end();
56898 - fscache_stat(&fscache_n_store_ops);
56899 - fscache_stat(&fscache_n_stores_ok);
56900 + fscache_stat_unchecked(&fscache_n_store_ops);
56901 + fscache_stat_unchecked(&fscache_n_stores_ok);
56902
56903 /* the work queue now carries its own ref on the object */
56904 fscache_put_operation(&op->op);
56905 @@ -949,14 +949,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
56906 return 0;
56907
56908 already_queued:
56909 - fscache_stat(&fscache_n_stores_again);
56910 + fscache_stat_unchecked(&fscache_n_stores_again);
56911 already_pending:
56912 spin_unlock(&cookie->stores_lock);
56913 spin_unlock(&object->lock);
56914 spin_unlock(&cookie->lock);
56915 radix_tree_preload_end();
56916 kfree(op);
56917 - fscache_stat(&fscache_n_stores_ok);
56918 + fscache_stat_unchecked(&fscache_n_stores_ok);
56919 _leave(" = 0");
56920 return 0;
56921
56922 @@ -976,14 +976,14 @@ nobufs:
56923 spin_unlock(&cookie->lock);
56924 radix_tree_preload_end();
56925 kfree(op);
56926 - fscache_stat(&fscache_n_stores_nobufs);
56927 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
56928 _leave(" = -ENOBUFS");
56929 return -ENOBUFS;
56930
56931 nomem_free:
56932 kfree(op);
56933 nomem:
56934 - fscache_stat(&fscache_n_stores_oom);
56935 + fscache_stat_unchecked(&fscache_n_stores_oom);
56936 _leave(" = -ENOMEM");
56937 return -ENOMEM;
56938 }
56939 @@ -1001,7 +1001,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
56940 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
56941 ASSERTCMP(page, !=, NULL);
56942
56943 - fscache_stat(&fscache_n_uncaches);
56944 + fscache_stat_unchecked(&fscache_n_uncaches);
56945
56946 /* cache withdrawal may beat us to it */
56947 if (!PageFsCache(page))
56948 @@ -1052,7 +1052,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
56949 struct fscache_cookie *cookie = op->op.object->cookie;
56950
56951 #ifdef CONFIG_FSCACHE_STATS
56952 - atomic_inc(&fscache_n_marks);
56953 + atomic_inc_unchecked(&fscache_n_marks);
56954 #endif
56955
56956 _debug("- mark %p{%lx}", page, page->index);
56957 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
56958 index 40d13c7..ddf52b9 100644
56959 --- a/fs/fscache/stats.c
56960 +++ b/fs/fscache/stats.c
56961 @@ -18,99 +18,99 @@
56962 /*
56963 * operation counters
56964 */
56965 -atomic_t fscache_n_op_pend;
56966 -atomic_t fscache_n_op_run;
56967 -atomic_t fscache_n_op_enqueue;
56968 -atomic_t fscache_n_op_requeue;
56969 -atomic_t fscache_n_op_deferred_release;
56970 -atomic_t fscache_n_op_release;
56971 -atomic_t fscache_n_op_gc;
56972 -atomic_t fscache_n_op_cancelled;
56973 -atomic_t fscache_n_op_rejected;
56974 +atomic_unchecked_t fscache_n_op_pend;
56975 +atomic_unchecked_t fscache_n_op_run;
56976 +atomic_unchecked_t fscache_n_op_enqueue;
56977 +atomic_unchecked_t fscache_n_op_requeue;
56978 +atomic_unchecked_t fscache_n_op_deferred_release;
56979 +atomic_unchecked_t fscache_n_op_release;
56980 +atomic_unchecked_t fscache_n_op_gc;
56981 +atomic_unchecked_t fscache_n_op_cancelled;
56982 +atomic_unchecked_t fscache_n_op_rejected;
56983
56984 -atomic_t fscache_n_attr_changed;
56985 -atomic_t fscache_n_attr_changed_ok;
56986 -atomic_t fscache_n_attr_changed_nobufs;
56987 -atomic_t fscache_n_attr_changed_nomem;
56988 -atomic_t fscache_n_attr_changed_calls;
56989 +atomic_unchecked_t fscache_n_attr_changed;
56990 +atomic_unchecked_t fscache_n_attr_changed_ok;
56991 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
56992 +atomic_unchecked_t fscache_n_attr_changed_nomem;
56993 +atomic_unchecked_t fscache_n_attr_changed_calls;
56994
56995 -atomic_t fscache_n_allocs;
56996 -atomic_t fscache_n_allocs_ok;
56997 -atomic_t fscache_n_allocs_wait;
56998 -atomic_t fscache_n_allocs_nobufs;
56999 -atomic_t fscache_n_allocs_intr;
57000 -atomic_t fscache_n_allocs_object_dead;
57001 -atomic_t fscache_n_alloc_ops;
57002 -atomic_t fscache_n_alloc_op_waits;
57003 +atomic_unchecked_t fscache_n_allocs;
57004 +atomic_unchecked_t fscache_n_allocs_ok;
57005 +atomic_unchecked_t fscache_n_allocs_wait;
57006 +atomic_unchecked_t fscache_n_allocs_nobufs;
57007 +atomic_unchecked_t fscache_n_allocs_intr;
57008 +atomic_unchecked_t fscache_n_allocs_object_dead;
57009 +atomic_unchecked_t fscache_n_alloc_ops;
57010 +atomic_unchecked_t fscache_n_alloc_op_waits;
57011
57012 -atomic_t fscache_n_retrievals;
57013 -atomic_t fscache_n_retrievals_ok;
57014 -atomic_t fscache_n_retrievals_wait;
57015 -atomic_t fscache_n_retrievals_nodata;
57016 -atomic_t fscache_n_retrievals_nobufs;
57017 -atomic_t fscache_n_retrievals_intr;
57018 -atomic_t fscache_n_retrievals_nomem;
57019 -atomic_t fscache_n_retrievals_object_dead;
57020 -atomic_t fscache_n_retrieval_ops;
57021 -atomic_t fscache_n_retrieval_op_waits;
57022 +atomic_unchecked_t fscache_n_retrievals;
57023 +atomic_unchecked_t fscache_n_retrievals_ok;
57024 +atomic_unchecked_t fscache_n_retrievals_wait;
57025 +atomic_unchecked_t fscache_n_retrievals_nodata;
57026 +atomic_unchecked_t fscache_n_retrievals_nobufs;
57027 +atomic_unchecked_t fscache_n_retrievals_intr;
57028 +atomic_unchecked_t fscache_n_retrievals_nomem;
57029 +atomic_unchecked_t fscache_n_retrievals_object_dead;
57030 +atomic_unchecked_t fscache_n_retrieval_ops;
57031 +atomic_unchecked_t fscache_n_retrieval_op_waits;
57032
57033 -atomic_t fscache_n_stores;
57034 -atomic_t fscache_n_stores_ok;
57035 -atomic_t fscache_n_stores_again;
57036 -atomic_t fscache_n_stores_nobufs;
57037 -atomic_t fscache_n_stores_oom;
57038 -atomic_t fscache_n_store_ops;
57039 -atomic_t fscache_n_store_calls;
57040 -atomic_t fscache_n_store_pages;
57041 -atomic_t fscache_n_store_radix_deletes;
57042 -atomic_t fscache_n_store_pages_over_limit;
57043 +atomic_unchecked_t fscache_n_stores;
57044 +atomic_unchecked_t fscache_n_stores_ok;
57045 +atomic_unchecked_t fscache_n_stores_again;
57046 +atomic_unchecked_t fscache_n_stores_nobufs;
57047 +atomic_unchecked_t fscache_n_stores_oom;
57048 +atomic_unchecked_t fscache_n_store_ops;
57049 +atomic_unchecked_t fscache_n_store_calls;
57050 +atomic_unchecked_t fscache_n_store_pages;
57051 +atomic_unchecked_t fscache_n_store_radix_deletes;
57052 +atomic_unchecked_t fscache_n_store_pages_over_limit;
57053
57054 -atomic_t fscache_n_store_vmscan_not_storing;
57055 -atomic_t fscache_n_store_vmscan_gone;
57056 -atomic_t fscache_n_store_vmscan_busy;
57057 -atomic_t fscache_n_store_vmscan_cancelled;
57058 -atomic_t fscache_n_store_vmscan_wait;
57059 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57060 +atomic_unchecked_t fscache_n_store_vmscan_gone;
57061 +atomic_unchecked_t fscache_n_store_vmscan_busy;
57062 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57063 +atomic_unchecked_t fscache_n_store_vmscan_wait;
57064
57065 -atomic_t fscache_n_marks;
57066 -atomic_t fscache_n_uncaches;
57067 +atomic_unchecked_t fscache_n_marks;
57068 +atomic_unchecked_t fscache_n_uncaches;
57069
57070 -atomic_t fscache_n_acquires;
57071 -atomic_t fscache_n_acquires_null;
57072 -atomic_t fscache_n_acquires_no_cache;
57073 -atomic_t fscache_n_acquires_ok;
57074 -atomic_t fscache_n_acquires_nobufs;
57075 -atomic_t fscache_n_acquires_oom;
57076 +atomic_unchecked_t fscache_n_acquires;
57077 +atomic_unchecked_t fscache_n_acquires_null;
57078 +atomic_unchecked_t fscache_n_acquires_no_cache;
57079 +atomic_unchecked_t fscache_n_acquires_ok;
57080 +atomic_unchecked_t fscache_n_acquires_nobufs;
57081 +atomic_unchecked_t fscache_n_acquires_oom;
57082
57083 -atomic_t fscache_n_invalidates;
57084 -atomic_t fscache_n_invalidates_run;
57085 +atomic_unchecked_t fscache_n_invalidates;
57086 +atomic_unchecked_t fscache_n_invalidates_run;
57087
57088 -atomic_t fscache_n_updates;
57089 -atomic_t fscache_n_updates_null;
57090 -atomic_t fscache_n_updates_run;
57091 +atomic_unchecked_t fscache_n_updates;
57092 +atomic_unchecked_t fscache_n_updates_null;
57093 +atomic_unchecked_t fscache_n_updates_run;
57094
57095 -atomic_t fscache_n_relinquishes;
57096 -atomic_t fscache_n_relinquishes_null;
57097 -atomic_t fscache_n_relinquishes_waitcrt;
57098 -atomic_t fscache_n_relinquishes_retire;
57099 +atomic_unchecked_t fscache_n_relinquishes;
57100 +atomic_unchecked_t fscache_n_relinquishes_null;
57101 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57102 +atomic_unchecked_t fscache_n_relinquishes_retire;
57103
57104 -atomic_t fscache_n_cookie_index;
57105 -atomic_t fscache_n_cookie_data;
57106 -atomic_t fscache_n_cookie_special;
57107 +atomic_unchecked_t fscache_n_cookie_index;
57108 +atomic_unchecked_t fscache_n_cookie_data;
57109 +atomic_unchecked_t fscache_n_cookie_special;
57110
57111 -atomic_t fscache_n_object_alloc;
57112 -atomic_t fscache_n_object_no_alloc;
57113 -atomic_t fscache_n_object_lookups;
57114 -atomic_t fscache_n_object_lookups_negative;
57115 -atomic_t fscache_n_object_lookups_positive;
57116 -atomic_t fscache_n_object_lookups_timed_out;
57117 -atomic_t fscache_n_object_created;
57118 -atomic_t fscache_n_object_avail;
57119 -atomic_t fscache_n_object_dead;
57120 +atomic_unchecked_t fscache_n_object_alloc;
57121 +atomic_unchecked_t fscache_n_object_no_alloc;
57122 +atomic_unchecked_t fscache_n_object_lookups;
57123 +atomic_unchecked_t fscache_n_object_lookups_negative;
57124 +atomic_unchecked_t fscache_n_object_lookups_positive;
57125 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
57126 +atomic_unchecked_t fscache_n_object_created;
57127 +atomic_unchecked_t fscache_n_object_avail;
57128 +atomic_unchecked_t fscache_n_object_dead;
57129
57130 -atomic_t fscache_n_checkaux_none;
57131 -atomic_t fscache_n_checkaux_okay;
57132 -atomic_t fscache_n_checkaux_update;
57133 -atomic_t fscache_n_checkaux_obsolete;
57134 +atomic_unchecked_t fscache_n_checkaux_none;
57135 +atomic_unchecked_t fscache_n_checkaux_okay;
57136 +atomic_unchecked_t fscache_n_checkaux_update;
57137 +atomic_unchecked_t fscache_n_checkaux_obsolete;
57138
57139 atomic_t fscache_n_cop_alloc_object;
57140 atomic_t fscache_n_cop_lookup_object;
57141 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
57142 seq_puts(m, "FS-Cache statistics\n");
57143
57144 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
57145 - atomic_read(&fscache_n_cookie_index),
57146 - atomic_read(&fscache_n_cookie_data),
57147 - atomic_read(&fscache_n_cookie_special));
57148 + atomic_read_unchecked(&fscache_n_cookie_index),
57149 + atomic_read_unchecked(&fscache_n_cookie_data),
57150 + atomic_read_unchecked(&fscache_n_cookie_special));
57151
57152 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
57153 - atomic_read(&fscache_n_object_alloc),
57154 - atomic_read(&fscache_n_object_no_alloc),
57155 - atomic_read(&fscache_n_object_avail),
57156 - atomic_read(&fscache_n_object_dead));
57157 + atomic_read_unchecked(&fscache_n_object_alloc),
57158 + atomic_read_unchecked(&fscache_n_object_no_alloc),
57159 + atomic_read_unchecked(&fscache_n_object_avail),
57160 + atomic_read_unchecked(&fscache_n_object_dead));
57161 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
57162 - atomic_read(&fscache_n_checkaux_none),
57163 - atomic_read(&fscache_n_checkaux_okay),
57164 - atomic_read(&fscache_n_checkaux_update),
57165 - atomic_read(&fscache_n_checkaux_obsolete));
57166 + atomic_read_unchecked(&fscache_n_checkaux_none),
57167 + atomic_read_unchecked(&fscache_n_checkaux_okay),
57168 + atomic_read_unchecked(&fscache_n_checkaux_update),
57169 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
57170
57171 seq_printf(m, "Pages : mrk=%u unc=%u\n",
57172 - atomic_read(&fscache_n_marks),
57173 - atomic_read(&fscache_n_uncaches));
57174 + atomic_read_unchecked(&fscache_n_marks),
57175 + atomic_read_unchecked(&fscache_n_uncaches));
57176
57177 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
57178 " oom=%u\n",
57179 - atomic_read(&fscache_n_acquires),
57180 - atomic_read(&fscache_n_acquires_null),
57181 - atomic_read(&fscache_n_acquires_no_cache),
57182 - atomic_read(&fscache_n_acquires_ok),
57183 - atomic_read(&fscache_n_acquires_nobufs),
57184 - atomic_read(&fscache_n_acquires_oom));
57185 + atomic_read_unchecked(&fscache_n_acquires),
57186 + atomic_read_unchecked(&fscache_n_acquires_null),
57187 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
57188 + atomic_read_unchecked(&fscache_n_acquires_ok),
57189 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
57190 + atomic_read_unchecked(&fscache_n_acquires_oom));
57191
57192 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
57193 - atomic_read(&fscache_n_object_lookups),
57194 - atomic_read(&fscache_n_object_lookups_negative),
57195 - atomic_read(&fscache_n_object_lookups_positive),
57196 - atomic_read(&fscache_n_object_created),
57197 - atomic_read(&fscache_n_object_lookups_timed_out));
57198 + atomic_read_unchecked(&fscache_n_object_lookups),
57199 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
57200 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
57201 + atomic_read_unchecked(&fscache_n_object_created),
57202 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
57203
57204 seq_printf(m, "Invals : n=%u run=%u\n",
57205 - atomic_read(&fscache_n_invalidates),
57206 - atomic_read(&fscache_n_invalidates_run));
57207 + atomic_read_unchecked(&fscache_n_invalidates),
57208 + atomic_read_unchecked(&fscache_n_invalidates_run));
57209
57210 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
57211 - atomic_read(&fscache_n_updates),
57212 - atomic_read(&fscache_n_updates_null),
57213 - atomic_read(&fscache_n_updates_run));
57214 + atomic_read_unchecked(&fscache_n_updates),
57215 + atomic_read_unchecked(&fscache_n_updates_null),
57216 + atomic_read_unchecked(&fscache_n_updates_run));
57217
57218 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
57219 - atomic_read(&fscache_n_relinquishes),
57220 - atomic_read(&fscache_n_relinquishes_null),
57221 - atomic_read(&fscache_n_relinquishes_waitcrt),
57222 - atomic_read(&fscache_n_relinquishes_retire));
57223 + atomic_read_unchecked(&fscache_n_relinquishes),
57224 + atomic_read_unchecked(&fscache_n_relinquishes_null),
57225 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
57226 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
57227
57228 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
57229 - atomic_read(&fscache_n_attr_changed),
57230 - atomic_read(&fscache_n_attr_changed_ok),
57231 - atomic_read(&fscache_n_attr_changed_nobufs),
57232 - atomic_read(&fscache_n_attr_changed_nomem),
57233 - atomic_read(&fscache_n_attr_changed_calls));
57234 + atomic_read_unchecked(&fscache_n_attr_changed),
57235 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
57236 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
57237 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
57238 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
57239
57240 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
57241 - atomic_read(&fscache_n_allocs),
57242 - atomic_read(&fscache_n_allocs_ok),
57243 - atomic_read(&fscache_n_allocs_wait),
57244 - atomic_read(&fscache_n_allocs_nobufs),
57245 - atomic_read(&fscache_n_allocs_intr));
57246 + atomic_read_unchecked(&fscache_n_allocs),
57247 + atomic_read_unchecked(&fscache_n_allocs_ok),
57248 + atomic_read_unchecked(&fscache_n_allocs_wait),
57249 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
57250 + atomic_read_unchecked(&fscache_n_allocs_intr));
57251 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
57252 - atomic_read(&fscache_n_alloc_ops),
57253 - atomic_read(&fscache_n_alloc_op_waits),
57254 - atomic_read(&fscache_n_allocs_object_dead));
57255 + atomic_read_unchecked(&fscache_n_alloc_ops),
57256 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
57257 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
57258
57259 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
57260 " int=%u oom=%u\n",
57261 - atomic_read(&fscache_n_retrievals),
57262 - atomic_read(&fscache_n_retrievals_ok),
57263 - atomic_read(&fscache_n_retrievals_wait),
57264 - atomic_read(&fscache_n_retrievals_nodata),
57265 - atomic_read(&fscache_n_retrievals_nobufs),
57266 - atomic_read(&fscache_n_retrievals_intr),
57267 - atomic_read(&fscache_n_retrievals_nomem));
57268 + atomic_read_unchecked(&fscache_n_retrievals),
57269 + atomic_read_unchecked(&fscache_n_retrievals_ok),
57270 + atomic_read_unchecked(&fscache_n_retrievals_wait),
57271 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
57272 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
57273 + atomic_read_unchecked(&fscache_n_retrievals_intr),
57274 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
57275 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
57276 - atomic_read(&fscache_n_retrieval_ops),
57277 - atomic_read(&fscache_n_retrieval_op_waits),
57278 - atomic_read(&fscache_n_retrievals_object_dead));
57279 + atomic_read_unchecked(&fscache_n_retrieval_ops),
57280 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
57281 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
57282
57283 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
57284 - atomic_read(&fscache_n_stores),
57285 - atomic_read(&fscache_n_stores_ok),
57286 - atomic_read(&fscache_n_stores_again),
57287 - atomic_read(&fscache_n_stores_nobufs),
57288 - atomic_read(&fscache_n_stores_oom));
57289 + atomic_read_unchecked(&fscache_n_stores),
57290 + atomic_read_unchecked(&fscache_n_stores_ok),
57291 + atomic_read_unchecked(&fscache_n_stores_again),
57292 + atomic_read_unchecked(&fscache_n_stores_nobufs),
57293 + atomic_read_unchecked(&fscache_n_stores_oom));
57294 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
57295 - atomic_read(&fscache_n_store_ops),
57296 - atomic_read(&fscache_n_store_calls),
57297 - atomic_read(&fscache_n_store_pages),
57298 - atomic_read(&fscache_n_store_radix_deletes),
57299 - atomic_read(&fscache_n_store_pages_over_limit));
57300 + atomic_read_unchecked(&fscache_n_store_ops),
57301 + atomic_read_unchecked(&fscache_n_store_calls),
57302 + atomic_read_unchecked(&fscache_n_store_pages),
57303 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
57304 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
57305
57306 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
57307 - atomic_read(&fscache_n_store_vmscan_not_storing),
57308 - atomic_read(&fscache_n_store_vmscan_gone),
57309 - atomic_read(&fscache_n_store_vmscan_busy),
57310 - atomic_read(&fscache_n_store_vmscan_cancelled),
57311 - atomic_read(&fscache_n_store_vmscan_wait));
57312 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
57313 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
57314 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
57315 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
57316 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
57317
57318 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
57319 - atomic_read(&fscache_n_op_pend),
57320 - atomic_read(&fscache_n_op_run),
57321 - atomic_read(&fscache_n_op_enqueue),
57322 - atomic_read(&fscache_n_op_cancelled),
57323 - atomic_read(&fscache_n_op_rejected));
57324 + atomic_read_unchecked(&fscache_n_op_pend),
57325 + atomic_read_unchecked(&fscache_n_op_run),
57326 + atomic_read_unchecked(&fscache_n_op_enqueue),
57327 + atomic_read_unchecked(&fscache_n_op_cancelled),
57328 + atomic_read_unchecked(&fscache_n_op_rejected));
57329 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
57330 - atomic_read(&fscache_n_op_deferred_release),
57331 - atomic_read(&fscache_n_op_release),
57332 - atomic_read(&fscache_n_op_gc));
57333 + atomic_read_unchecked(&fscache_n_op_deferred_release),
57334 + atomic_read_unchecked(&fscache_n_op_release),
57335 + atomic_read_unchecked(&fscache_n_op_gc));
57336
57337 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
57338 atomic_read(&fscache_n_cop_alloc_object),
57339 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
57340 index aef34b1..59bfd7b 100644
57341 --- a/fs/fuse/cuse.c
57342 +++ b/fs/fuse/cuse.c
57343 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
57344 INIT_LIST_HEAD(&cuse_conntbl[i]);
57345
57346 /* inherit and extend fuse_dev_operations */
57347 - cuse_channel_fops = fuse_dev_operations;
57348 - cuse_channel_fops.owner = THIS_MODULE;
57349 - cuse_channel_fops.open = cuse_channel_open;
57350 - cuse_channel_fops.release = cuse_channel_release;
57351 + pax_open_kernel();
57352 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
57353 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
57354 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
57355 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
57356 + pax_close_kernel();
57357
57358 cuse_class = class_create(THIS_MODULE, "cuse");
57359 if (IS_ERR(cuse_class))
57360 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
57361 index 1d55f94..088da65 100644
57362 --- a/fs/fuse/dev.c
57363 +++ b/fs/fuse/dev.c
57364 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57365 ret = 0;
57366 pipe_lock(pipe);
57367
57368 - if (!pipe->readers) {
57369 + if (!atomic_read(&pipe->readers)) {
57370 send_sig(SIGPIPE, current, 0);
57371 if (!ret)
57372 ret = -EPIPE;
57373 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
57374 page_nr++;
57375 ret += buf->len;
57376
57377 - if (pipe->files)
57378 + if (atomic_read(&pipe->files))
57379 do_wakeup = 1;
57380 }
57381
57382 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
57383 index 8fec28f..cd40dba 100644
57384 --- a/fs/fuse/dir.c
57385 +++ b/fs/fuse/dir.c
57386 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
57387 return link;
57388 }
57389
57390 -static void free_link(char *link)
57391 +static void free_link(const char *link)
57392 {
57393 if (!IS_ERR(link))
57394 free_page((unsigned long) link);
57395 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
57396 index 64915ee..6bed500 100644
57397 --- a/fs/gfs2/inode.c
57398 +++ b/fs/gfs2/inode.c
57399 @@ -1506,7 +1506,7 @@ out:
57400
57401 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
57402 {
57403 - char *s = nd_get_link(nd);
57404 + const char *s = nd_get_link(nd);
57405 if (!IS_ERR(s))
57406 kfree(s);
57407 }
57408 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
57409 index d19b30a..ef89c36 100644
57410 --- a/fs/hugetlbfs/inode.c
57411 +++ b/fs/hugetlbfs/inode.c
57412 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57413 struct mm_struct *mm = current->mm;
57414 struct vm_area_struct *vma;
57415 struct hstate *h = hstate_file(file);
57416 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
57417 struct vm_unmapped_area_info info;
57418
57419 if (len & ~huge_page_mask(h))
57420 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
57421 return addr;
57422 }
57423
57424 +#ifdef CONFIG_PAX_RANDMMAP
57425 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
57426 +#endif
57427 +
57428 if (addr) {
57429 addr = ALIGN(addr, huge_page_size(h));
57430 vma = find_vma(mm, addr);
57431 - if (TASK_SIZE - len >= addr &&
57432 - (!vma || addr + len <= vma->vm_start))
57433 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
57434 return addr;
57435 }
57436
57437 info.flags = 0;
57438 info.length = len;
57439 info.low_limit = TASK_UNMAPPED_BASE;
57440 +
57441 +#ifdef CONFIG_PAX_RANDMMAP
57442 + if (mm->pax_flags & MF_PAX_RANDMMAP)
57443 + info.low_limit += mm->delta_mmap;
57444 +#endif
57445 +
57446 info.high_limit = TASK_SIZE;
57447 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
57448 info.align_offset = 0;
57449 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
57450 };
57451 MODULE_ALIAS_FS("hugetlbfs");
57452
57453 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57454 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
57455
57456 static int can_do_hugetlb_shm(void)
57457 {
57458 diff --git a/fs/inode.c b/fs/inode.c
57459 index d6dfb09..602e77e 100644
57460 --- a/fs/inode.c
57461 +++ b/fs/inode.c
57462 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
57463
57464 #ifdef CONFIG_SMP
57465 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
57466 - static atomic_t shared_last_ino;
57467 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
57468 + static atomic_unchecked_t shared_last_ino;
57469 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
57470
57471 res = next - LAST_INO_BATCH;
57472 }
57473 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
57474 index 4a6cf28..d3a29d3 100644
57475 --- a/fs/jffs2/erase.c
57476 +++ b/fs/jffs2/erase.c
57477 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
57478 struct jffs2_unknown_node marker = {
57479 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
57480 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57481 - .totlen = cpu_to_je32(c->cleanmarker_size)
57482 + .totlen = cpu_to_je32(c->cleanmarker_size),
57483 + .hdr_crc = cpu_to_je32(0)
57484 };
57485
57486 jffs2_prealloc_raw_node_refs(c, jeb, 1);
57487 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
57488 index a6597d6..41b30ec 100644
57489 --- a/fs/jffs2/wbuf.c
57490 +++ b/fs/jffs2/wbuf.c
57491 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
57492 {
57493 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
57494 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
57495 - .totlen = constant_cpu_to_je32(8)
57496 + .totlen = constant_cpu_to_je32(8),
57497 + .hdr_crc = constant_cpu_to_je32(0)
57498 };
57499
57500 /*
57501 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
57502 index 6669aa2..36b033d 100644
57503 --- a/fs/jfs/super.c
57504 +++ b/fs/jfs/super.c
57505 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
57506
57507 jfs_inode_cachep =
57508 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
57509 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
57510 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
57511 init_once);
57512 if (jfs_inode_cachep == NULL)
57513 return -ENOMEM;
57514 diff --git a/fs/libfs.c b/fs/libfs.c
57515 index 3a3a9b5..3a9b074 100644
57516 --- a/fs/libfs.c
57517 +++ b/fs/libfs.c
57518 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57519
57520 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
57521 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
57522 + char d_name[sizeof(next->d_iname)];
57523 + const unsigned char *name;
57524 +
57525 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
57526 if (!simple_positive(next)) {
57527 spin_unlock(&next->d_lock);
57528 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
57529
57530 spin_unlock(&next->d_lock);
57531 spin_unlock(&dentry->d_lock);
57532 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
57533 + name = next->d_name.name;
57534 + if (name == next->d_iname) {
57535 + memcpy(d_name, name, next->d_name.len);
57536 + name = d_name;
57537 + }
57538 + if (!dir_emit(ctx, name, next->d_name.len,
57539 next->d_inode->i_ino, dt_type(next->d_inode)))
57540 return 0;
57541 spin_lock(&dentry->d_lock);
57542 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
57543 index acd3947..1f896e2 100644
57544 --- a/fs/lockd/clntproc.c
57545 +++ b/fs/lockd/clntproc.c
57546 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
57547 /*
57548 * Cookie counter for NLM requests
57549 */
57550 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
57551 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
57552
57553 void nlmclnt_next_cookie(struct nlm_cookie *c)
57554 {
57555 - u32 cookie = atomic_inc_return(&nlm_cookie);
57556 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
57557
57558 memcpy(c->data, &cookie, 4);
57559 c->len=4;
57560 diff --git a/fs/locks.c b/fs/locks.c
57561 index b27a300..4156d0b 100644
57562 --- a/fs/locks.c
57563 +++ b/fs/locks.c
57564 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
57565 return;
57566
57567 if (filp->f_op && filp->f_op->flock) {
57568 - struct file_lock fl = {
57569 + struct file_lock flock = {
57570 .fl_pid = current->tgid,
57571 .fl_file = filp,
57572 .fl_flags = FL_FLOCK,
57573 .fl_type = F_UNLCK,
57574 .fl_end = OFFSET_MAX,
57575 };
57576 - filp->f_op->flock(filp, F_SETLKW, &fl);
57577 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
57578 - fl.fl_ops->fl_release_private(&fl);
57579 + filp->f_op->flock(filp, F_SETLKW, &flock);
57580 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
57581 + flock.fl_ops->fl_release_private(&flock);
57582 }
57583
57584 spin_lock(&inode->i_lock);
57585 diff --git a/fs/namei.c b/fs/namei.c
57586 index 7720fbd..7934bb2 100644
57587 --- a/fs/namei.c
57588 +++ b/fs/namei.c
57589 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
57590 if (ret != -EACCES)
57591 return ret;
57592
57593 +#ifdef CONFIG_GRKERNSEC
57594 + /* we'll block if we have to log due to a denied capability use */
57595 + if (mask & MAY_NOT_BLOCK)
57596 + return -ECHILD;
57597 +#endif
57598 +
57599 if (S_ISDIR(inode->i_mode)) {
57600 /* DACs are overridable for directories */
57601 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
57602 - return 0;
57603 if (!(mask & MAY_WRITE))
57604 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57605 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57606 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57607 return 0;
57608 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
57609 + return 0;
57610 return -EACCES;
57611 }
57612 /*
57613 + * Searching includes executable on directories, else just read.
57614 + */
57615 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57616 + if (mask == MAY_READ)
57617 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
57618 + inode_capable(inode, CAP_DAC_READ_SEARCH))
57619 + return 0;
57620 +
57621 + /*
57622 * Read/write DACs are always overridable.
57623 * Executable DACs are overridable when there is
57624 * at least one exec bit set.
57625 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
57626 if (inode_capable(inode, CAP_DAC_OVERRIDE))
57627 return 0;
57628
57629 - /*
57630 - * Searching includes executable on directories, else just read.
57631 - */
57632 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
57633 - if (mask == MAY_READ)
57634 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
57635 - return 0;
57636 -
57637 return -EACCES;
57638 }
57639
57640 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57641 {
57642 struct dentry *dentry = link->dentry;
57643 int error;
57644 - char *s;
57645 + const char *s;
57646
57647 BUG_ON(nd->flags & LOOKUP_RCU);
57648
57649 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
57650 if (error)
57651 goto out_put_nd_path;
57652
57653 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
57654 + dentry->d_inode, dentry, nd->path.mnt)) {
57655 + error = -EACCES;
57656 + goto out_put_nd_path;
57657 + }
57658 +
57659 nd->last_type = LAST_BIND;
57660 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
57661 error = PTR_ERR(*p);
57662 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
57663 if (res)
57664 break;
57665 res = walk_component(nd, path, LOOKUP_FOLLOW);
57666 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
57667 + res = -EACCES;
57668 put_link(nd, &link, cookie);
57669 } while (res > 0);
57670
57671 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
57672 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
57673 {
57674 unsigned long a, b, adata, bdata, mask, hash, len;
57675 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57676 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
57677
57678 hash = a = 0;
57679 len = -sizeof(unsigned long);
57680 @@ -1967,6 +1983,8 @@ static int path_lookupat(int dfd, const char *name,
57681 if (err)
57682 break;
57683 err = lookup_last(nd, &path);
57684 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
57685 + err = -EACCES;
57686 put_link(nd, &link, cookie);
57687 }
57688 }
57689 @@ -1974,6 +1992,13 @@ static int path_lookupat(int dfd, const char *name,
57690 if (!err)
57691 err = complete_walk(nd);
57692
57693 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
57694 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57695 + path_put(&nd->path);
57696 + err = -ENOENT;
57697 + }
57698 + }
57699 +
57700 if (!err && nd->flags & LOOKUP_DIRECTORY) {
57701 if (!can_lookup(nd->inode)) {
57702 path_put(&nd->path);
57703 @@ -2001,8 +2026,15 @@ static int filename_lookup(int dfd, struct filename *name,
57704 retval = path_lookupat(dfd, name->name,
57705 flags | LOOKUP_REVAL, nd);
57706
57707 - if (likely(!retval))
57708 + if (likely(!retval)) {
57709 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
57710 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
57711 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
57712 + path_put(&nd->path);
57713 + return -ENOENT;
57714 + }
57715 + }
57716 + }
57717 return retval;
57718 }
57719
57720 @@ -2380,6 +2412,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
57721 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
57722 return -EPERM;
57723
57724 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
57725 + return -EPERM;
57726 + if (gr_handle_rawio(inode))
57727 + return -EPERM;
57728 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
57729 + return -EACCES;
57730 +
57731 return 0;
57732 }
57733
57734 @@ -2601,7 +2640,7 @@ looked_up:
57735 * cleared otherwise prior to returning.
57736 */
57737 static int lookup_open(struct nameidata *nd, struct path *path,
57738 - struct file *file,
57739 + struct path *link, struct file *file,
57740 const struct open_flags *op,
57741 bool got_write, int *opened)
57742 {
57743 @@ -2636,6 +2675,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57744 /* Negative dentry, just create the file */
57745 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
57746 umode_t mode = op->mode;
57747 +
57748 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
57749 + error = -EACCES;
57750 + goto out_dput;
57751 + }
57752 +
57753 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
57754 + error = -EACCES;
57755 + goto out_dput;
57756 + }
57757 +
57758 if (!IS_POSIXACL(dir->d_inode))
57759 mode &= ~current_umask();
57760 /*
57761 @@ -2657,6 +2707,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
57762 nd->flags & LOOKUP_EXCL);
57763 if (error)
57764 goto out_dput;
57765 + else
57766 + gr_handle_create(dentry, nd->path.mnt);
57767 }
57768 out_no_open:
57769 path->dentry = dentry;
57770 @@ -2671,7 +2723,7 @@ out_dput:
57771 /*
57772 * Handle the last step of open()
57773 */
57774 -static int do_last(struct nameidata *nd, struct path *path,
57775 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
57776 struct file *file, const struct open_flags *op,
57777 int *opened, struct filename *name)
57778 {
57779 @@ -2721,6 +2773,15 @@ static int do_last(struct nameidata *nd, struct path *path,
57780 if (error)
57781 return error;
57782
57783 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
57784 + error = -ENOENT;
57785 + goto out;
57786 + }
57787 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57788 + error = -EACCES;
57789 + goto out;
57790 + }
57791 +
57792 audit_inode(name, dir, LOOKUP_PARENT);
57793 error = -EISDIR;
57794 /* trailing slashes? */
57795 @@ -2740,7 +2801,7 @@ retry_lookup:
57796 */
57797 }
57798 mutex_lock(&dir->d_inode->i_mutex);
57799 - error = lookup_open(nd, path, file, op, got_write, opened);
57800 + error = lookup_open(nd, path, link, file, op, got_write, opened);
57801 mutex_unlock(&dir->d_inode->i_mutex);
57802
57803 if (error <= 0) {
57804 @@ -2764,11 +2825,28 @@ retry_lookup:
57805 goto finish_open_created;
57806 }
57807
57808 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
57809 + error = -ENOENT;
57810 + goto exit_dput;
57811 + }
57812 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
57813 + error = -EACCES;
57814 + goto exit_dput;
57815 + }
57816 +
57817 /*
57818 * create/update audit record if it already exists.
57819 */
57820 - if (path->dentry->d_inode)
57821 + if (path->dentry->d_inode) {
57822 + /* only check if O_CREAT is specified, all other checks need to go
57823 + into may_open */
57824 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
57825 + error = -EACCES;
57826 + goto exit_dput;
57827 + }
57828 +
57829 audit_inode(name, path->dentry, 0);
57830 + }
57831
57832 /*
57833 * If atomic_open() acquired write access it is dropped now due to
57834 @@ -2809,6 +2887,11 @@ finish_lookup:
57835 }
57836 }
57837 BUG_ON(inode != path->dentry->d_inode);
57838 + /* if we're resolving a symlink to another symlink */
57839 + if (link && gr_handle_symlink_owner(link, inode)) {
57840 + error = -EACCES;
57841 + goto out;
57842 + }
57843 return 1;
57844 }
57845
57846 @@ -2818,7 +2901,6 @@ finish_lookup:
57847 save_parent.dentry = nd->path.dentry;
57848 save_parent.mnt = mntget(path->mnt);
57849 nd->path.dentry = path->dentry;
57850 -
57851 }
57852 nd->inode = inode;
57853 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
57854 @@ -2828,7 +2910,18 @@ finish_open:
57855 path_put(&save_parent);
57856 return error;
57857 }
57858 +
57859 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
57860 + error = -ENOENT;
57861 + goto out;
57862 + }
57863 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
57864 + error = -EACCES;
57865 + goto out;
57866 + }
57867 +
57868 audit_inode(name, nd->path.dentry, 0);
57869 +
57870 error = -EISDIR;
57871 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
57872 goto out;
57873 @@ -2991,7 +3084,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57874 if (unlikely(error))
57875 goto out;
57876
57877 - error = do_last(nd, &path, file, op, &opened, pathname);
57878 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
57879 while (unlikely(error > 0)) { /* trailing symlink */
57880 struct path link = path;
57881 void *cookie;
57882 @@ -3009,7 +3102,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
57883 error = follow_link(&link, nd, &cookie);
57884 if (unlikely(error))
57885 break;
57886 - error = do_last(nd, &path, file, op, &opened, pathname);
57887 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
57888 put_link(nd, &link, cookie);
57889 }
57890 out:
57891 @@ -3109,8 +3202,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
57892 goto unlock;
57893
57894 error = -EEXIST;
57895 - if (dentry->d_inode)
57896 + if (dentry->d_inode) {
57897 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
57898 + error = -ENOENT;
57899 + }
57900 goto fail;
57901 + }
57902 /*
57903 * Special case - lookup gave negative, but... we had foo/bar/
57904 * From the vfs_mknod() POV we just have a negative dentry -
57905 @@ -3162,6 +3259,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
57906 }
57907 EXPORT_SYMBOL(user_path_create);
57908
57909 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
57910 +{
57911 + struct filename *tmp = getname(pathname);
57912 + struct dentry *res;
57913 + if (IS_ERR(tmp))
57914 + return ERR_CAST(tmp);
57915 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
57916 + if (IS_ERR(res))
57917 + putname(tmp);
57918 + else
57919 + *to = tmp;
57920 + return res;
57921 +}
57922 +
57923 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
57924 {
57925 int error = may_create(dir, dentry);
57926 @@ -3224,6 +3335,17 @@ retry:
57927
57928 if (!IS_POSIXACL(path.dentry->d_inode))
57929 mode &= ~current_umask();
57930 +
57931 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
57932 + error = -EPERM;
57933 + goto out;
57934 + }
57935 +
57936 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
57937 + error = -EACCES;
57938 + goto out;
57939 + }
57940 +
57941 error = security_path_mknod(&path, dentry, mode, dev);
57942 if (error)
57943 goto out;
57944 @@ -3240,6 +3362,8 @@ retry:
57945 break;
57946 }
57947 out:
57948 + if (!error)
57949 + gr_handle_create(dentry, path.mnt);
57950 done_path_create(&path, dentry);
57951 if (retry_estale(error, lookup_flags)) {
57952 lookup_flags |= LOOKUP_REVAL;
57953 @@ -3292,9 +3416,16 @@ retry:
57954
57955 if (!IS_POSIXACL(path.dentry->d_inode))
57956 mode &= ~current_umask();
57957 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
57958 + error = -EACCES;
57959 + goto out;
57960 + }
57961 error = security_path_mkdir(&path, dentry, mode);
57962 if (!error)
57963 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
57964 + if (!error)
57965 + gr_handle_create(dentry, path.mnt);
57966 +out:
57967 done_path_create(&path, dentry);
57968 if (retry_estale(error, lookup_flags)) {
57969 lookup_flags |= LOOKUP_REVAL;
57970 @@ -3375,6 +3506,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
57971 struct filename *name;
57972 struct dentry *dentry;
57973 struct nameidata nd;
57974 + ino_t saved_ino = 0;
57975 + dev_t saved_dev = 0;
57976 unsigned int lookup_flags = 0;
57977 retry:
57978 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
57979 @@ -3407,10 +3540,21 @@ retry:
57980 error = -ENOENT;
57981 goto exit3;
57982 }
57983 +
57984 + saved_ino = dentry->d_inode->i_ino;
57985 + saved_dev = gr_get_dev_from_dentry(dentry);
57986 +
57987 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
57988 + error = -EACCES;
57989 + goto exit3;
57990 + }
57991 +
57992 error = security_path_rmdir(&nd.path, dentry);
57993 if (error)
57994 goto exit3;
57995 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
57996 + if (!error && (saved_dev || saved_ino))
57997 + gr_handle_delete(saved_ino, saved_dev);
57998 exit3:
57999 dput(dentry);
58000 exit2:
58001 @@ -3476,6 +3620,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
58002 struct dentry *dentry;
58003 struct nameidata nd;
58004 struct inode *inode = NULL;
58005 + ino_t saved_ino = 0;
58006 + dev_t saved_dev = 0;
58007 unsigned int lookup_flags = 0;
58008 retry:
58009 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
58010 @@ -3502,10 +3648,22 @@ retry:
58011 if (!inode)
58012 goto slashes;
58013 ihold(inode);
58014 +
58015 + if (inode->i_nlink <= 1) {
58016 + saved_ino = inode->i_ino;
58017 + saved_dev = gr_get_dev_from_dentry(dentry);
58018 + }
58019 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
58020 + error = -EACCES;
58021 + goto exit2;
58022 + }
58023 +
58024 error = security_path_unlink(&nd.path, dentry);
58025 if (error)
58026 goto exit2;
58027 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
58028 + if (!error && (saved_ino || saved_dev))
58029 + gr_handle_delete(saved_ino, saved_dev);
58030 exit2:
58031 dput(dentry);
58032 }
58033 @@ -3583,9 +3741,17 @@ retry:
58034 if (IS_ERR(dentry))
58035 goto out_putname;
58036
58037 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
58038 + error = -EACCES;
58039 + goto out;
58040 + }
58041 +
58042 error = security_path_symlink(&path, dentry, from->name);
58043 if (!error)
58044 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
58045 + if (!error)
58046 + gr_handle_create(dentry, path.mnt);
58047 +out:
58048 done_path_create(&path, dentry);
58049 if (retry_estale(error, lookup_flags)) {
58050 lookup_flags |= LOOKUP_REVAL;
58051 @@ -3665,6 +3831,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
58052 {
58053 struct dentry *new_dentry;
58054 struct path old_path, new_path;
58055 + struct filename *to = NULL;
58056 int how = 0;
58057 int error;
58058
58059 @@ -3688,7 +3855,7 @@ retry:
58060 if (error)
58061 return error;
58062
58063 - new_dentry = user_path_create(newdfd, newname, &new_path,
58064 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
58065 (how & LOOKUP_REVAL));
58066 error = PTR_ERR(new_dentry);
58067 if (IS_ERR(new_dentry))
58068 @@ -3700,11 +3867,28 @@ retry:
58069 error = may_linkat(&old_path);
58070 if (unlikely(error))
58071 goto out_dput;
58072 +
58073 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
58074 + old_path.dentry->d_inode,
58075 + old_path.dentry->d_inode->i_mode, to)) {
58076 + error = -EACCES;
58077 + goto out_dput;
58078 + }
58079 +
58080 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
58081 + old_path.dentry, old_path.mnt, to)) {
58082 + error = -EACCES;
58083 + goto out_dput;
58084 + }
58085 +
58086 error = security_path_link(old_path.dentry, &new_path, new_dentry);
58087 if (error)
58088 goto out_dput;
58089 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
58090 + if (!error)
58091 + gr_handle_create(new_dentry, new_path.mnt);
58092 out_dput:
58093 + putname(to);
58094 done_path_create(&new_path, new_dentry);
58095 if (retry_estale(error, how)) {
58096 how |= LOOKUP_REVAL;
58097 @@ -3950,12 +4134,21 @@ retry:
58098 if (new_dentry == trap)
58099 goto exit5;
58100
58101 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
58102 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
58103 + to);
58104 + if (error)
58105 + goto exit5;
58106 +
58107 error = security_path_rename(&oldnd.path, old_dentry,
58108 &newnd.path, new_dentry);
58109 if (error)
58110 goto exit5;
58111 error = vfs_rename(old_dir->d_inode, old_dentry,
58112 new_dir->d_inode, new_dentry);
58113 + if (!error)
58114 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
58115 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
58116 exit5:
58117 dput(new_dentry);
58118 exit4:
58119 @@ -3987,6 +4180,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
58120
58121 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
58122 {
58123 + char tmpbuf[64];
58124 + const char *newlink;
58125 int len;
58126
58127 len = PTR_ERR(link);
58128 @@ -3996,7 +4191,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
58129 len = strlen(link);
58130 if (len > (unsigned) buflen)
58131 len = buflen;
58132 - if (copy_to_user(buffer, link, len))
58133 +
58134 + if (len < sizeof(tmpbuf)) {
58135 + memcpy(tmpbuf, link, len);
58136 + newlink = tmpbuf;
58137 + } else
58138 + newlink = link;
58139 +
58140 + if (copy_to_user(buffer, newlink, len))
58141 len = -EFAULT;
58142 out:
58143 return len;
58144 diff --git a/fs/namespace.c b/fs/namespace.c
58145 index a45ba4f..b4c7d07 100644
58146 --- a/fs/namespace.c
58147 +++ b/fs/namespace.c
58148 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
58149 if (!(sb->s_flags & MS_RDONLY))
58150 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
58151 up_write(&sb->s_umount);
58152 +
58153 + gr_log_remount(mnt->mnt_devname, retval);
58154 +
58155 return retval;
58156 }
58157
58158 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
58159 }
58160 br_write_unlock(&vfsmount_lock);
58161 namespace_unlock();
58162 +
58163 + gr_log_unmount(mnt->mnt_devname, retval);
58164 +
58165 return retval;
58166 }
58167
58168 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
58169 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
58170 */
58171
58172 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
58173 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
58174 {
58175 struct path path;
58176 struct mount *mnt;
58177 @@ -1342,7 +1348,7 @@ out:
58178 /*
58179 * The 2.0 compatible umount. No flags.
58180 */
58181 -SYSCALL_DEFINE1(oldumount, char __user *, name)
58182 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
58183 {
58184 return sys_umount(name, 0);
58185 }
58186 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
58187 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
58188 MS_STRICTATIME);
58189
58190 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
58191 + retval = -EPERM;
58192 + goto dput_out;
58193 + }
58194 +
58195 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
58196 + retval = -EPERM;
58197 + goto dput_out;
58198 + }
58199 +
58200 if (flags & MS_REMOUNT)
58201 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
58202 data_page);
58203 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
58204 dev_name, data_page);
58205 dput_out:
58206 path_put(&path);
58207 +
58208 + gr_log_mount(dev_name, dir_name, retval);
58209 +
58210 return retval;
58211 }
58212
58213 @@ -2344,7 +2363,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
58214 * number incrementing at 10Ghz will take 12,427 years to wrap which
58215 * is effectively never, so we can ignore the possibility.
58216 */
58217 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
58218 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
58219
58220 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58221 {
58222 @@ -2359,7 +2378,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58223 kfree(new_ns);
58224 return ERR_PTR(ret);
58225 }
58226 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
58227 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
58228 atomic_set(&new_ns->count, 1);
58229 new_ns->root = NULL;
58230 INIT_LIST_HEAD(&new_ns->list);
58231 @@ -2373,7 +2392,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
58232 * Allocate a new namespace structure and populate it with contents
58233 * copied from the namespace of the passed in task structure.
58234 */
58235 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58236 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
58237 struct user_namespace *user_ns, struct fs_struct *fs)
58238 {
58239 struct mnt_namespace *new_ns;
58240 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
58241 }
58242 EXPORT_SYMBOL(mount_subtree);
58243
58244 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
58245 - char __user *, type, unsigned long, flags, void __user *, data)
58246 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
58247 + const char __user *, type, unsigned long, flags, void __user *, data)
58248 {
58249 int ret;
58250 char *kernel_type;
58251 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
58252 if (error)
58253 goto out2;
58254
58255 + if (gr_handle_chroot_pivot()) {
58256 + error = -EPERM;
58257 + goto out2;
58258 + }
58259 +
58260 get_fs_root(current->fs, &root);
58261 old_mp = lock_mount(&old);
58262 error = PTR_ERR(old_mp);
58263 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
58264 !nsown_capable(CAP_SYS_ADMIN))
58265 return -EPERM;
58266
58267 - if (fs->users != 1)
58268 + if (atomic_read(&fs->users) != 1)
58269 return -EINVAL;
58270
58271 get_mnt_ns(mnt_ns);
58272 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
58273 index f4ccfe6..a5cf064 100644
58274 --- a/fs/nfs/callback_xdr.c
58275 +++ b/fs/nfs/callback_xdr.c
58276 @@ -51,7 +51,7 @@ struct callback_op {
58277 callback_decode_arg_t decode_args;
58278 callback_encode_res_t encode_res;
58279 long res_maxsize;
58280 -};
58281 +} __do_const;
58282
58283 static struct callback_op callback_ops[];
58284
58285 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
58286 index 941246f..17d8724 100644
58287 --- a/fs/nfs/inode.c
58288 +++ b/fs/nfs/inode.c
58289 @@ -1138,16 +1138,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
58290 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
58291 }
58292
58293 -static atomic_long_t nfs_attr_generation_counter;
58294 +static atomic_long_unchecked_t nfs_attr_generation_counter;
58295
58296 static unsigned long nfs_read_attr_generation_counter(void)
58297 {
58298 - return atomic_long_read(&nfs_attr_generation_counter);
58299 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
58300 }
58301
58302 unsigned long nfs_inc_attr_generation_counter(void)
58303 {
58304 - return atomic_long_inc_return(&nfs_attr_generation_counter);
58305 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
58306 }
58307
58308 void nfs_fattr_init(struct nfs_fattr *fattr)
58309 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
58310 index 419572f..5414a23 100644
58311 --- a/fs/nfsd/nfs4proc.c
58312 +++ b/fs/nfsd/nfs4proc.c
58313 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
58314 nfsd4op_rsize op_rsize_bop;
58315 stateid_getter op_get_currentstateid;
58316 stateid_setter op_set_currentstateid;
58317 -};
58318 +} __do_const;
58319
58320 static struct nfsd4_operation nfsd4_ops[];
58321
58322 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
58323 index c2a4701..fd80e29 100644
58324 --- a/fs/nfsd/nfs4xdr.c
58325 +++ b/fs/nfsd/nfs4xdr.c
58326 @@ -1498,7 +1498,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
58327
58328 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
58329
58330 -static nfsd4_dec nfsd4_dec_ops[] = {
58331 +static const nfsd4_dec nfsd4_dec_ops[] = {
58332 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58333 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58334 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58335 @@ -1538,7 +1538,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
58336 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
58337 };
58338
58339 -static nfsd4_dec nfsd41_dec_ops[] = {
58340 +static const nfsd4_dec nfsd41_dec_ops[] = {
58341 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
58342 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
58343 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
58344 @@ -1600,7 +1600,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
58345 };
58346
58347 struct nfsd4_minorversion_ops {
58348 - nfsd4_dec *decoders;
58349 + const nfsd4_dec *decoders;
58350 int nops;
58351 };
58352
58353 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
58354 index e76244e..9fe8f2f1 100644
58355 --- a/fs/nfsd/nfscache.c
58356 +++ b/fs/nfsd/nfscache.c
58357 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
58358 {
58359 struct svc_cacherep *rp = rqstp->rq_cacherep;
58360 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
58361 - int len;
58362 + long len;
58363 size_t bufsize = 0;
58364
58365 if (!rp)
58366 return;
58367
58368 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
58369 - len >>= 2;
58370 + if (statp) {
58371 + len = (char*)statp - (char*)resv->iov_base;
58372 + len = resv->iov_len - len;
58373 + len >>= 2;
58374 + }
58375
58376 /* Don't cache excessive amounts of data and XDR failures */
58377 if (!statp || len > (256 >> 2)) {
58378 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
58379 index c827acb..b253b77 100644
58380 --- a/fs/nfsd/vfs.c
58381 +++ b/fs/nfsd/vfs.c
58382 @@ -968,7 +968,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58383 } else {
58384 oldfs = get_fs();
58385 set_fs(KERNEL_DS);
58386 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
58387 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
58388 set_fs(oldfs);
58389 }
58390
58391 @@ -1055,7 +1055,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
58392
58393 /* Write the data. */
58394 oldfs = get_fs(); set_fs(KERNEL_DS);
58395 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
58396 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
58397 set_fs(oldfs);
58398 if (host_err < 0)
58399 goto out_nfserr;
58400 @@ -1601,7 +1601,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
58401 */
58402
58403 oldfs = get_fs(); set_fs(KERNEL_DS);
58404 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
58405 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
58406 set_fs(oldfs);
58407
58408 if (host_err < 0)
58409 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
58410 index fea6bd5..8ee9d81 100644
58411 --- a/fs/nls/nls_base.c
58412 +++ b/fs/nls/nls_base.c
58413 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
58414
58415 int register_nls(struct nls_table * nls)
58416 {
58417 - struct nls_table ** tmp = &tables;
58418 + struct nls_table *tmp = tables;
58419
58420 if (nls->next)
58421 return -EBUSY;
58422
58423 spin_lock(&nls_lock);
58424 - while (*tmp) {
58425 - if (nls == *tmp) {
58426 + while (tmp) {
58427 + if (nls == tmp) {
58428 spin_unlock(&nls_lock);
58429 return -EBUSY;
58430 }
58431 - tmp = &(*tmp)->next;
58432 + tmp = tmp->next;
58433 }
58434 - nls->next = tables;
58435 + pax_open_kernel();
58436 + *(struct nls_table **)&nls->next = tables;
58437 + pax_close_kernel();
58438 tables = nls;
58439 spin_unlock(&nls_lock);
58440 return 0;
58441 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
58442
58443 int unregister_nls(struct nls_table * nls)
58444 {
58445 - struct nls_table ** tmp = &tables;
58446 + struct nls_table * const * tmp = &tables;
58447
58448 spin_lock(&nls_lock);
58449 while (*tmp) {
58450 if (nls == *tmp) {
58451 - *tmp = nls->next;
58452 + pax_open_kernel();
58453 + *(struct nls_table **)tmp = nls->next;
58454 + pax_close_kernel();
58455 spin_unlock(&nls_lock);
58456 return 0;
58457 }
58458 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
58459 index 7424929..35f6be5 100644
58460 --- a/fs/nls/nls_euc-jp.c
58461 +++ b/fs/nls/nls_euc-jp.c
58462 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
58463 p_nls = load_nls("cp932");
58464
58465 if (p_nls) {
58466 - table.charset2upper = p_nls->charset2upper;
58467 - table.charset2lower = p_nls->charset2lower;
58468 + pax_open_kernel();
58469 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58470 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58471 + pax_close_kernel();
58472 return register_nls(&table);
58473 }
58474
58475 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
58476 index e7bc1d7..06bd4bb 100644
58477 --- a/fs/nls/nls_koi8-ru.c
58478 +++ b/fs/nls/nls_koi8-ru.c
58479 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
58480 p_nls = load_nls("koi8-u");
58481
58482 if (p_nls) {
58483 - table.charset2upper = p_nls->charset2upper;
58484 - table.charset2lower = p_nls->charset2lower;
58485 + pax_open_kernel();
58486 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
58487 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
58488 + pax_close_kernel();
58489 return register_nls(&table);
58490 }
58491
58492 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
58493 index e44cb64..4807084 100644
58494 --- a/fs/notify/fanotify/fanotify_user.c
58495 +++ b/fs/notify/fanotify/fanotify_user.c
58496 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
58497
58498 fd = fanotify_event_metadata.fd;
58499 ret = -EFAULT;
58500 - if (copy_to_user(buf, &fanotify_event_metadata,
58501 - fanotify_event_metadata.event_len))
58502 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
58503 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
58504 goto out_close_fd;
58505
58506 ret = prepare_for_access_response(group, event, fd);
58507 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
58508 index 7b51b05..5ea5ef6 100644
58509 --- a/fs/notify/notification.c
58510 +++ b/fs/notify/notification.c
58511 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
58512 * get set to 0 so it will never get 'freed'
58513 */
58514 static struct fsnotify_event *q_overflow_event;
58515 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58516 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58517
58518 /**
58519 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
58520 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
58521 */
58522 u32 fsnotify_get_cookie(void)
58523 {
58524 - return atomic_inc_return(&fsnotify_sync_cookie);
58525 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
58526 }
58527 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
58528
58529 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
58530 index 9e38daf..5727cae 100644
58531 --- a/fs/ntfs/dir.c
58532 +++ b/fs/ntfs/dir.c
58533 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
58534 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
58535 ~(s64)(ndir->itype.index.block_size - 1)));
58536 /* Bounds checks. */
58537 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58538 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
58539 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
58540 "inode 0x%lx or driver bug.", vdir->i_ino);
58541 goto err_out;
58542 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
58543 index c5670b8..d590213 100644
58544 --- a/fs/ntfs/file.c
58545 +++ b/fs/ntfs/file.c
58546 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
58547 char *addr;
58548 size_t total = 0;
58549 unsigned len;
58550 - int left;
58551 + unsigned left;
58552
58553 do {
58554 len = PAGE_CACHE_SIZE - ofs;
58555 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
58556 index 82650d5..db37dcf 100644
58557 --- a/fs/ntfs/super.c
58558 +++ b/fs/ntfs/super.c
58559 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58560 if (!silent)
58561 ntfs_error(sb, "Primary boot sector is invalid.");
58562 } else if (!silent)
58563 - ntfs_error(sb, read_err_str, "primary");
58564 + ntfs_error(sb, read_err_str, "%s", "primary");
58565 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
58566 if (bh_primary)
58567 brelse(bh_primary);
58568 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58569 goto hotfix_primary_boot_sector;
58570 brelse(bh_backup);
58571 } else if (!silent)
58572 - ntfs_error(sb, read_err_str, "backup");
58573 + ntfs_error(sb, read_err_str, "%s", "backup");
58574 /* Try to read NT3.51- backup boot sector. */
58575 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
58576 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
58577 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
58578 "sector.");
58579 brelse(bh_backup);
58580 } else if (!silent)
58581 - ntfs_error(sb, read_err_str, "backup");
58582 + ntfs_error(sb, read_err_str, "%s", "backup");
58583 /* We failed. Cleanup and return. */
58584 if (bh_primary)
58585 brelse(bh_primary);
58586 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
58587 index aebeacd..0dcdd26 100644
58588 --- a/fs/ocfs2/localalloc.c
58589 +++ b/fs/ocfs2/localalloc.c
58590 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
58591 goto bail;
58592 }
58593
58594 - atomic_inc(&osb->alloc_stats.moves);
58595 + atomic_inc_unchecked(&osb->alloc_stats.moves);
58596
58597 bail:
58598 if (handle)
58599 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
58600 index 3a90347..c40bef8 100644
58601 --- a/fs/ocfs2/ocfs2.h
58602 +++ b/fs/ocfs2/ocfs2.h
58603 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
58604
58605 struct ocfs2_alloc_stats
58606 {
58607 - atomic_t moves;
58608 - atomic_t local_data;
58609 - atomic_t bitmap_data;
58610 - atomic_t bg_allocs;
58611 - atomic_t bg_extends;
58612 + atomic_unchecked_t moves;
58613 + atomic_unchecked_t local_data;
58614 + atomic_unchecked_t bitmap_data;
58615 + atomic_unchecked_t bg_allocs;
58616 + atomic_unchecked_t bg_extends;
58617 };
58618
58619 enum ocfs2_local_alloc_state
58620 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
58621 index 5397c07..54afc55 100644
58622 --- a/fs/ocfs2/suballoc.c
58623 +++ b/fs/ocfs2/suballoc.c
58624 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
58625 mlog_errno(status);
58626 goto bail;
58627 }
58628 - atomic_inc(&osb->alloc_stats.bg_extends);
58629 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
58630
58631 /* You should never ask for this much metadata */
58632 BUG_ON(bits_wanted >
58633 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
58634 mlog_errno(status);
58635 goto bail;
58636 }
58637 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58638 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58639
58640 *suballoc_loc = res.sr_bg_blkno;
58641 *suballoc_bit_start = res.sr_bit_offset;
58642 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
58643 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
58644 res->sr_bits);
58645
58646 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58647 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58648
58649 BUG_ON(res->sr_bits != 1);
58650
58651 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
58652 mlog_errno(status);
58653 goto bail;
58654 }
58655 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58656 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
58657
58658 BUG_ON(res.sr_bits != 1);
58659
58660 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58661 cluster_start,
58662 num_clusters);
58663 if (!status)
58664 - atomic_inc(&osb->alloc_stats.local_data);
58665 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
58666 } else {
58667 if (min_clusters > (osb->bitmap_cpg - 1)) {
58668 /* The only paths asking for contiguousness
58669 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
58670 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
58671 res.sr_bg_blkno,
58672 res.sr_bit_offset);
58673 - atomic_inc(&osb->alloc_stats.bitmap_data);
58674 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
58675 *num_clusters = res.sr_bits;
58676 }
58677 }
58678 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
58679 index 121da2d..a0232bc 100644
58680 --- a/fs/ocfs2/super.c
58681 +++ b/fs/ocfs2/super.c
58682 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
58683 "%10s => GlobalAllocs: %d LocalAllocs: %d "
58684 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
58685 "Stats",
58686 - atomic_read(&osb->alloc_stats.bitmap_data),
58687 - atomic_read(&osb->alloc_stats.local_data),
58688 - atomic_read(&osb->alloc_stats.bg_allocs),
58689 - atomic_read(&osb->alloc_stats.moves),
58690 - atomic_read(&osb->alloc_stats.bg_extends));
58691 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
58692 + atomic_read_unchecked(&osb->alloc_stats.local_data),
58693 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
58694 + atomic_read_unchecked(&osb->alloc_stats.moves),
58695 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
58696
58697 out += snprintf(buf + out, len - out,
58698 "%10s => State: %u Descriptor: %llu Size: %u bits "
58699 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
58700 spin_lock_init(&osb->osb_xattr_lock);
58701 ocfs2_init_steal_slots(osb);
58702
58703 - atomic_set(&osb->alloc_stats.moves, 0);
58704 - atomic_set(&osb->alloc_stats.local_data, 0);
58705 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
58706 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
58707 - atomic_set(&osb->alloc_stats.bg_extends, 0);
58708 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
58709 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
58710 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
58711 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
58712 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
58713
58714 /* Copy the blockcheck stats from the superblock probe */
58715 osb->osb_ecc_stats = *stats;
58716 diff --git a/fs/open.c b/fs/open.c
58717 index 7931f76..7b03f3b 100644
58718 --- a/fs/open.c
58719 +++ b/fs/open.c
58720 @@ -32,6 +32,8 @@
58721 #include <linux/dnotify.h>
58722 #include <linux/compat.h>
58723
58724 +#define CREATE_TRACE_POINTS
58725 +#include <trace/events/fs.h>
58726 #include "internal.h"
58727
58728 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
58729 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
58730 error = locks_verify_truncate(inode, NULL, length);
58731 if (!error)
58732 error = security_path_truncate(path);
58733 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
58734 + error = -EACCES;
58735 if (!error)
58736 error = do_truncate(path->dentry, length, 0, NULL);
58737
58738 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
58739 error = locks_verify_truncate(inode, f.file, length);
58740 if (!error)
58741 error = security_path_truncate(&f.file->f_path);
58742 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
58743 + error = -EACCES;
58744 if (!error)
58745 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
58746 sb_end_write(inode->i_sb);
58747 @@ -360,6 +366,9 @@ retry:
58748 if (__mnt_is_readonly(path.mnt))
58749 res = -EROFS;
58750
58751 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
58752 + res = -EACCES;
58753 +
58754 out_path_release:
58755 path_put(&path);
58756 if (retry_estale(res, lookup_flags)) {
58757 @@ -391,6 +400,8 @@ retry:
58758 if (error)
58759 goto dput_and_out;
58760
58761 + gr_log_chdir(path.dentry, path.mnt);
58762 +
58763 set_fs_pwd(current->fs, &path);
58764
58765 dput_and_out:
58766 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
58767 goto out_putf;
58768
58769 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
58770 +
58771 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
58772 + error = -EPERM;
58773 +
58774 + if (!error)
58775 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
58776 +
58777 if (!error)
58778 set_fs_pwd(current->fs, &f.file->f_path);
58779 out_putf:
58780 @@ -449,7 +467,13 @@ retry:
58781 if (error)
58782 goto dput_and_out;
58783
58784 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
58785 + goto dput_and_out;
58786 +
58787 set_fs_root(current->fs, &path);
58788 +
58789 + gr_handle_chroot_chdir(&path);
58790 +
58791 error = 0;
58792 dput_and_out:
58793 path_put(&path);
58794 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
58795 if (error)
58796 return error;
58797 mutex_lock(&inode->i_mutex);
58798 +
58799 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
58800 + error = -EACCES;
58801 + goto out_unlock;
58802 + }
58803 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
58804 + error = -EACCES;
58805 + goto out_unlock;
58806 + }
58807 +
58808 error = security_path_chmod(path, mode);
58809 if (error)
58810 goto out_unlock;
58811 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
58812 uid = make_kuid(current_user_ns(), user);
58813 gid = make_kgid(current_user_ns(), group);
58814
58815 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
58816 + return -EACCES;
58817 +
58818 newattrs.ia_valid = ATTR_CTIME;
58819 if (user != (uid_t) -1) {
58820 if (!uid_valid(uid))
58821 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
58822 } else {
58823 fsnotify_open(f);
58824 fd_install(fd, f);
58825 + trace_do_sys_open(tmp->name, flags, mode);
58826 }
58827 }
58828 putname(tmp);
58829 diff --git a/fs/pipe.c b/fs/pipe.c
58830 index d2c45e1..009fe1c 100644
58831 --- a/fs/pipe.c
58832 +++ b/fs/pipe.c
58833 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
58834
58835 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
58836 {
58837 - if (pipe->files)
58838 + if (atomic_read(&pipe->files))
58839 mutex_lock_nested(&pipe->mutex, subclass);
58840 }
58841
58842 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
58843
58844 void pipe_unlock(struct pipe_inode_info *pipe)
58845 {
58846 - if (pipe->files)
58847 + if (atomic_read(&pipe->files))
58848 mutex_unlock(&pipe->mutex);
58849 }
58850 EXPORT_SYMBOL(pipe_unlock);
58851 @@ -449,9 +449,9 @@ redo:
58852 }
58853 if (bufs) /* More to do? */
58854 continue;
58855 - if (!pipe->writers)
58856 + if (!atomic_read(&pipe->writers))
58857 break;
58858 - if (!pipe->waiting_writers) {
58859 + if (!atomic_read(&pipe->waiting_writers)) {
58860 /* syscall merging: Usually we must not sleep
58861 * if O_NONBLOCK is set, or if we got some data.
58862 * But if a writer sleeps in kernel space, then
58863 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
58864 ret = 0;
58865 __pipe_lock(pipe);
58866
58867 - if (!pipe->readers) {
58868 + if (!atomic_read(&pipe->readers)) {
58869 send_sig(SIGPIPE, current, 0);
58870 ret = -EPIPE;
58871 goto out;
58872 @@ -562,7 +562,7 @@ redo1:
58873 for (;;) {
58874 int bufs;
58875
58876 - if (!pipe->readers) {
58877 + if (!atomic_read(&pipe->readers)) {
58878 send_sig(SIGPIPE, current, 0);
58879 if (!ret)
58880 ret = -EPIPE;
58881 @@ -653,9 +653,9 @@ redo2:
58882 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58883 do_wakeup = 0;
58884 }
58885 - pipe->waiting_writers++;
58886 + atomic_inc(&pipe->waiting_writers);
58887 pipe_wait(pipe);
58888 - pipe->waiting_writers--;
58889 + atomic_dec(&pipe->waiting_writers);
58890 }
58891 out:
58892 __pipe_unlock(pipe);
58893 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58894 mask = 0;
58895 if (filp->f_mode & FMODE_READ) {
58896 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
58897 - if (!pipe->writers && filp->f_version != pipe->w_counter)
58898 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
58899 mask |= POLLHUP;
58900 }
58901
58902 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
58903 * Most Unices do not set POLLERR for FIFOs but on Linux they
58904 * behave exactly like pipes for poll().
58905 */
58906 - if (!pipe->readers)
58907 + if (!atomic_read(&pipe->readers))
58908 mask |= POLLERR;
58909 }
58910
58911 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
58912
58913 __pipe_lock(pipe);
58914 if (file->f_mode & FMODE_READ)
58915 - pipe->readers--;
58916 + atomic_dec(&pipe->readers);
58917 if (file->f_mode & FMODE_WRITE)
58918 - pipe->writers--;
58919 + atomic_dec(&pipe->writers);
58920
58921 - if (pipe->readers || pipe->writers) {
58922 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
58923 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
58924 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
58925 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
58926 }
58927 spin_lock(&inode->i_lock);
58928 - if (!--pipe->files) {
58929 + if (atomic_dec_and_test(&pipe->files)) {
58930 inode->i_pipe = NULL;
58931 kill = 1;
58932 }
58933 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
58934 kfree(pipe);
58935 }
58936
58937 -static struct vfsmount *pipe_mnt __read_mostly;
58938 +struct vfsmount *pipe_mnt __read_mostly;
58939
58940 /*
58941 * pipefs_dname() is called from d_path().
58942 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
58943 goto fail_iput;
58944
58945 inode->i_pipe = pipe;
58946 - pipe->files = 2;
58947 - pipe->readers = pipe->writers = 1;
58948 + atomic_set(&pipe->files, 2);
58949 + atomic_set(&pipe->readers, 1);
58950 + atomic_set(&pipe->writers, 1);
58951 inode->i_fop = &pipefifo_fops;
58952
58953 /*
58954 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
58955 spin_lock(&inode->i_lock);
58956 if (inode->i_pipe) {
58957 pipe = inode->i_pipe;
58958 - pipe->files++;
58959 + atomic_inc(&pipe->files);
58960 spin_unlock(&inode->i_lock);
58961 } else {
58962 spin_unlock(&inode->i_lock);
58963 pipe = alloc_pipe_info();
58964 if (!pipe)
58965 return -ENOMEM;
58966 - pipe->files = 1;
58967 + atomic_set(&pipe->files, 1);
58968 spin_lock(&inode->i_lock);
58969 if (unlikely(inode->i_pipe)) {
58970 - inode->i_pipe->files++;
58971 + atomic_inc(&inode->i_pipe->files);
58972 spin_unlock(&inode->i_lock);
58973 free_pipe_info(pipe);
58974 pipe = inode->i_pipe;
58975 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
58976 * opened, even when there is no process writing the FIFO.
58977 */
58978 pipe->r_counter++;
58979 - if (pipe->readers++ == 0)
58980 + if (atomic_inc_return(&pipe->readers) == 1)
58981 wake_up_partner(pipe);
58982
58983 - if (!is_pipe && !pipe->writers) {
58984 + if (!is_pipe && !atomic_read(&pipe->writers)) {
58985 if ((filp->f_flags & O_NONBLOCK)) {
58986 /* suppress POLLHUP until we have
58987 * seen a writer */
58988 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
58989 * errno=ENXIO when there is no process reading the FIFO.
58990 */
58991 ret = -ENXIO;
58992 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
58993 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
58994 goto err;
58995
58996 pipe->w_counter++;
58997 - if (!pipe->writers++)
58998 + if (atomic_inc_return(&pipe->writers) == 1)
58999 wake_up_partner(pipe);
59000
59001 - if (!is_pipe && !pipe->readers) {
59002 + if (!is_pipe && !atomic_read(&pipe->readers)) {
59003 if (wait_for_partner(pipe, &pipe->r_counter))
59004 goto err_wr;
59005 }
59006 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
59007 * the process can at least talk to itself.
59008 */
59009
59010 - pipe->readers++;
59011 - pipe->writers++;
59012 + atomic_inc(&pipe->readers);
59013 + atomic_inc(&pipe->writers);
59014 pipe->r_counter++;
59015 pipe->w_counter++;
59016 - if (pipe->readers == 1 || pipe->writers == 1)
59017 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
59018 wake_up_partner(pipe);
59019 break;
59020
59021 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
59022 return 0;
59023
59024 err_rd:
59025 - if (!--pipe->readers)
59026 + if (atomic_dec_and_test(&pipe->readers))
59027 wake_up_interruptible(&pipe->wait);
59028 ret = -ERESTARTSYS;
59029 goto err;
59030
59031 err_wr:
59032 - if (!--pipe->writers)
59033 + if (atomic_dec_and_test(&pipe->writers))
59034 wake_up_interruptible(&pipe->wait);
59035 ret = -ERESTARTSYS;
59036 goto err;
59037
59038 err:
59039 spin_lock(&inode->i_lock);
59040 - if (!--pipe->files) {
59041 + if (atomic_dec_and_test(&pipe->files)) {
59042 inode->i_pipe = NULL;
59043 kill = 1;
59044 }
59045 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
59046 index 15af622..0e9f4467 100644
59047 --- a/fs/proc/Kconfig
59048 +++ b/fs/proc/Kconfig
59049 @@ -30,12 +30,12 @@ config PROC_FS
59050
59051 config PROC_KCORE
59052 bool "/proc/kcore support" if !ARM
59053 - depends on PROC_FS && MMU
59054 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
59055
59056 config PROC_VMCORE
59057 bool "/proc/vmcore support"
59058 - depends on PROC_FS && CRASH_DUMP
59059 - default y
59060 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
59061 + default n
59062 help
59063 Exports the dump image of crashed kernel in ELF format.
59064
59065 @@ -59,8 +59,8 @@ config PROC_SYSCTL
59066 limited in memory.
59067
59068 config PROC_PAGE_MONITOR
59069 - default y
59070 - depends on PROC_FS && MMU
59071 + default n
59072 + depends on PROC_FS && MMU && !GRKERNSEC
59073 bool "Enable /proc page monitoring" if EXPERT
59074 help
59075 Various /proc files exist to monitor process memory utilization:
59076 diff --git a/fs/proc/array.c b/fs/proc/array.c
59077 index cbd0f1b..adec3f0 100644
59078 --- a/fs/proc/array.c
59079 +++ b/fs/proc/array.c
59080 @@ -60,6 +60,7 @@
59081 #include <linux/tty.h>
59082 #include <linux/string.h>
59083 #include <linux/mman.h>
59084 +#include <linux/grsecurity.h>
59085 #include <linux/proc_fs.h>
59086 #include <linux/ioport.h>
59087 #include <linux/uaccess.h>
59088 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
59089 seq_putc(m, '\n');
59090 }
59091
59092 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59093 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
59094 +{
59095 + if (p->mm)
59096 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
59097 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
59098 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
59099 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
59100 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
59101 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
59102 + else
59103 + seq_printf(m, "PaX:\t-----\n");
59104 +}
59105 +#endif
59106 +
59107 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59108 struct pid *pid, struct task_struct *task)
59109 {
59110 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
59111 task_cpus_allowed(m, task);
59112 cpuset_task_status_allowed(m, task);
59113 task_context_switch_counts(m, task);
59114 +
59115 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
59116 + task_pax(m, task);
59117 +#endif
59118 +
59119 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
59120 + task_grsec_rbac(m, task);
59121 +#endif
59122 +
59123 return 0;
59124 }
59125
59126 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59127 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59128 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59129 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59130 +#endif
59131 +
59132 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59133 struct pid *pid, struct task_struct *task, int whole)
59134 {
59135 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59136 char tcomm[sizeof(task->comm)];
59137 unsigned long flags;
59138
59139 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59140 + if (current->exec_id != m->exec_id) {
59141 + gr_log_badprocpid("stat");
59142 + return 0;
59143 + }
59144 +#endif
59145 +
59146 state = *get_task_state(task);
59147 vsize = eip = esp = 0;
59148 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59149 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59150 gtime = task_gtime(task);
59151 }
59152
59153 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59154 + if (PAX_RAND_FLAGS(mm)) {
59155 + eip = 0;
59156 + esp = 0;
59157 + wchan = 0;
59158 + }
59159 +#endif
59160 +#ifdef CONFIG_GRKERNSEC_HIDESYM
59161 + wchan = 0;
59162 + eip =0;
59163 + esp =0;
59164 +#endif
59165 +
59166 /* scale priority and nice values from timeslices to -20..20 */
59167 /* to make it look like a "normal" Unix priority/nice value */
59168 priority = task_prio(task);
59169 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59170 seq_put_decimal_ull(m, ' ', vsize);
59171 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
59172 seq_put_decimal_ull(m, ' ', rsslim);
59173 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59174 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
59175 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
59176 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
59177 +#else
59178 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
59179 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
59180 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
59181 +#endif
59182 seq_put_decimal_ull(m, ' ', esp);
59183 seq_put_decimal_ull(m, ' ', eip);
59184 /* The signal information here is obsolete.
59185 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
59186 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
59187 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
59188
59189 - if (mm && permitted) {
59190 + if (mm && permitted
59191 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59192 + && !PAX_RAND_FLAGS(mm)
59193 +#endif
59194 + ) {
59195 seq_put_decimal_ull(m, ' ', mm->start_data);
59196 seq_put_decimal_ull(m, ' ', mm->end_data);
59197 seq_put_decimal_ull(m, ' ', mm->start_brk);
59198 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59199 struct pid *pid, struct task_struct *task)
59200 {
59201 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
59202 - struct mm_struct *mm = get_task_mm(task);
59203 + struct mm_struct *mm;
59204
59205 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59206 + if (current->exec_id != m->exec_id) {
59207 + gr_log_badprocpid("statm");
59208 + return 0;
59209 + }
59210 +#endif
59211 + mm = get_task_mm(task);
59212 if (mm) {
59213 size = task_statm(mm, &shared, &text, &data, &resident);
59214 mmput(mm);
59215 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
59216 return 0;
59217 }
59218
59219 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59220 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
59221 +{
59222 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
59223 +}
59224 +#endif
59225 +
59226 #ifdef CONFIG_CHECKPOINT_RESTORE
59227 static struct pid *
59228 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
59229 diff --git a/fs/proc/base.c b/fs/proc/base.c
59230 index 1485e38..8ad4236 100644
59231 --- a/fs/proc/base.c
59232 +++ b/fs/proc/base.c
59233 @@ -113,6 +113,14 @@ struct pid_entry {
59234 union proc_op op;
59235 };
59236
59237 +struct getdents_callback {
59238 + struct linux_dirent __user * current_dir;
59239 + struct linux_dirent __user * previous;
59240 + struct file * file;
59241 + int count;
59242 + int error;
59243 +};
59244 +
59245 #define NOD(NAME, MODE, IOP, FOP, OP) { \
59246 .name = (NAME), \
59247 .len = sizeof(NAME) - 1, \
59248 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
59249 if (!mm->arg_end)
59250 goto out_mm; /* Shh! No looking before we're done */
59251
59252 + if (gr_acl_handle_procpidmem(task))
59253 + goto out_mm;
59254 +
59255 len = mm->arg_end - mm->arg_start;
59256
59257 if (len > PAGE_SIZE)
59258 @@ -237,12 +248,28 @@ out:
59259 return res;
59260 }
59261
59262 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59263 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
59264 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
59265 + _mm->pax_flags & MF_PAX_SEGMEXEC))
59266 +#endif
59267 +
59268 static int proc_pid_auxv(struct task_struct *task, char *buffer)
59269 {
59270 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
59271 int res = PTR_ERR(mm);
59272 if (mm && !IS_ERR(mm)) {
59273 unsigned int nwords = 0;
59274 +
59275 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59276 + /* allow if we're currently ptracing this task */
59277 + if (PAX_RAND_FLAGS(mm) &&
59278 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
59279 + mmput(mm);
59280 + return 0;
59281 + }
59282 +#endif
59283 +
59284 do {
59285 nwords += 2;
59286 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
59287 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
59288 }
59289
59290
59291 -#ifdef CONFIG_KALLSYMS
59292 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59293 /*
59294 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
59295 * Returns the resolved symbol. If that fails, simply return the address.
59296 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
59297 mutex_unlock(&task->signal->cred_guard_mutex);
59298 }
59299
59300 -#ifdef CONFIG_STACKTRACE
59301 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59302
59303 #define MAX_STACK_TRACE_DEPTH 64
59304
59305 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
59306 return count;
59307 }
59308
59309 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59310 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59311 static int proc_pid_syscall(struct task_struct *task, char *buffer)
59312 {
59313 long nr;
59314 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
59315 /************************************************************************/
59316
59317 /* permission checks */
59318 -static int proc_fd_access_allowed(struct inode *inode)
59319 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
59320 {
59321 struct task_struct *task;
59322 int allowed = 0;
59323 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
59324 */
59325 task = get_proc_task(inode);
59326 if (task) {
59327 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59328 + if (log)
59329 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
59330 + else
59331 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
59332 put_task_struct(task);
59333 }
59334 return allowed;
59335 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
59336 struct task_struct *task,
59337 int hide_pid_min)
59338 {
59339 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59340 + return false;
59341 +
59342 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59343 + rcu_read_lock();
59344 + {
59345 + const struct cred *tmpcred = current_cred();
59346 + const struct cred *cred = __task_cred(task);
59347 +
59348 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
59349 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59350 + || in_group_p(grsec_proc_gid)
59351 +#endif
59352 + ) {
59353 + rcu_read_unlock();
59354 + return true;
59355 + }
59356 + }
59357 + rcu_read_unlock();
59358 +
59359 + if (!pid->hide_pid)
59360 + return false;
59361 +#endif
59362 +
59363 if (pid->hide_pid < hide_pid_min)
59364 return true;
59365 if (in_group_p(pid->pid_gid))
59366 return true;
59367 +
59368 return ptrace_may_access(task, PTRACE_MODE_READ);
59369 }
59370
59371 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
59372 put_task_struct(task);
59373
59374 if (!has_perms) {
59375 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59376 + {
59377 +#else
59378 if (pid->hide_pid == 2) {
59379 +#endif
59380 /*
59381 * Let's make getdents(), stat(), and open()
59382 * consistent with each other. If a process
59383 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59384 if (!task)
59385 return -ESRCH;
59386
59387 + if (gr_acl_handle_procpidmem(task)) {
59388 + put_task_struct(task);
59389 + return -EPERM;
59390 + }
59391 +
59392 mm = mm_access(task, mode);
59393 put_task_struct(task);
59394
59395 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
59396
59397 file->private_data = mm;
59398
59399 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59400 + file->f_version = current->exec_id;
59401 +#endif
59402 +
59403 return 0;
59404 }
59405
59406 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59407 ssize_t copied;
59408 char *page;
59409
59410 +#ifdef CONFIG_GRKERNSEC
59411 + if (write)
59412 + return -EPERM;
59413 +#endif
59414 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59415 + if (file->f_version != current->exec_id) {
59416 + gr_log_badprocpid("mem");
59417 + return 0;
59418 + }
59419 +#endif
59420 +
59421 if (!mm)
59422 return 0;
59423
59424 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
59425 goto free;
59426
59427 while (count > 0) {
59428 - int this_len = min_t(int, count, PAGE_SIZE);
59429 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
59430
59431 if (write && copy_from_user(page, buf, this_len)) {
59432 copied = -EFAULT;
59433 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59434 if (!mm)
59435 return 0;
59436
59437 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
59438 + if (file->f_version != current->exec_id) {
59439 + gr_log_badprocpid("environ");
59440 + return 0;
59441 + }
59442 +#endif
59443 +
59444 page = (char *)__get_free_page(GFP_TEMPORARY);
59445 if (!page)
59446 return -ENOMEM;
59447 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
59448 goto free;
59449 while (count > 0) {
59450 size_t this_len, max_len;
59451 - int retval;
59452 + ssize_t retval;
59453
59454 if (src >= (mm->env_end - mm->env_start))
59455 break;
59456 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
59457 int error = -EACCES;
59458
59459 /* Are we allowed to snoop on the tasks file descriptors? */
59460 - if (!proc_fd_access_allowed(inode))
59461 + if (!proc_fd_access_allowed(inode, 0))
59462 goto out;
59463
59464 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59465 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
59466 struct path path;
59467
59468 /* Are we allowed to snoop on the tasks file descriptors? */
59469 - if (!proc_fd_access_allowed(inode))
59470 - goto out;
59471 + /* logging this is needed for learning on chromium to work properly,
59472 + but we don't want to flood the logs from 'ps' which does a readlink
59473 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
59474 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
59475 + */
59476 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
59477 + if (!proc_fd_access_allowed(inode,0))
59478 + goto out;
59479 + } else {
59480 + if (!proc_fd_access_allowed(inode,1))
59481 + goto out;
59482 + }
59483
59484 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
59485 if (error)
59486 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
59487 rcu_read_lock();
59488 cred = __task_cred(task);
59489 inode->i_uid = cred->euid;
59490 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59491 + inode->i_gid = grsec_proc_gid;
59492 +#else
59493 inode->i_gid = cred->egid;
59494 +#endif
59495 rcu_read_unlock();
59496 }
59497 security_task_to_inode(task, inode);
59498 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
59499 return -ENOENT;
59500 }
59501 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59502 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59503 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59504 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59505 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59506 +#endif
59507 task_dumpable(task)) {
59508 cred = __task_cred(task);
59509 stat->uid = cred->euid;
59510 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59511 + stat->gid = grsec_proc_gid;
59512 +#else
59513 stat->gid = cred->egid;
59514 +#endif
59515 }
59516 }
59517 rcu_read_unlock();
59518 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
59519
59520 if (task) {
59521 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
59522 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59523 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
59524 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59525 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
59526 +#endif
59527 task_dumpable(task)) {
59528 rcu_read_lock();
59529 cred = __task_cred(task);
59530 inode->i_uid = cred->euid;
59531 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59532 + inode->i_gid = grsec_proc_gid;
59533 +#else
59534 inode->i_gid = cred->egid;
59535 +#endif
59536 rcu_read_unlock();
59537 } else {
59538 inode->i_uid = GLOBAL_ROOT_UID;
59539 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
59540 if (!task)
59541 goto out_no_task;
59542
59543 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59544 + goto out;
59545 +
59546 /*
59547 * Yes, it does not scale. And it should not. Don't add
59548 * new entries into /proc/<tgid>/ without very good reasons.
59549 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
59550 if (!task)
59551 return -ENOENT;
59552
59553 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59554 + goto out;
59555 +
59556 if (!dir_emit_dots(file, ctx))
59557 goto out;
59558
59559 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
59560 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
59561 #endif
59562 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59563 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59564 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59565 INF("syscall", S_IRUGO, proc_pid_syscall),
59566 #endif
59567 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59568 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
59569 #ifdef CONFIG_SECURITY
59570 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59571 #endif
59572 -#ifdef CONFIG_KALLSYMS
59573 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59574 INF("wchan", S_IRUGO, proc_pid_wchan),
59575 #endif
59576 -#ifdef CONFIG_STACKTRACE
59577 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59578 ONE("stack", S_IRUGO, proc_pid_stack),
59579 #endif
59580 #ifdef CONFIG_SCHEDSTATS
59581 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
59582 #ifdef CONFIG_HARDWALL
59583 INF("hardwall", S_IRUGO, proc_pid_hardwall),
59584 #endif
59585 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59586 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
59587 +#endif
59588 #ifdef CONFIG_USER_NS
59589 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
59590 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
59591 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
59592 if (!inode)
59593 goto out;
59594
59595 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59596 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
59597 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59598 + inode->i_gid = grsec_proc_gid;
59599 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
59600 +#else
59601 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
59602 +#endif
59603 inode->i_op = &proc_tgid_base_inode_operations;
59604 inode->i_fop = &proc_tgid_base_operations;
59605 inode->i_flags|=S_IMMUTABLE;
59606 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
59607 if (!task)
59608 goto out;
59609
59610 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
59611 + goto out_put_task;
59612 +
59613 result = proc_pid_instantiate(dir, dentry, task, NULL);
59614 +out_put_task:
59615 put_task_struct(task);
59616 out:
59617 return ERR_PTR(result);
59618 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
59619 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
59620 #endif
59621 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
59622 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
59623 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
59624 INF("syscall", S_IRUGO, proc_pid_syscall),
59625 #endif
59626 INF("cmdline", S_IRUGO, proc_pid_cmdline),
59627 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
59628 #ifdef CONFIG_SECURITY
59629 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
59630 #endif
59631 -#ifdef CONFIG_KALLSYMS
59632 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59633 INF("wchan", S_IRUGO, proc_pid_wchan),
59634 #endif
59635 -#ifdef CONFIG_STACKTRACE
59636 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
59637 ONE("stack", S_IRUGO, proc_pid_stack),
59638 #endif
59639 #ifdef CONFIG_SCHEDSTATS
59640 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
59641 index 82676e3..5f8518a 100644
59642 --- a/fs/proc/cmdline.c
59643 +++ b/fs/proc/cmdline.c
59644 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
59645
59646 static int __init proc_cmdline_init(void)
59647 {
59648 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59649 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
59650 +#else
59651 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
59652 +#endif
59653 return 0;
59654 }
59655 module_init(proc_cmdline_init);
59656 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
59657 index b143471..bb105e5 100644
59658 --- a/fs/proc/devices.c
59659 +++ b/fs/proc/devices.c
59660 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
59661
59662 static int __init proc_devices_init(void)
59663 {
59664 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
59665 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
59666 +#else
59667 proc_create("devices", 0, NULL, &proc_devinfo_operations);
59668 +#endif
59669 return 0;
59670 }
59671 module_init(proc_devices_init);
59672 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
59673 index 0ff80f9..a1d7500 100644
59674 --- a/fs/proc/fd.c
59675 +++ b/fs/proc/fd.c
59676 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
59677 if (!task)
59678 return -ENOENT;
59679
59680 - files = get_files_struct(task);
59681 + if (!gr_acl_handle_procpidmem(task))
59682 + files = get_files_struct(task);
59683 put_task_struct(task);
59684
59685 if (files) {
59686 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
59687 */
59688 int proc_fd_permission(struct inode *inode, int mask)
59689 {
59690 + struct task_struct *task;
59691 int rv = generic_permission(inode, mask);
59692 - if (rv == 0)
59693 - return 0;
59694 +
59695 if (task_pid(current) == proc_pid(inode))
59696 rv = 0;
59697 +
59698 + task = get_proc_task(inode);
59699 + if (task == NULL)
59700 + return rv;
59701 +
59702 + if (gr_acl_handle_procpidmem(task))
59703 + rv = -EACCES;
59704 +
59705 + put_task_struct(task);
59706 +
59707 return rv;
59708 }
59709
59710 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
59711 index 073aea6..0630370 100644
59712 --- a/fs/proc/inode.c
59713 +++ b/fs/proc/inode.c
59714 @@ -23,11 +23,17 @@
59715 #include <linux/slab.h>
59716 #include <linux/mount.h>
59717 #include <linux/magic.h>
59718 +#include <linux/grsecurity.h>
59719
59720 #include <asm/uaccess.h>
59721
59722 #include "internal.h"
59723
59724 +#ifdef CONFIG_PROC_SYSCTL
59725 +extern const struct inode_operations proc_sys_inode_operations;
59726 +extern const struct inode_operations proc_sys_dir_operations;
59727 +#endif
59728 +
59729 static void proc_evict_inode(struct inode *inode)
59730 {
59731 struct proc_dir_entry *de;
59732 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
59733 ns = PROC_I(inode)->ns.ns;
59734 if (ns_ops && ns)
59735 ns_ops->put(ns);
59736 +
59737 +#ifdef CONFIG_PROC_SYSCTL
59738 + if (inode->i_op == &proc_sys_inode_operations ||
59739 + inode->i_op == &proc_sys_dir_operations)
59740 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
59741 +#endif
59742 +
59743 }
59744
59745 static struct kmem_cache * proc_inode_cachep;
59746 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
59747 if (de->mode) {
59748 inode->i_mode = de->mode;
59749 inode->i_uid = de->uid;
59750 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
59751 + inode->i_gid = grsec_proc_gid;
59752 +#else
59753 inode->i_gid = de->gid;
59754 +#endif
59755 }
59756 if (de->size)
59757 inode->i_size = de->size;
59758 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
59759 index 651d09a..60c73ae 100644
59760 --- a/fs/proc/internal.h
59761 +++ b/fs/proc/internal.h
59762 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
59763 struct pid *, struct task_struct *);
59764 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
59765 struct pid *, struct task_struct *);
59766 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
59767 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
59768 +#endif
59769
59770 /*
59771 * base.c
59772 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
59773 index 06ea155..9a798c7 100644
59774 --- a/fs/proc/kcore.c
59775 +++ b/fs/proc/kcore.c
59776 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59777 * the addresses in the elf_phdr on our list.
59778 */
59779 start = kc_offset_to_vaddr(*fpos - elf_buflen);
59780 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
59781 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
59782 + if (tsz > buflen)
59783 tsz = buflen;
59784 -
59785 +
59786 while (buflen) {
59787 struct kcore_list *m;
59788
59789 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59790 kfree(elf_buf);
59791 } else {
59792 if (kern_addr_valid(start)) {
59793 - unsigned long n;
59794 + char *elf_buf;
59795 + mm_segment_t oldfs;
59796
59797 - n = copy_to_user(buffer, (char *)start, tsz);
59798 - /*
59799 - * We cannot distinguish between fault on source
59800 - * and fault on destination. When this happens
59801 - * we clear too and hope it will trigger the
59802 - * EFAULT again.
59803 - */
59804 - if (n) {
59805 - if (clear_user(buffer + tsz - n,
59806 - n))
59807 + elf_buf = kmalloc(tsz, GFP_KERNEL);
59808 + if (!elf_buf)
59809 + return -ENOMEM;
59810 + oldfs = get_fs();
59811 + set_fs(KERNEL_DS);
59812 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
59813 + set_fs(oldfs);
59814 + if (copy_to_user(buffer, elf_buf, tsz)) {
59815 + kfree(elf_buf);
59816 return -EFAULT;
59817 + }
59818 }
59819 + set_fs(oldfs);
59820 + kfree(elf_buf);
59821 } else {
59822 if (clear_user(buffer, tsz))
59823 return -EFAULT;
59824 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
59825
59826 static int open_kcore(struct inode *inode, struct file *filp)
59827 {
59828 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
59829 + return -EPERM;
59830 +#endif
59831 if (!capable(CAP_SYS_RAWIO))
59832 return -EPERM;
59833 if (kcore_need_update)
59834 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
59835 index 5aa847a..f77c8d4 100644
59836 --- a/fs/proc/meminfo.c
59837 +++ b/fs/proc/meminfo.c
59838 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
59839 vmi.used >> 10,
59840 vmi.largest_chunk >> 10
59841 #ifdef CONFIG_MEMORY_FAILURE
59842 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59843 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
59844 #endif
59845 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
59846 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
59847 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
59848 index ccfd99b..1b7e255 100644
59849 --- a/fs/proc/nommu.c
59850 +++ b/fs/proc/nommu.c
59851 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
59852 if (len < 1)
59853 len = 1;
59854 seq_printf(m, "%*c", len, ' ');
59855 - seq_path(m, &file->f_path, "");
59856 + seq_path(m, &file->f_path, "\n\\");
59857 }
59858
59859 seq_putc(m, '\n');
59860 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
59861 index 4677bb7..408e936 100644
59862 --- a/fs/proc/proc_net.c
59863 +++ b/fs/proc/proc_net.c
59864 @@ -23,6 +23,7 @@
59865 #include <linux/nsproxy.h>
59866 #include <net/net_namespace.h>
59867 #include <linux/seq_file.h>
59868 +#include <linux/grsecurity.h>
59869
59870 #include "internal.h"
59871
59872 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
59873 struct task_struct *task;
59874 struct nsproxy *ns;
59875 struct net *net = NULL;
59876 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59877 + const struct cred *cred = current_cred();
59878 +#endif
59879 +
59880 +#ifdef CONFIG_GRKERNSEC_PROC_USER
59881 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
59882 + return net;
59883 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
59884 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
59885 + return net;
59886 +#endif
59887
59888 rcu_read_lock();
59889 task = pid_task(proc_pid(dir), PIDTYPE_PID);
59890 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
59891 index 7129046..f2779c6 100644
59892 --- a/fs/proc/proc_sysctl.c
59893 +++ b/fs/proc/proc_sysctl.c
59894 @@ -13,11 +13,15 @@
59895 #include <linux/module.h>
59896 #include "internal.h"
59897
59898 +extern int gr_handle_chroot_sysctl(const int op);
59899 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
59900 + const int op);
59901 +
59902 static const struct dentry_operations proc_sys_dentry_operations;
59903 static const struct file_operations proc_sys_file_operations;
59904 -static const struct inode_operations proc_sys_inode_operations;
59905 +const struct inode_operations proc_sys_inode_operations;
59906 static const struct file_operations proc_sys_dir_file_operations;
59907 -static const struct inode_operations proc_sys_dir_operations;
59908 +const struct inode_operations proc_sys_dir_operations;
59909
59910 void proc_sys_poll_notify(struct ctl_table_poll *poll)
59911 {
59912 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
59913
59914 err = NULL;
59915 d_set_d_op(dentry, &proc_sys_dentry_operations);
59916 +
59917 + gr_handle_proc_create(dentry, inode);
59918 +
59919 d_add(dentry, inode);
59920
59921 out:
59922 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59923 struct inode *inode = file_inode(filp);
59924 struct ctl_table_header *head = grab_header(inode);
59925 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
59926 + int op = write ? MAY_WRITE : MAY_READ;
59927 ssize_t error;
59928 size_t res;
59929
59930 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59931 * and won't be until we finish.
59932 */
59933 error = -EPERM;
59934 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
59935 + if (sysctl_perm(head, table, op))
59936 goto out;
59937
59938 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
59939 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
59940 if (!table->proc_handler)
59941 goto out;
59942
59943 +#ifdef CONFIG_GRKERNSEC
59944 + error = -EPERM;
59945 + if (gr_handle_chroot_sysctl(op))
59946 + goto out;
59947 + dget(filp->f_path.dentry);
59948 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
59949 + dput(filp->f_path.dentry);
59950 + goto out;
59951 + }
59952 + dput(filp->f_path.dentry);
59953 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
59954 + goto out;
59955 + if (write && !capable(CAP_SYS_ADMIN))
59956 + goto out;
59957 +#endif
59958 +
59959 /* careful: calling conventions are nasty here */
59960 res = count;
59961 error = table->proc_handler(table, write, buf, &res, ppos);
59962 @@ -598,6 +622,9 @@ static bool proc_sys_fill_cache(struct file *file,
59963 return false;
59964 } else {
59965 d_set_d_op(child, &proc_sys_dentry_operations);
59966 +
59967 + gr_handle_proc_create(child, inode);
59968 +
59969 d_add(child, inode);
59970 }
59971 } else {
59972 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
59973 if ((*pos)++ < ctx->pos)
59974 return true;
59975
59976 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
59977 + return 0;
59978 +
59979 if (unlikely(S_ISLNK(table->mode)))
59980 res = proc_sys_link_fill_cache(file, ctx, head, table);
59981 else
59982 @@ -734,6 +764,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
59983 if (IS_ERR(head))
59984 return PTR_ERR(head);
59985
59986 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
59987 + return -ENOENT;
59988 +
59989 generic_fillattr(inode, stat);
59990 if (table)
59991 stat->mode = (stat->mode & S_IFMT) | table->mode;
59992 @@ -756,13 +789,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
59993 .llseek = generic_file_llseek,
59994 };
59995
59996 -static const struct inode_operations proc_sys_inode_operations = {
59997 +const struct inode_operations proc_sys_inode_operations = {
59998 .permission = proc_sys_permission,
59999 .setattr = proc_sys_setattr,
60000 .getattr = proc_sys_getattr,
60001 };
60002
60003 -static const struct inode_operations proc_sys_dir_operations = {
60004 +const struct inode_operations proc_sys_dir_operations = {
60005 .lookup = proc_sys_lookup,
60006 .permission = proc_sys_permission,
60007 .setattr = proc_sys_setattr,
60008 @@ -839,7 +872,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
60009 static struct ctl_dir *new_dir(struct ctl_table_set *set,
60010 const char *name, int namelen)
60011 {
60012 - struct ctl_table *table;
60013 + ctl_table_no_const *table;
60014 struct ctl_dir *new;
60015 struct ctl_node *node;
60016 char *new_name;
60017 @@ -851,7 +884,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
60018 return NULL;
60019
60020 node = (struct ctl_node *)(new + 1);
60021 - table = (struct ctl_table *)(node + 1);
60022 + table = (ctl_table_no_const *)(node + 1);
60023 new_name = (char *)(table + 2);
60024 memcpy(new_name, name, namelen);
60025 new_name[namelen] = '\0';
60026 @@ -1020,7 +1053,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
60027 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
60028 struct ctl_table_root *link_root)
60029 {
60030 - struct ctl_table *link_table, *entry, *link;
60031 + ctl_table_no_const *link_table, *link;
60032 + struct ctl_table *entry;
60033 struct ctl_table_header *links;
60034 struct ctl_node *node;
60035 char *link_name;
60036 @@ -1043,7 +1077,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
60037 return NULL;
60038
60039 node = (struct ctl_node *)(links + 1);
60040 - link_table = (struct ctl_table *)(node + nr_entries);
60041 + link_table = (ctl_table_no_const *)(node + nr_entries);
60042 link_name = (char *)&link_table[nr_entries + 1];
60043
60044 for (link = link_table, entry = table; entry->procname; link++, entry++) {
60045 @@ -1291,8 +1325,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60046 struct ctl_table_header ***subheader, struct ctl_table_set *set,
60047 struct ctl_table *table)
60048 {
60049 - struct ctl_table *ctl_table_arg = NULL;
60050 - struct ctl_table *entry, *files;
60051 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
60052 + struct ctl_table *entry;
60053 int nr_files = 0;
60054 int nr_dirs = 0;
60055 int err = -ENOMEM;
60056 @@ -1304,10 +1338,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60057 nr_files++;
60058 }
60059
60060 - files = table;
60061 /* If there are mixed files and directories we need a new table */
60062 if (nr_dirs && nr_files) {
60063 - struct ctl_table *new;
60064 + ctl_table_no_const *new;
60065 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
60066 GFP_KERNEL);
60067 if (!files)
60068 @@ -1325,7 +1358,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
60069 /* Register everything except a directory full of subdirectories */
60070 if (nr_files || !nr_dirs) {
60071 struct ctl_table_header *header;
60072 - header = __register_sysctl_table(set, path, files);
60073 + header = __register_sysctl_table(set, path, files ? files : table);
60074 if (!header) {
60075 kfree(ctl_table_arg);
60076 goto out;
60077 diff --git a/fs/proc/root.c b/fs/proc/root.c
60078 index 0e0e83c..005ba6a 100644
60079 --- a/fs/proc/root.c
60080 +++ b/fs/proc/root.c
60081 @@ -183,7 +183,15 @@ void __init proc_root_init(void)
60082 #ifdef CONFIG_PROC_DEVICETREE
60083 proc_device_tree_init();
60084 #endif
60085 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60086 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60087 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
60088 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60089 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
60090 +#endif
60091 +#else
60092 proc_mkdir("bus", NULL);
60093 +#endif
60094 proc_sys_init();
60095 }
60096
60097 diff --git a/fs/proc/self.c b/fs/proc/self.c
60098 index 6b6a993..807cccc 100644
60099 --- a/fs/proc/self.c
60100 +++ b/fs/proc/self.c
60101 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
60102 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
60103 void *cookie)
60104 {
60105 - char *s = nd_get_link(nd);
60106 + const char *s = nd_get_link(nd);
60107 if (!IS_ERR(s))
60108 kfree(s);
60109 }
60110 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
60111 index 107d026..c715aeb 100644
60112 --- a/fs/proc/task_mmu.c
60113 +++ b/fs/proc/task_mmu.c
60114 @@ -12,12 +12,19 @@
60115 #include <linux/swap.h>
60116 #include <linux/swapops.h>
60117 #include <linux/mmu_notifier.h>
60118 +#include <linux/grsecurity.h>
60119
60120 #include <asm/elf.h>
60121 #include <asm/uaccess.h>
60122 #include <asm/tlbflush.h>
60123 #include "internal.h"
60124
60125 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60126 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60127 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60128 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60129 +#endif
60130 +
60131 void task_mem(struct seq_file *m, struct mm_struct *mm)
60132 {
60133 unsigned long data, text, lib, swap;
60134 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60135 "VmExe:\t%8lu kB\n"
60136 "VmLib:\t%8lu kB\n"
60137 "VmPTE:\t%8lu kB\n"
60138 - "VmSwap:\t%8lu kB\n",
60139 - hiwater_vm << (PAGE_SHIFT-10),
60140 + "VmSwap:\t%8lu kB\n"
60141 +
60142 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60143 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
60144 +#endif
60145 +
60146 + ,hiwater_vm << (PAGE_SHIFT-10),
60147 total_vm << (PAGE_SHIFT-10),
60148 mm->locked_vm << (PAGE_SHIFT-10),
60149 mm->pinned_vm << (PAGE_SHIFT-10),
60150 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60151 data << (PAGE_SHIFT-10),
60152 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
60153 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
60154 - swap << (PAGE_SHIFT-10));
60155 + swap << (PAGE_SHIFT-10)
60156 +
60157 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
60158 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60159 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
60160 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
60161 +#else
60162 + , mm->context.user_cs_base
60163 + , mm->context.user_cs_limit
60164 +#endif
60165 +#endif
60166 +
60167 + );
60168 }
60169
60170 unsigned long task_vsize(struct mm_struct *mm)
60171 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60172 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
60173 }
60174
60175 - /* We don't show the stack guard page in /proc/maps */
60176 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60177 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
60178 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
60179 +#else
60180 start = vma->vm_start;
60181 - if (stack_guard_page_start(vma, start))
60182 - start += PAGE_SIZE;
60183 end = vma->vm_end;
60184 - if (stack_guard_page_end(vma, end))
60185 - end -= PAGE_SIZE;
60186 +#endif
60187
60188 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
60189 start,
60190 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60191 flags & VM_WRITE ? 'w' : '-',
60192 flags & VM_EXEC ? 'x' : '-',
60193 flags & VM_MAYSHARE ? 's' : 'p',
60194 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60195 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
60196 +#else
60197 pgoff,
60198 +#endif
60199 MAJOR(dev), MINOR(dev), ino, &len);
60200
60201 /*
60202 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60203 */
60204 if (file) {
60205 pad_len_spaces(m, len);
60206 - seq_path(m, &file->f_path, "\n");
60207 + seq_path(m, &file->f_path, "\n\\");
60208 goto done;
60209 }
60210
60211 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
60212 * Thread stack in /proc/PID/task/TID/maps or
60213 * the main process stack.
60214 */
60215 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
60216 - vma->vm_end >= mm->start_stack)) {
60217 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
60218 + (vma->vm_start <= mm->start_stack &&
60219 + vma->vm_end >= mm->start_stack)) {
60220 name = "[stack]";
60221 } else {
60222 /* Thread stack in /proc/PID/maps */
60223 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
60224 struct proc_maps_private *priv = m->private;
60225 struct task_struct *task = priv->task;
60226
60227 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60228 + if (current->exec_id != m->exec_id) {
60229 + gr_log_badprocpid("maps");
60230 + return 0;
60231 + }
60232 +#endif
60233 +
60234 show_map_vma(m, vma, is_pid);
60235
60236 if (m->count < m->size) /* vma is copied successfully */
60237 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60238 .private = &mss,
60239 };
60240
60241 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60242 + if (current->exec_id != m->exec_id) {
60243 + gr_log_badprocpid("smaps");
60244 + return 0;
60245 + }
60246 +#endif
60247 memset(&mss, 0, sizeof mss);
60248 - mss.vma = vma;
60249 - /* mmap_sem is held in m_start */
60250 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60251 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60252 -
60253 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60254 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
60255 +#endif
60256 + mss.vma = vma;
60257 + /* mmap_sem is held in m_start */
60258 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
60259 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
60260 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60261 + }
60262 +#endif
60263 show_map_vma(m, vma, is_pid);
60264
60265 seq_printf(m,
60266 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
60267 "KernelPageSize: %8lu kB\n"
60268 "MMUPageSize: %8lu kB\n"
60269 "Locked: %8lu kB\n",
60270 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60271 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
60272 +#else
60273 (vma->vm_end - vma->vm_start) >> 10,
60274 +#endif
60275 mss.resident >> 10,
60276 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
60277 mss.shared_clean >> 10,
60278 @@ -1362,6 +1413,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60279 int n;
60280 char buffer[50];
60281
60282 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60283 + if (current->exec_id != m->exec_id) {
60284 + gr_log_badprocpid("numa_maps");
60285 + return 0;
60286 + }
60287 +#endif
60288 +
60289 if (!mm)
60290 return 0;
60291
60292 @@ -1379,11 +1437,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
60293 mpol_to_str(buffer, sizeof(buffer), pol);
60294 mpol_cond_put(pol);
60295
60296 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60297 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
60298 +#else
60299 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
60300 +#endif
60301
60302 if (file) {
60303 seq_printf(m, " file=");
60304 - seq_path(m, &file->f_path, "\n\t= ");
60305 + seq_path(m, &file->f_path, "\n\t\\= ");
60306 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
60307 seq_printf(m, " heap");
60308 } else {
60309 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
60310 index 56123a6..5a2f6ec 100644
60311 --- a/fs/proc/task_nommu.c
60312 +++ b/fs/proc/task_nommu.c
60313 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
60314 else
60315 bytes += kobjsize(mm);
60316
60317 - if (current->fs && current->fs->users > 1)
60318 + if (current->fs && atomic_read(&current->fs->users) > 1)
60319 sbytes += kobjsize(current->fs);
60320 else
60321 bytes += kobjsize(current->fs);
60322 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
60323
60324 if (file) {
60325 pad_len_spaces(m, len);
60326 - seq_path(m, &file->f_path, "");
60327 + seq_path(m, &file->f_path, "\n\\");
60328 } else if (mm) {
60329 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
60330
60331 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
60332 index a1a16eb..6be46ed 100644
60333 --- a/fs/proc/vmcore.c
60334 +++ b/fs/proc/vmcore.c
60335 @@ -104,9 +104,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
60336 nr_bytes = count;
60337
60338 /* If pfn is not ram, return zeros for sparse dump files */
60339 - if (pfn_is_ram(pfn) == 0)
60340 - memset(buf, 0, nr_bytes);
60341 - else {
60342 + if (pfn_is_ram(pfn) == 0) {
60343 + if (userbuf) {
60344 + if (clear_user((char __force_user *)buf, nr_bytes))
60345 + return -EFAULT;
60346 + } else
60347 + memset(buf, 0, nr_bytes);
60348 + } else {
60349 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
60350 offset, userbuf);
60351 if (tmp < 0)
60352 @@ -178,7 +182,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
60353 if (*fpos < m->offset + m->size) {
60354 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
60355 start = m->paddr + *fpos - m->offset;
60356 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
60357 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
60358 if (tmp < 0)
60359 return tmp;
60360 buflen -= tsz;
60361 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
60362 index b00fcc9..e0c6381 100644
60363 --- a/fs/qnx6/qnx6.h
60364 +++ b/fs/qnx6/qnx6.h
60365 @@ -74,7 +74,7 @@ enum {
60366 BYTESEX_BE,
60367 };
60368
60369 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60370 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
60371 {
60372 if (sbi->s_bytesex == BYTESEX_LE)
60373 return le64_to_cpu((__force __le64)n);
60374 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
60375 return (__force __fs64)cpu_to_be64(n);
60376 }
60377
60378 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60379 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
60380 {
60381 if (sbi->s_bytesex == BYTESEX_LE)
60382 return le32_to_cpu((__force __le32)n);
60383 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
60384 index 16e8abb..2dcf914 100644
60385 --- a/fs/quota/netlink.c
60386 +++ b/fs/quota/netlink.c
60387 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
60388 void quota_send_warning(struct kqid qid, dev_t dev,
60389 const char warntype)
60390 {
60391 - static atomic_t seq;
60392 + static atomic_unchecked_t seq;
60393 struct sk_buff *skb;
60394 void *msg_head;
60395 int ret;
60396 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
60397 "VFS: Not enough memory to send quota warning.\n");
60398 return;
60399 }
60400 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
60401 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
60402 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
60403 if (!msg_head) {
60404 printk(KERN_ERR
60405 diff --git a/fs/read_write.c b/fs/read_write.c
60406 index 122a384..0b7ecf2 100644
60407 --- a/fs/read_write.c
60408 +++ b/fs/read_write.c
60409 @@ -440,7 +440,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
60410
60411 old_fs = get_fs();
60412 set_fs(get_ds());
60413 - p = (__force const char __user *)buf;
60414 + p = (const char __force_user *)buf;
60415 if (count > MAX_RW_COUNT)
60416 count = MAX_RW_COUNT;
60417 if (file->f_op->write)
60418 diff --git a/fs/readdir.c b/fs/readdir.c
60419 index 93d71e5..6a14be8 100644
60420 --- a/fs/readdir.c
60421 +++ b/fs/readdir.c
60422 @@ -17,6 +17,7 @@
60423 #include <linux/security.h>
60424 #include <linux/syscalls.h>
60425 #include <linux/unistd.h>
60426 +#include <linux/namei.h>
60427
60428 #include <asm/uaccess.h>
60429
60430 @@ -69,6 +70,7 @@ struct old_linux_dirent {
60431 struct readdir_callback {
60432 struct dir_context ctx;
60433 struct old_linux_dirent __user * dirent;
60434 + struct file * file;
60435 int result;
60436 };
60437
60438 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
60439 buf->result = -EOVERFLOW;
60440 return -EOVERFLOW;
60441 }
60442 +
60443 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60444 + return 0;
60445 +
60446 buf->result++;
60447 dirent = buf->dirent;
60448 if (!access_ok(VERIFY_WRITE, dirent,
60449 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
60450 if (!f.file)
60451 return -EBADF;
60452
60453 + buf.file = f.file;
60454 error = iterate_dir(f.file, &buf.ctx);
60455 if (buf.result)
60456 error = buf.result;
60457 @@ -142,6 +149,7 @@ struct getdents_callback {
60458 struct dir_context ctx;
60459 struct linux_dirent __user * current_dir;
60460 struct linux_dirent __user * previous;
60461 + struct file * file;
60462 int count;
60463 int error;
60464 };
60465 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
60466 buf->error = -EOVERFLOW;
60467 return -EOVERFLOW;
60468 }
60469 +
60470 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60471 + return 0;
60472 +
60473 dirent = buf->previous;
60474 if (dirent) {
60475 if (__put_user(offset, &dirent->d_off))
60476 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
60477 if (!f.file)
60478 return -EBADF;
60479
60480 + buf.file = f.file;
60481 error = iterate_dir(f.file, &buf.ctx);
60482 if (error >= 0)
60483 error = buf.error;
60484 @@ -226,6 +239,7 @@ struct getdents_callback64 {
60485 struct dir_context ctx;
60486 struct linux_dirent64 __user * current_dir;
60487 struct linux_dirent64 __user * previous;
60488 + struct file *file;
60489 int count;
60490 int error;
60491 };
60492 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
60493 buf->error = -EINVAL; /* only used if we fail.. */
60494 if (reclen > buf->count)
60495 return -EINVAL;
60496 +
60497 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
60498 + return 0;
60499 +
60500 dirent = buf->previous;
60501 if (dirent) {
60502 if (__put_user(offset, &dirent->d_off))
60503 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
60504 if (!f.file)
60505 return -EBADF;
60506
60507 + buf.file = f.file;
60508 error = iterate_dir(f.file, &buf.ctx);
60509 if (error >= 0)
60510 error = buf.error;
60511 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
60512 index 2b7882b..1c5ef48 100644
60513 --- a/fs/reiserfs/do_balan.c
60514 +++ b/fs/reiserfs/do_balan.c
60515 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
60516 return;
60517 }
60518
60519 - atomic_inc(&(fs_generation(tb->tb_sb)));
60520 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
60521 do_balance_starts(tb);
60522
60523 /* balance leaf returns 0 except if combining L R and S into
60524 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
60525 index a958444..42b2323 100644
60526 --- a/fs/reiserfs/procfs.c
60527 +++ b/fs/reiserfs/procfs.c
60528 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
60529 "SMALL_TAILS " : "NO_TAILS ",
60530 replay_only(sb) ? "REPLAY_ONLY " : "",
60531 convert_reiserfs(sb) ? "CONV " : "",
60532 - atomic_read(&r->s_generation_counter),
60533 + atomic_read_unchecked(&r->s_generation_counter),
60534 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
60535 SF(s_do_balance), SF(s_unneeded_left_neighbor),
60536 SF(s_good_search_by_key_reada), SF(s_bmaps),
60537 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
60538 index 3df5ce6..8c0f4b0 100644
60539 --- a/fs/reiserfs/reiserfs.h
60540 +++ b/fs/reiserfs/reiserfs.h
60541 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
60542 /* Comment? -Hans */
60543 wait_queue_head_t s_wait;
60544 /* To be obsoleted soon by per buffer seals.. -Hans */
60545 - atomic_t s_generation_counter; // increased by one every time the
60546 + atomic_unchecked_t s_generation_counter; // increased by one every time the
60547 // tree gets re-balanced
60548 unsigned long s_properties; /* File system properties. Currently holds
60549 on-disk FS format */
60550 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
60551 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
60552
60553 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
60554 -#define get_generation(s) atomic_read (&fs_generation(s))
60555 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
60556 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
60557 #define __fs_changed(gen,s) (gen != get_generation (s))
60558 #define fs_changed(gen,s) \
60559 diff --git a/fs/select.c b/fs/select.c
60560 index 35d4adc7..d6c60db 100644
60561 --- a/fs/select.c
60562 +++ b/fs/select.c
60563 @@ -20,6 +20,7 @@
60564 #include <linux/export.h>
60565 #include <linux/slab.h>
60566 #include <linux/poll.h>
60567 +#include <linux/security.h>
60568 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
60569 #include <linux/file.h>
60570 #include <linux/fdtable.h>
60571 @@ -881,6 +882,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
60572 struct poll_list *walk = head;
60573 unsigned long todo = nfds;
60574
60575 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
60576 if (nfds > rlimit(RLIMIT_NOFILE))
60577 return -EINVAL;
60578
60579 diff --git a/fs/seq_file.c b/fs/seq_file.c
60580 index 3135c25..d0395dd 100644
60581 --- a/fs/seq_file.c
60582 +++ b/fs/seq_file.c
60583 @@ -10,6 +10,7 @@
60584 #include <linux/seq_file.h>
60585 #include <linux/slab.h>
60586 #include <linux/cred.h>
60587 +#include <linux/sched.h>
60588
60589 #include <asm/uaccess.h>
60590 #include <asm/page.h>
60591 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
60592 #ifdef CONFIG_USER_NS
60593 p->user_ns = file->f_cred->user_ns;
60594 #endif
60595 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60596 + p->exec_id = current->exec_id;
60597 +#endif
60598
60599 /*
60600 * Wrappers around seq_open(e.g. swaps_open) need to be
60601 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60602 return 0;
60603 }
60604 if (!m->buf) {
60605 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60606 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60607 if (!m->buf)
60608 return -ENOMEM;
60609 }
60610 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
60611 Eoverflow:
60612 m->op->stop(m, p);
60613 kfree(m->buf);
60614 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60615 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60616 return !m->buf ? -ENOMEM : -EAGAIN;
60617 }
60618
60619 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60620
60621 /* grab buffer if we didn't have one */
60622 if (!m->buf) {
60623 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
60624 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
60625 if (!m->buf)
60626 goto Enomem;
60627 }
60628 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
60629 goto Fill;
60630 m->op->stop(m, p);
60631 kfree(m->buf);
60632 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
60633 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
60634 if (!m->buf)
60635 goto Enomem;
60636 m->count = 0;
60637 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
60638 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
60639 void *data)
60640 {
60641 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
60642 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
60643 int res = -ENOMEM;
60644
60645 if (op) {
60646 diff --git a/fs/splice.c b/fs/splice.c
60647 index 3b7ee65..87fc2e4 100644
60648 --- a/fs/splice.c
60649 +++ b/fs/splice.c
60650 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60651 pipe_lock(pipe);
60652
60653 for (;;) {
60654 - if (!pipe->readers) {
60655 + if (!atomic_read(&pipe->readers)) {
60656 send_sig(SIGPIPE, current, 0);
60657 if (!ret)
60658 ret = -EPIPE;
60659 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60660 page_nr++;
60661 ret += buf->len;
60662
60663 - if (pipe->files)
60664 + if (atomic_read(&pipe->files))
60665 do_wakeup = 1;
60666
60667 if (!--spd->nr_pages)
60668 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
60669 do_wakeup = 0;
60670 }
60671
60672 - pipe->waiting_writers++;
60673 + atomic_inc(&pipe->waiting_writers);
60674 pipe_wait(pipe);
60675 - pipe->waiting_writers--;
60676 + atomic_dec(&pipe->waiting_writers);
60677 }
60678
60679 pipe_unlock(pipe);
60680 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
60681 old_fs = get_fs();
60682 set_fs(get_ds());
60683 /* The cast to a user pointer is valid due to the set_fs() */
60684 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
60685 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
60686 set_fs(old_fs);
60687
60688 return res;
60689 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
60690 old_fs = get_fs();
60691 set_fs(get_ds());
60692 /* The cast to a user pointer is valid due to the set_fs() */
60693 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
60694 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
60695 set_fs(old_fs);
60696
60697 return res;
60698 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
60699 goto err;
60700
60701 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
60702 - vec[i].iov_base = (void __user *) page_address(page);
60703 + vec[i].iov_base = (void __force_user *) page_address(page);
60704 vec[i].iov_len = this_len;
60705 spd.pages[i] = page;
60706 spd.nr_pages++;
60707 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
60708 ops->release(pipe, buf);
60709 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
60710 pipe->nrbufs--;
60711 - if (pipe->files)
60712 + if (atomic_read(&pipe->files))
60713 sd->need_wakeup = true;
60714 }
60715
60716 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
60717 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
60718 {
60719 while (!pipe->nrbufs) {
60720 - if (!pipe->writers)
60721 + if (!atomic_read(&pipe->writers))
60722 return 0;
60723
60724 - if (!pipe->waiting_writers && sd->num_spliced)
60725 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
60726 return 0;
60727
60728 if (sd->flags & SPLICE_F_NONBLOCK)
60729 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
60730 * out of the pipe right after the splice_to_pipe(). So set
60731 * PIPE_READERS appropriately.
60732 */
60733 - pipe->readers = 1;
60734 + atomic_set(&pipe->readers, 1);
60735
60736 current->splice_pipe = pipe;
60737 }
60738 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
60739
60740 partial[buffers].offset = off;
60741 partial[buffers].len = plen;
60742 + partial[buffers].private = 0;
60743
60744 off = 0;
60745 len -= plen;
60746 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60747 ret = -ERESTARTSYS;
60748 break;
60749 }
60750 - if (!pipe->writers)
60751 + if (!atomic_read(&pipe->writers))
60752 break;
60753 - if (!pipe->waiting_writers) {
60754 + if (!atomic_read(&pipe->waiting_writers)) {
60755 if (flags & SPLICE_F_NONBLOCK) {
60756 ret = -EAGAIN;
60757 break;
60758 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60759 pipe_lock(pipe);
60760
60761 while (pipe->nrbufs >= pipe->buffers) {
60762 - if (!pipe->readers) {
60763 + if (!atomic_read(&pipe->readers)) {
60764 send_sig(SIGPIPE, current, 0);
60765 ret = -EPIPE;
60766 break;
60767 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
60768 ret = -ERESTARTSYS;
60769 break;
60770 }
60771 - pipe->waiting_writers++;
60772 + atomic_inc(&pipe->waiting_writers);
60773 pipe_wait(pipe);
60774 - pipe->waiting_writers--;
60775 + atomic_dec(&pipe->waiting_writers);
60776 }
60777
60778 pipe_unlock(pipe);
60779 @@ -1862,14 +1863,14 @@ retry:
60780 pipe_double_lock(ipipe, opipe);
60781
60782 do {
60783 - if (!opipe->readers) {
60784 + if (!atomic_read(&opipe->readers)) {
60785 send_sig(SIGPIPE, current, 0);
60786 if (!ret)
60787 ret = -EPIPE;
60788 break;
60789 }
60790
60791 - if (!ipipe->nrbufs && !ipipe->writers)
60792 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
60793 break;
60794
60795 /*
60796 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60797 pipe_double_lock(ipipe, opipe);
60798
60799 do {
60800 - if (!opipe->readers) {
60801 + if (!atomic_read(&opipe->readers)) {
60802 send_sig(SIGPIPE, current, 0);
60803 if (!ret)
60804 ret = -EPIPE;
60805 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
60806 * return EAGAIN if we have the potential of some data in the
60807 * future, otherwise just return 0
60808 */
60809 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
60810 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
60811 ret = -EAGAIN;
60812
60813 pipe_unlock(ipipe);
60814 diff --git a/fs/stat.c b/fs/stat.c
60815 index 04ce1ac..a13dd1e 100644
60816 --- a/fs/stat.c
60817 +++ b/fs/stat.c
60818 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
60819 stat->gid = inode->i_gid;
60820 stat->rdev = inode->i_rdev;
60821 stat->size = i_size_read(inode);
60822 - stat->atime = inode->i_atime;
60823 - stat->mtime = inode->i_mtime;
60824 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60825 + stat->atime = inode->i_ctime;
60826 + stat->mtime = inode->i_ctime;
60827 + } else {
60828 + stat->atime = inode->i_atime;
60829 + stat->mtime = inode->i_mtime;
60830 + }
60831 stat->ctime = inode->i_ctime;
60832 stat->blksize = (1 << inode->i_blkbits);
60833 stat->blocks = inode->i_blocks;
60834 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
60835 if (retval)
60836 return retval;
60837
60838 - if (inode->i_op->getattr)
60839 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
60840 + if (inode->i_op->getattr) {
60841 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
60842 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
60843 + stat->atime = stat->ctime;
60844 + stat->mtime = stat->ctime;
60845 + }
60846 + return retval;
60847 + }
60848
60849 generic_fillattr(inode, stat);
60850 return 0;
60851 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
60852 index 15c68f9..36a8b3e 100644
60853 --- a/fs/sysfs/bin.c
60854 +++ b/fs/sysfs/bin.c
60855 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
60856 return ret;
60857 }
60858
60859 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
60860 - void *buf, int len, int write)
60861 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
60862 + void *buf, size_t len, int write)
60863 {
60864 struct file *file = vma->vm_file;
60865 struct bin_buffer *bb = file->private_data;
60866 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
60867 - int ret;
60868 + ssize_t ret;
60869
60870 if (!bb->vm_ops)
60871 return -EINVAL;
60872 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
60873 index e068e74..92edeb8 100644
60874 --- a/fs/sysfs/dir.c
60875 +++ b/fs/sysfs/dir.c
60876 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
60877 *
60878 * Returns 31 bit hash of ns + name (so it fits in an off_t )
60879 */
60880 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
60881 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
60882 {
60883 unsigned long hash = init_name_hash();
60884 unsigned int len = strlen(name);
60885 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
60886 struct sysfs_dirent *sd;
60887 int rc;
60888
60889 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
60890 + const char *parent_name = parent_sd->s_name;
60891 +
60892 + mode = S_IFDIR | S_IRWXU;
60893 +
60894 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
60895 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
60896 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
60897 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
60898 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
60899 +#endif
60900 +
60901 /* allocate */
60902 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
60903 if (!sd)
60904 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
60905 index d2bb7ed..fe8c331 100644
60906 --- a/fs/sysfs/file.c
60907 +++ b/fs/sysfs/file.c
60908 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
60909
60910 struct sysfs_open_dirent {
60911 atomic_t refcnt;
60912 - atomic_t event;
60913 + atomic_unchecked_t event;
60914 wait_queue_head_t poll;
60915 struct list_head buffers; /* goes through sysfs_buffer.list */
60916 };
60917 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
60918 if (!sysfs_get_active(attr_sd))
60919 return -ENODEV;
60920
60921 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
60922 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
60923 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
60924
60925 sysfs_put_active(attr_sd);
60926 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
60927 return -ENOMEM;
60928
60929 atomic_set(&new_od->refcnt, 0);
60930 - atomic_set(&new_od->event, 1);
60931 + atomic_set_unchecked(&new_od->event, 1);
60932 init_waitqueue_head(&new_od->poll);
60933 INIT_LIST_HEAD(&new_od->buffers);
60934 goto retry;
60935 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
60936
60937 sysfs_put_active(attr_sd);
60938
60939 - if (buffer->event != atomic_read(&od->event))
60940 + if (buffer->event != atomic_read_unchecked(&od->event))
60941 goto trigger;
60942
60943 return DEFAULT_POLLMASK;
60944 @@ -452,7 +452,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
60945 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
60946 od = sd->s_attr.open;
60947 if (od) {
60948 - atomic_inc(&od->event);
60949 + atomic_inc_unchecked(&od->event);
60950 wake_up_interruptible(&od->poll);
60951 }
60952 }
60953 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
60954 index 8c940df..25b733e 100644
60955 --- a/fs/sysfs/symlink.c
60956 +++ b/fs/sysfs/symlink.c
60957 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
60958
60959 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
60960 {
60961 - char *page = nd_get_link(nd);
60962 + const char *page = nd_get_link(nd);
60963 if (!IS_ERR(page))
60964 free_page((unsigned long)page);
60965 }
60966 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
60967 index 69d4889..a810bd4 100644
60968 --- a/fs/sysv/sysv.h
60969 +++ b/fs/sysv/sysv.h
60970 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
60971 #endif
60972 }
60973
60974 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60975 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
60976 {
60977 if (sbi->s_bytesex == BYTESEX_PDP)
60978 return PDP_swab((__force __u32)n);
60979 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
60980 index e18b988..f1d4ad0f 100644
60981 --- a/fs/ubifs/io.c
60982 +++ b/fs/ubifs/io.c
60983 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
60984 return err;
60985 }
60986
60987 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60988 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
60989 {
60990 int err;
60991
60992 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
60993 index c175b4d..8f36a16 100644
60994 --- a/fs/udf/misc.c
60995 +++ b/fs/udf/misc.c
60996 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
60997
60998 u8 udf_tag_checksum(const struct tag *t)
60999 {
61000 - u8 *data = (u8 *)t;
61001 + const u8 *data = (const u8 *)t;
61002 u8 checksum = 0;
61003 int i;
61004 for (i = 0; i < sizeof(struct tag); ++i)
61005 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
61006 index 8d974c4..b82f6ec 100644
61007 --- a/fs/ufs/swab.h
61008 +++ b/fs/ufs/swab.h
61009 @@ -22,7 +22,7 @@ enum {
61010 BYTESEX_BE
61011 };
61012
61013 -static inline u64
61014 +static inline u64 __intentional_overflow(-1)
61015 fs64_to_cpu(struct super_block *sbp, __fs64 n)
61016 {
61017 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61018 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
61019 return (__force __fs64)cpu_to_be64(n);
61020 }
61021
61022 -static inline u32
61023 +static inline u32 __intentional_overflow(-1)
61024 fs32_to_cpu(struct super_block *sbp, __fs32 n)
61025 {
61026 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
61027 diff --git a/fs/utimes.c b/fs/utimes.c
61028 index f4fb7ec..3fe03c0 100644
61029 --- a/fs/utimes.c
61030 +++ b/fs/utimes.c
61031 @@ -1,6 +1,7 @@
61032 #include <linux/compiler.h>
61033 #include <linux/file.h>
61034 #include <linux/fs.h>
61035 +#include <linux/security.h>
61036 #include <linux/linkage.h>
61037 #include <linux/mount.h>
61038 #include <linux/namei.h>
61039 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
61040 goto mnt_drop_write_and_out;
61041 }
61042 }
61043 +
61044 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
61045 + error = -EACCES;
61046 + goto mnt_drop_write_and_out;
61047 + }
61048 +
61049 mutex_lock(&inode->i_mutex);
61050 error = notify_change(path->dentry, &newattrs);
61051 mutex_unlock(&inode->i_mutex);
61052 diff --git a/fs/xattr.c b/fs/xattr.c
61053 index 3377dff..4d074d9 100644
61054 --- a/fs/xattr.c
61055 +++ b/fs/xattr.c
61056 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
61057 return rc;
61058 }
61059
61060 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
61061 +ssize_t
61062 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
61063 +{
61064 + struct inode *inode = dentry->d_inode;
61065 + ssize_t error;
61066 +
61067 + error = inode_permission(inode, MAY_EXEC);
61068 + if (error)
61069 + return error;
61070 +
61071 + if (inode->i_op->getxattr)
61072 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
61073 + else
61074 + error = -EOPNOTSUPP;
61075 +
61076 + return error;
61077 +}
61078 +EXPORT_SYMBOL(pax_getxattr);
61079 +#endif
61080 +
61081 ssize_t
61082 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
61083 {
61084 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
61085 * Extended attribute SET operations
61086 */
61087 static long
61088 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
61089 +setxattr(struct path *path, const char __user *name, const void __user *value,
61090 size_t size, int flags)
61091 {
61092 int error;
61093 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
61094 posix_acl_fix_xattr_from_user(kvalue, size);
61095 }
61096
61097 - error = vfs_setxattr(d, kname, kvalue, size, flags);
61098 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
61099 + error = -EACCES;
61100 + goto out;
61101 + }
61102 +
61103 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
61104 out:
61105 if (vvalue)
61106 vfree(vvalue);
61107 @@ -377,7 +403,7 @@ retry:
61108 return error;
61109 error = mnt_want_write(path.mnt);
61110 if (!error) {
61111 - error = setxattr(path.dentry, name, value, size, flags);
61112 + error = setxattr(&path, name, value, size, flags);
61113 mnt_drop_write(path.mnt);
61114 }
61115 path_put(&path);
61116 @@ -401,7 +427,7 @@ retry:
61117 return error;
61118 error = mnt_want_write(path.mnt);
61119 if (!error) {
61120 - error = setxattr(path.dentry, name, value, size, flags);
61121 + error = setxattr(&path, name, value, size, flags);
61122 mnt_drop_write(path.mnt);
61123 }
61124 path_put(&path);
61125 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
61126 const void __user *,value, size_t, size, int, flags)
61127 {
61128 struct fd f = fdget(fd);
61129 - struct dentry *dentry;
61130 int error = -EBADF;
61131
61132 if (!f.file)
61133 return error;
61134 - dentry = f.file->f_path.dentry;
61135 - audit_inode(NULL, dentry, 0);
61136 + audit_inode(NULL, f.file->f_path.dentry, 0);
61137 error = mnt_want_write_file(f.file);
61138 if (!error) {
61139 - error = setxattr(dentry, name, value, size, flags);
61140 + error = setxattr(&f.file->f_path, name, value, size, flags);
61141 mnt_drop_write_file(f.file);
61142 }
61143 fdput(f);
61144 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
61145 index 9fbea87..6b19972 100644
61146 --- a/fs/xattr_acl.c
61147 +++ b/fs/xattr_acl.c
61148 @@ -76,8 +76,8 @@ struct posix_acl *
61149 posix_acl_from_xattr(struct user_namespace *user_ns,
61150 const void *value, size_t size)
61151 {
61152 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
61153 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
61154 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
61155 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
61156 int count;
61157 struct posix_acl *acl;
61158 struct posix_acl_entry *acl_e;
61159 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
61160 index 05c698c..6b918af 100644
61161 --- a/fs/xfs/xfs_bmap.c
61162 +++ b/fs/xfs/xfs_bmap.c
61163 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
61164
61165 #else
61166 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
61167 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
61168 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
61169 #endif /* DEBUG */
61170
61171 /*
61172 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
61173 index 97676a3..399a75d 100644
61174 --- a/fs/xfs/xfs_dir2_sf.c
61175 +++ b/fs/xfs/xfs_dir2_sf.c
61176 @@ -848,7 +848,12 @@ xfs_dir2_sf_getdents(
61177
61178 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
61179 ctx->pos = off & 0x7fffffff;
61180 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61181 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
61182 + char name[sfep->namelen];
61183 + memcpy(name, sfep->name, sfep->namelen);
61184 + if (!dir_emit(ctx, name, sfep->namelen, ino, DT_UNKNOWN))
61185 + return 0;
61186 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen,
61187 ino, DT_UNKNOWN))
61188 return 0;
61189 sfep = xfs_dir2_sf_nextentry(sfp, sfep);
61190 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
61191 index 6e2bca5..6ce80d3 100644
61192 --- a/fs/xfs/xfs_ioctl.c
61193 +++ b/fs/xfs/xfs_ioctl.c
61194 @@ -127,7 +127,7 @@ xfs_find_handle(
61195 }
61196
61197 error = -EFAULT;
61198 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
61199 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
61200 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
61201 goto out_put;
61202
61203 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
61204 index 96dda62..d6c6a52 100644
61205 --- a/fs/xfs/xfs_iops.c
61206 +++ b/fs/xfs/xfs_iops.c
61207 @@ -395,7 +395,7 @@ xfs_vn_put_link(
61208 struct nameidata *nd,
61209 void *p)
61210 {
61211 - char *s = nd_get_link(nd);
61212 + const char *s = nd_get_link(nd);
61213
61214 if (!IS_ERR(s))
61215 kfree(s);
61216 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
61217 new file mode 100644
61218 index 0000000..0fd7c82
61219 --- /dev/null
61220 +++ b/grsecurity/Kconfig
61221 @@ -0,0 +1,1080 @@
61222 +#
61223 +# grecurity configuration
61224 +#
61225 +menu "Memory Protections"
61226 +depends on GRKERNSEC
61227 +
61228 +config GRKERNSEC_KMEM
61229 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
61230 + default y if GRKERNSEC_CONFIG_AUTO
61231 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
61232 + help
61233 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
61234 + be written to or read from to modify or leak the contents of the running
61235 + kernel. /dev/port will also not be allowed to be opened and support
61236 + for /dev/cpu/*/msr will be removed. If you have module
61237 + support disabled, enabling this will close up five ways that are
61238 + currently used to insert malicious code into the running kernel.
61239 +
61240 + Even with all these features enabled, we still highly recommend that
61241 + you use the RBAC system, as it is still possible for an attacker to
61242 + modify the running kernel through privileged I/O granted by ioperm/iopl.
61243 +
61244 + If you are not using XFree86, you may be able to stop this additional
61245 + case by enabling the 'Disable privileged I/O' option. Though nothing
61246 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
61247 + but only to video memory, which is the only writing we allow in this
61248 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
61249 + not be allowed to mprotect it with PROT_WRITE later.
61250 + Enabling this feature will prevent the "cpupower" and "powertop" tools
61251 + from working.
61252 +
61253 + It is highly recommended that you say Y here if you meet all the
61254 + conditions above.
61255 +
61256 +config GRKERNSEC_VM86
61257 + bool "Restrict VM86 mode"
61258 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61259 + depends on X86_32
61260 +
61261 + help
61262 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
61263 + make use of a special execution mode on 32bit x86 processors called
61264 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
61265 + video cards and will still work with this option enabled. The purpose
61266 + of the option is to prevent exploitation of emulation errors in
61267 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
61268 + Nearly all users should be able to enable this option.
61269 +
61270 +config GRKERNSEC_IO
61271 + bool "Disable privileged I/O"
61272 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61273 + depends on X86
61274 + select RTC_CLASS
61275 + select RTC_INTF_DEV
61276 + select RTC_DRV_CMOS
61277 +
61278 + help
61279 + If you say Y here, all ioperm and iopl calls will return an error.
61280 + Ioperm and iopl can be used to modify the running kernel.
61281 + Unfortunately, some programs need this access to operate properly,
61282 + the most notable of which are XFree86 and hwclock. hwclock can be
61283 + remedied by having RTC support in the kernel, so real-time
61284 + clock support is enabled if this option is enabled, to ensure
61285 + that hwclock operates correctly. XFree86 still will not
61286 + operate correctly with this option enabled, so DO NOT CHOOSE Y
61287 + IF YOU USE XFree86. If you use XFree86 and you still want to
61288 + protect your kernel against modification, use the RBAC system.
61289 +
61290 +config GRKERNSEC_JIT_HARDEN
61291 + bool "Harden BPF JIT against spray attacks"
61292 + default y if GRKERNSEC_CONFIG_AUTO
61293 + depends on BPF_JIT
61294 + help
61295 + If you say Y here, the native code generated by the kernel's Berkeley
61296 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
61297 + attacks that attempt to fit attacker-beneficial instructions in
61298 + 32bit immediate fields of JIT-generated native instructions. The
61299 + attacker will generally aim to cause an unintended instruction sequence
61300 + of JIT-generated native code to execute by jumping into the middle of
61301 + a generated instruction. This feature effectively randomizes the 32bit
61302 + immediate constants present in the generated code to thwart such attacks.
61303 +
61304 + If you're using KERNEXEC, it's recommended that you enable this option
61305 + to supplement the hardening of the kernel.
61306 +
61307 +config GRKERNSEC_PERF_HARDEN
61308 + bool "Disable unprivileged PERF_EVENTS usage by default"
61309 + default y if GRKERNSEC_CONFIG_AUTO
61310 + depends on PERF_EVENTS
61311 + help
61312 + If you say Y here, the range of acceptable values for the
61313 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
61314 + default to a new value: 3. When the sysctl is set to this value, no
61315 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
61316 +
61317 + Though PERF_EVENTS can be used legitimately for performance monitoring
61318 + and low-level application profiling, it is forced on regardless of
61319 + configuration, has been at fault for several vulnerabilities, and
61320 + creates new opportunities for side channels and other information leaks.
61321 +
61322 + This feature puts PERF_EVENTS into a secure default state and permits
61323 + the administrator to change out of it temporarily if unprivileged
61324 + application profiling is needed.
61325 +
61326 +config GRKERNSEC_RAND_THREADSTACK
61327 + bool "Insert random gaps between thread stacks"
61328 + default y if GRKERNSEC_CONFIG_AUTO
61329 + depends on PAX_RANDMMAP && !PPC
61330 + help
61331 + If you say Y here, a random-sized gap will be enforced between allocated
61332 + thread stacks. Glibc's NPTL and other threading libraries that
61333 + pass MAP_STACK to the kernel for thread stack allocation are supported.
61334 + The implementation currently provides 8 bits of entropy for the gap.
61335 +
61336 + Many distributions do not compile threaded remote services with the
61337 + -fstack-check argument to GCC, causing the variable-sized stack-based
61338 + allocator, alloca(), to not probe the stack on allocation. This
61339 + permits an unbounded alloca() to skip over any guard page and potentially
61340 + modify another thread's stack reliably. An enforced random gap
61341 + reduces the reliability of such an attack and increases the chance
61342 + that such a read/write to another thread's stack instead lands in
61343 + an unmapped area, causing a crash and triggering grsecurity's
61344 + anti-bruteforcing logic.
61345 +
61346 +config GRKERNSEC_PROC_MEMMAP
61347 + bool "Harden ASLR against information leaks and entropy reduction"
61348 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
61349 + depends on PAX_NOEXEC || PAX_ASLR
61350 + help
61351 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
61352 + give no information about the addresses of its mappings if
61353 + PaX features that rely on random addresses are enabled on the task.
61354 + In addition to sanitizing this information and disabling other
61355 + dangerous sources of information, this option causes reads of sensitive
61356 + /proc/<pid> entries where the file descriptor was opened in a different
61357 + task than the one performing the read. Such attempts are logged.
61358 + This option also limits argv/env strings for suid/sgid binaries
61359 + to 512KB to prevent a complete exhaustion of the stack entropy provided
61360 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
61361 + binaries to prevent alternative mmap layouts from being abused.
61362 +
61363 + If you use PaX it is essential that you say Y here as it closes up
61364 + several holes that make full ASLR useless locally.
61365 +
61366 +config GRKERNSEC_BRUTE
61367 + bool "Deter exploit bruteforcing"
61368 + default y if GRKERNSEC_CONFIG_AUTO
61369 + help
61370 + If you say Y here, attempts to bruteforce exploits against forking
61371 + daemons such as apache or sshd, as well as against suid/sgid binaries
61372 + will be deterred. When a child of a forking daemon is killed by PaX
61373 + or crashes due to an illegal instruction or other suspicious signal,
61374 + the parent process will be delayed 30 seconds upon every subsequent
61375 + fork until the administrator is able to assess the situation and
61376 + restart the daemon.
61377 + In the suid/sgid case, the attempt is logged, the user has all their
61378 + existing instances of the suid/sgid binary terminated and will
61379 + be unable to execute any suid/sgid binaries for 15 minutes.
61380 +
61381 + It is recommended that you also enable signal logging in the auditing
61382 + section so that logs are generated when a process triggers a suspicious
61383 + signal.
61384 + If the sysctl option is enabled, a sysctl option with name
61385 + "deter_bruteforce" is created.
61386 +
61387 +
61388 +config GRKERNSEC_MODHARDEN
61389 + bool "Harden module auto-loading"
61390 + default y if GRKERNSEC_CONFIG_AUTO
61391 + depends on MODULES
61392 + help
61393 + If you say Y here, module auto-loading in response to use of some
61394 + feature implemented by an unloaded module will be restricted to
61395 + root users. Enabling this option helps defend against attacks
61396 + by unprivileged users who abuse the auto-loading behavior to
61397 + cause a vulnerable module to load that is then exploited.
61398 +
61399 + If this option prevents a legitimate use of auto-loading for a
61400 + non-root user, the administrator can execute modprobe manually
61401 + with the exact name of the module mentioned in the alert log.
61402 + Alternatively, the administrator can add the module to the list
61403 + of modules loaded at boot by modifying init scripts.
61404 +
61405 + Modification of init scripts will most likely be needed on
61406 + Ubuntu servers with encrypted home directory support enabled,
61407 + as the first non-root user logging in will cause the ecb(aes),
61408 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
61409 +
61410 +config GRKERNSEC_HIDESYM
61411 + bool "Hide kernel symbols"
61412 + default y if GRKERNSEC_CONFIG_AUTO
61413 + select PAX_USERCOPY_SLABS
61414 + help
61415 + If you say Y here, getting information on loaded modules, and
61416 + displaying all kernel symbols through a syscall will be restricted
61417 + to users with CAP_SYS_MODULE. For software compatibility reasons,
61418 + /proc/kallsyms will be restricted to the root user. The RBAC
61419 + system can hide that entry even from root.
61420 +
61421 + This option also prevents leaking of kernel addresses through
61422 + several /proc entries.
61423 +
61424 + Note that this option is only effective provided the following
61425 + conditions are met:
61426 + 1) The kernel using grsecurity is not precompiled by some distribution
61427 + 2) You have also enabled GRKERNSEC_DMESG
61428 + 3) You are using the RBAC system and hiding other files such as your
61429 + kernel image and System.map. Alternatively, enabling this option
61430 + causes the permissions on /boot, /lib/modules, and the kernel
61431 + source directory to change at compile time to prevent
61432 + reading by non-root users.
61433 + If the above conditions are met, this option will aid in providing a
61434 + useful protection against local kernel exploitation of overflows
61435 + and arbitrary read/write vulnerabilities.
61436 +
61437 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
61438 + in addition to this feature.
61439 +
61440 +config GRKERNSEC_KERN_LOCKOUT
61441 + bool "Active kernel exploit response"
61442 + default y if GRKERNSEC_CONFIG_AUTO
61443 + depends on X86 || ARM || PPC || SPARC
61444 + help
61445 + If you say Y here, when a PaX alert is triggered due to suspicious
61446 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
61447 + or an OOPS occurs due to bad memory accesses, instead of just
61448 + terminating the offending process (and potentially allowing
61449 + a subsequent exploit from the same user), we will take one of two
61450 + actions:
61451 + If the user was root, we will panic the system
61452 + If the user was non-root, we will log the attempt, terminate
61453 + all processes owned by the user, then prevent them from creating
61454 + any new processes until the system is restarted
61455 + This deters repeated kernel exploitation/bruteforcing attempts
61456 + and is useful for later forensics.
61457 +
61458 +endmenu
61459 +menu "Role Based Access Control Options"
61460 +depends on GRKERNSEC
61461 +
61462 +config GRKERNSEC_RBAC_DEBUG
61463 + bool
61464 +
61465 +config GRKERNSEC_NO_RBAC
61466 + bool "Disable RBAC system"
61467 + help
61468 + If you say Y here, the /dev/grsec device will be removed from the kernel,
61469 + preventing the RBAC system from being enabled. You should only say Y
61470 + here if you have no intention of using the RBAC system, so as to prevent
61471 + an attacker with root access from misusing the RBAC system to hide files
61472 + and processes when loadable module support and /dev/[k]mem have been
61473 + locked down.
61474 +
61475 +config GRKERNSEC_ACL_HIDEKERN
61476 + bool "Hide kernel processes"
61477 + help
61478 + If you say Y here, all kernel threads will be hidden to all
61479 + processes but those whose subject has the "view hidden processes"
61480 + flag.
61481 +
61482 +config GRKERNSEC_ACL_MAXTRIES
61483 + int "Maximum tries before password lockout"
61484 + default 3
61485 + help
61486 + This option enforces the maximum number of times a user can attempt
61487 + to authorize themselves with the grsecurity RBAC system before being
61488 + denied the ability to attempt authorization again for a specified time.
61489 + The lower the number, the harder it will be to brute-force a password.
61490 +
61491 +config GRKERNSEC_ACL_TIMEOUT
61492 + int "Time to wait after max password tries, in seconds"
61493 + default 30
61494 + help
61495 + This option specifies the time the user must wait after attempting to
61496 + authorize to the RBAC system with the maximum number of invalid
61497 + passwords. The higher the number, the harder it will be to brute-force
61498 + a password.
61499 +
61500 +endmenu
61501 +menu "Filesystem Protections"
61502 +depends on GRKERNSEC
61503 +
61504 +config GRKERNSEC_PROC
61505 + bool "Proc restrictions"
61506 + default y if GRKERNSEC_CONFIG_AUTO
61507 + help
61508 + If you say Y here, the permissions of the /proc filesystem
61509 + will be altered to enhance system security and privacy. You MUST
61510 + choose either a user only restriction or a user and group restriction.
61511 + Depending upon the option you choose, you can either restrict users to
61512 + see only the processes they themselves run, or choose a group that can
61513 + view all processes and files normally restricted to root if you choose
61514 + the "restrict to user only" option. NOTE: If you're running identd or
61515 + ntpd as a non-root user, you will have to run it as the group you
61516 + specify here.
61517 +
61518 +config GRKERNSEC_PROC_USER
61519 + bool "Restrict /proc to user only"
61520 + depends on GRKERNSEC_PROC
61521 + help
61522 + If you say Y here, non-root users will only be able to view their own
61523 + processes, and restricts them from viewing network-related information,
61524 + and viewing kernel symbol and module information.
61525 +
61526 +config GRKERNSEC_PROC_USERGROUP
61527 + bool "Allow special group"
61528 + default y if GRKERNSEC_CONFIG_AUTO
61529 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
61530 + help
61531 + If you say Y here, you will be able to select a group that will be
61532 + able to view all processes and network-related information. If you've
61533 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
61534 + remain hidden. This option is useful if you want to run identd as
61535 + a non-root user. The group you select may also be chosen at boot time
61536 + via "grsec_proc_gid=" on the kernel commandline.
61537 +
61538 +config GRKERNSEC_PROC_GID
61539 + int "GID for special group"
61540 + depends on GRKERNSEC_PROC_USERGROUP
61541 + default 1001
61542 +
61543 +config GRKERNSEC_PROC_ADD
61544 + bool "Additional restrictions"
61545 + default y if GRKERNSEC_CONFIG_AUTO
61546 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
61547 + help
61548 + If you say Y here, additional restrictions will be placed on
61549 + /proc that keep normal users from viewing device information and
61550 + slabinfo information that could be useful for exploits.
61551 +
61552 +config GRKERNSEC_LINK
61553 + bool "Linking restrictions"
61554 + default y if GRKERNSEC_CONFIG_AUTO
61555 + help
61556 + If you say Y here, /tmp race exploits will be prevented, since users
61557 + will no longer be able to follow symlinks owned by other users in
61558 + world-writable +t directories (e.g. /tmp), unless the owner of the
61559 + symlink is the owner of the directory. users will also not be
61560 + able to hardlink to files they do not own. If the sysctl option is
61561 + enabled, a sysctl option with name "linking_restrictions" is created.
61562 +
61563 +config GRKERNSEC_SYMLINKOWN
61564 + bool "Kernel-enforced SymlinksIfOwnerMatch"
61565 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
61566 + help
61567 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
61568 + that prevents it from being used as a security feature. As Apache
61569 + verifies the symlink by performing a stat() against the target of
61570 + the symlink before it is followed, an attacker can setup a symlink
61571 + to point to a same-owned file, then replace the symlink with one
61572 + that targets another user's file just after Apache "validates" the
61573 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
61574 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
61575 + will be in place for the group you specify. If the sysctl option
61576 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
61577 + created.
61578 +
61579 +config GRKERNSEC_SYMLINKOWN_GID
61580 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
61581 + depends on GRKERNSEC_SYMLINKOWN
61582 + default 1006
61583 + help
61584 + Setting this GID determines what group kernel-enforced
61585 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
61586 + is enabled, a sysctl option with name "symlinkown_gid" is created.
61587 +
61588 +config GRKERNSEC_FIFO
61589 + bool "FIFO restrictions"
61590 + default y if GRKERNSEC_CONFIG_AUTO
61591 + help
61592 + If you say Y here, users will not be able to write to FIFOs they don't
61593 + own in world-writable +t directories (e.g. /tmp), unless the owner of
61594 + the FIFO is the same owner of the directory it's held in. If the sysctl
61595 + option is enabled, a sysctl option with name "fifo_restrictions" is
61596 + created.
61597 +
61598 +config GRKERNSEC_SYSFS_RESTRICT
61599 + bool "Sysfs/debugfs restriction"
61600 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
61601 + depends on SYSFS
61602 + help
61603 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
61604 + any filesystem normally mounted under it (e.g. debugfs) will be
61605 + mostly accessible only by root. These filesystems generally provide access
61606 + to hardware and debug information that isn't appropriate for unprivileged
61607 + users of the system. Sysfs and debugfs have also become a large source
61608 + of new vulnerabilities, ranging from infoleaks to local compromise.
61609 + There has been very little oversight with an eye toward security involved
61610 + in adding new exporters of information to these filesystems, so their
61611 + use is discouraged.
61612 + For reasons of compatibility, a few directories have been whitelisted
61613 + for access by non-root users:
61614 + /sys/fs/selinux
61615 + /sys/fs/fuse
61616 + /sys/devices/system/cpu
61617 +
61618 +config GRKERNSEC_ROFS
61619 + bool "Runtime read-only mount protection"
61620 + depends on SYSCTL
61621 + help
61622 + If you say Y here, a sysctl option with name "romount_protect" will
61623 + be created. By setting this option to 1 at runtime, filesystems
61624 + will be protected in the following ways:
61625 + * No new writable mounts will be allowed
61626 + * Existing read-only mounts won't be able to be remounted read/write
61627 + * Write operations will be denied on all block devices
61628 + This option acts independently of grsec_lock: once it is set to 1,
61629 + it cannot be turned off. Therefore, please be mindful of the resulting
61630 + behavior if this option is enabled in an init script on a read-only
61631 + filesystem. This feature is mainly intended for secure embedded systems.
61632 +
61633 +config GRKERNSEC_DEVICE_SIDECHANNEL
61634 + bool "Eliminate stat/notify-based device sidechannels"
61635 + default y if GRKERNSEC_CONFIG_AUTO
61636 + help
61637 + If you say Y here, timing analyses on block or character
61638 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
61639 + will be thwarted for unprivileged users. If a process without
61640 + CAP_MKNOD stats such a device, the last access and last modify times
61641 + will match the device's create time. No access or modify events
61642 + will be triggered through inotify/dnotify/fanotify for such devices.
61643 + This feature will prevent attacks that may at a minimum
61644 + allow an attacker to determine the administrator's password length.
61645 +
61646 +config GRKERNSEC_CHROOT
61647 + bool "Chroot jail restrictions"
61648 + default y if GRKERNSEC_CONFIG_AUTO
61649 + help
61650 + If you say Y here, you will be able to choose several options that will
61651 + make breaking out of a chrooted jail much more difficult. If you
61652 + encounter no software incompatibilities with the following options, it
61653 + is recommended that you enable each one.
61654 +
61655 +config GRKERNSEC_CHROOT_MOUNT
61656 + bool "Deny mounts"
61657 + default y if GRKERNSEC_CONFIG_AUTO
61658 + depends on GRKERNSEC_CHROOT
61659 + help
61660 + If you say Y here, processes inside a chroot will not be able to
61661 + mount or remount filesystems. If the sysctl option is enabled, a
61662 + sysctl option with name "chroot_deny_mount" is created.
61663 +
61664 +config GRKERNSEC_CHROOT_DOUBLE
61665 + bool "Deny double-chroots"
61666 + default y if GRKERNSEC_CONFIG_AUTO
61667 + depends on GRKERNSEC_CHROOT
61668 + help
61669 + If you say Y here, processes inside a chroot will not be able to chroot
61670 + again outside the chroot. This is a widely used method of breaking
61671 + out of a chroot jail and should not be allowed. If the sysctl
61672 + option is enabled, a sysctl option with name
61673 + "chroot_deny_chroot" is created.
61674 +
61675 +config GRKERNSEC_CHROOT_PIVOT
61676 + bool "Deny pivot_root in chroot"
61677 + default y if GRKERNSEC_CONFIG_AUTO
61678 + depends on GRKERNSEC_CHROOT
61679 + help
61680 + If you say Y here, processes inside a chroot will not be able to use
61681 + a function called pivot_root() that was introduced in Linux 2.3.41. It
61682 + works similar to chroot in that it changes the root filesystem. This
61683 + function could be misused in a chrooted process to attempt to break out
61684 + of the chroot, and therefore should not be allowed. If the sysctl
61685 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
61686 + created.
61687 +
61688 +config GRKERNSEC_CHROOT_CHDIR
61689 + bool "Enforce chdir(\"/\") on all chroots"
61690 + default y if GRKERNSEC_CONFIG_AUTO
61691 + depends on GRKERNSEC_CHROOT
61692 + help
61693 + If you say Y here, the current working directory of all newly-chrooted
61694 + applications will be set to the the root directory of the chroot.
61695 + The man page on chroot(2) states:
61696 + Note that this call does not change the current working
61697 + directory, so that `.' can be outside the tree rooted at
61698 + `/'. In particular, the super-user can escape from a
61699 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
61700 +
61701 + It is recommended that you say Y here, since it's not known to break
61702 + any software. If the sysctl option is enabled, a sysctl option with
61703 + name "chroot_enforce_chdir" is created.
61704 +
61705 +config GRKERNSEC_CHROOT_CHMOD
61706 + bool "Deny (f)chmod +s"
61707 + default y if GRKERNSEC_CONFIG_AUTO
61708 + depends on GRKERNSEC_CHROOT
61709 + help
61710 + If you say Y here, processes inside a chroot will not be able to chmod
61711 + or fchmod files to make them have suid or sgid bits. This protects
61712 + against another published method of breaking a chroot. If the sysctl
61713 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
61714 + created.
61715 +
61716 +config GRKERNSEC_CHROOT_FCHDIR
61717 + bool "Deny fchdir out of chroot"
61718 + default y if GRKERNSEC_CONFIG_AUTO
61719 + depends on GRKERNSEC_CHROOT
61720 + help
61721 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
61722 + to a file descriptor of the chrooting process that points to a directory
61723 + outside the filesystem will be stopped. If the sysctl option
61724 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
61725 +
61726 +config GRKERNSEC_CHROOT_MKNOD
61727 + bool "Deny mknod"
61728 + default y if GRKERNSEC_CONFIG_AUTO
61729 + depends on GRKERNSEC_CHROOT
61730 + help
61731 + If you say Y here, processes inside a chroot will not be allowed to
61732 + mknod. The problem with using mknod inside a chroot is that it
61733 + would allow an attacker to create a device entry that is the same
61734 + as one on the physical root of your system, which could range from
61735 + anything from the console device to a device for your harddrive (which
61736 + they could then use to wipe the drive or steal data). It is recommended
61737 + that you say Y here, unless you run into software incompatibilities.
61738 + If the sysctl option is enabled, a sysctl option with name
61739 + "chroot_deny_mknod" is created.
61740 +
61741 +config GRKERNSEC_CHROOT_SHMAT
61742 + bool "Deny shmat() out of chroot"
61743 + default y if GRKERNSEC_CONFIG_AUTO
61744 + depends on GRKERNSEC_CHROOT
61745 + help
61746 + If you say Y here, processes inside a chroot will not be able to attach
61747 + to shared memory segments that were created outside of the chroot jail.
61748 + It is recommended that you say Y here. If the sysctl option is enabled,
61749 + a sysctl option with name "chroot_deny_shmat" is created.
61750 +
61751 +config GRKERNSEC_CHROOT_UNIX
61752 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
61753 + default y if GRKERNSEC_CONFIG_AUTO
61754 + depends on GRKERNSEC_CHROOT
61755 + help
61756 + If you say Y here, processes inside a chroot will not be able to
61757 + connect to abstract (meaning not belonging to a filesystem) Unix
61758 + domain sockets that were bound outside of a chroot. It is recommended
61759 + that you say Y here. If the sysctl option is enabled, a sysctl option
61760 + with name "chroot_deny_unix" is created.
61761 +
61762 +config GRKERNSEC_CHROOT_FINDTASK
61763 + bool "Protect outside processes"
61764 + default y if GRKERNSEC_CONFIG_AUTO
61765 + depends on GRKERNSEC_CHROOT
61766 + help
61767 + If you say Y here, processes inside a chroot will not be able to
61768 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
61769 + getsid, or view any process outside of the chroot. If the sysctl
61770 + option is enabled, a sysctl option with name "chroot_findtask" is
61771 + created.
61772 +
61773 +config GRKERNSEC_CHROOT_NICE
61774 + bool "Restrict priority changes"
61775 + default y if GRKERNSEC_CONFIG_AUTO
61776 + depends on GRKERNSEC_CHROOT
61777 + help
61778 + If you say Y here, processes inside a chroot will not be able to raise
61779 + the priority of processes in the chroot, or alter the priority of
61780 + processes outside the chroot. This provides more security than simply
61781 + removing CAP_SYS_NICE from the process' capability set. If the
61782 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
61783 + is created.
61784 +
61785 +config GRKERNSEC_CHROOT_SYSCTL
61786 + bool "Deny sysctl writes"
61787 + default y if GRKERNSEC_CONFIG_AUTO
61788 + depends on GRKERNSEC_CHROOT
61789 + help
61790 + If you say Y here, an attacker in a chroot will not be able to
61791 + write to sysctl entries, either by sysctl(2) or through a /proc
61792 + interface. It is strongly recommended that you say Y here. If the
61793 + sysctl option is enabled, a sysctl option with name
61794 + "chroot_deny_sysctl" is created.
61795 +
61796 +config GRKERNSEC_CHROOT_CAPS
61797 + bool "Capability restrictions"
61798 + default y if GRKERNSEC_CONFIG_AUTO
61799 + depends on GRKERNSEC_CHROOT
61800 + help
61801 + If you say Y here, the capabilities on all processes within a
61802 + chroot jail will be lowered to stop module insertion, raw i/o,
61803 + system and net admin tasks, rebooting the system, modifying immutable
61804 + files, modifying IPC owned by another, and changing the system time.
61805 + This is left an option because it can break some apps. Disable this
61806 + if your chrooted apps are having problems performing those kinds of
61807 + tasks. If the sysctl option is enabled, a sysctl option with
61808 + name "chroot_caps" is created.
61809 +
61810 +config GRKERNSEC_CHROOT_INITRD
61811 + bool "Exempt initrd tasks from restrictions"
61812 + default y if GRKERNSEC_CONFIG_AUTO
61813 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
61814 + help
61815 + If you say Y here, tasks started prior to init will be exempted from
61816 + grsecurity's chroot restrictions. This option is mainly meant to
61817 + resolve Plymouth's performing privileged operations unnecessarily
61818 + in a chroot.
61819 +
61820 +endmenu
61821 +menu "Kernel Auditing"
61822 +depends on GRKERNSEC
61823 +
61824 +config GRKERNSEC_AUDIT_GROUP
61825 + bool "Single group for auditing"
61826 + help
61827 + If you say Y here, the exec and chdir logging features will only operate
61828 + on a group you specify. This option is recommended if you only want to
61829 + watch certain users instead of having a large amount of logs from the
61830 + entire system. If the sysctl option is enabled, a sysctl option with
61831 + name "audit_group" is created.
61832 +
61833 +config GRKERNSEC_AUDIT_GID
61834 + int "GID for auditing"
61835 + depends on GRKERNSEC_AUDIT_GROUP
61836 + default 1007
61837 +
61838 +config GRKERNSEC_EXECLOG
61839 + bool "Exec logging"
61840 + help
61841 + If you say Y here, all execve() calls will be logged (since the
61842 + other exec*() calls are frontends to execve(), all execution
61843 + will be logged). Useful for shell-servers that like to keep track
61844 + of their users. If the sysctl option is enabled, a sysctl option with
61845 + name "exec_logging" is created.
61846 + WARNING: This option when enabled will produce a LOT of logs, especially
61847 + on an active system.
61848 +
61849 +config GRKERNSEC_RESLOG
61850 + bool "Resource logging"
61851 + default y if GRKERNSEC_CONFIG_AUTO
61852 + help
61853 + If you say Y here, all attempts to overstep resource limits will
61854 + be logged with the resource name, the requested size, and the current
61855 + limit. It is highly recommended that you say Y here. If the sysctl
61856 + option is enabled, a sysctl option with name "resource_logging" is
61857 + created. If the RBAC system is enabled, the sysctl value is ignored.
61858 +
61859 +config GRKERNSEC_CHROOT_EXECLOG
61860 + bool "Log execs within chroot"
61861 + help
61862 + If you say Y here, all executions inside a chroot jail will be logged
61863 + to syslog. This can cause a large amount of logs if certain
61864 + applications (eg. djb's daemontools) are installed on the system, and
61865 + is therefore left as an option. If the sysctl option is enabled, a
61866 + sysctl option with name "chroot_execlog" is created.
61867 +
61868 +config GRKERNSEC_AUDIT_PTRACE
61869 + bool "Ptrace logging"
61870 + help
61871 + If you say Y here, all attempts to attach to a process via ptrace
61872 + will be logged. If the sysctl option is enabled, a sysctl option
61873 + with name "audit_ptrace" is created.
61874 +
61875 +config GRKERNSEC_AUDIT_CHDIR
61876 + bool "Chdir logging"
61877 + help
61878 + If you say Y here, all chdir() calls will be logged. If the sysctl
61879 + option is enabled, a sysctl option with name "audit_chdir" is created.
61880 +
61881 +config GRKERNSEC_AUDIT_MOUNT
61882 + bool "(Un)Mount logging"
61883 + help
61884 + If you say Y here, all mounts and unmounts will be logged. If the
61885 + sysctl option is enabled, a sysctl option with name "audit_mount" is
61886 + created.
61887 +
61888 +config GRKERNSEC_SIGNAL
61889 + bool "Signal logging"
61890 + default y if GRKERNSEC_CONFIG_AUTO
61891 + help
61892 + If you say Y here, certain important signals will be logged, such as
61893 + SIGSEGV, which will as a result inform you of when a error in a program
61894 + occurred, which in some cases could mean a possible exploit attempt.
61895 + If the sysctl option is enabled, a sysctl option with name
61896 + "signal_logging" is created.
61897 +
61898 +config GRKERNSEC_FORKFAIL
61899 + bool "Fork failure logging"
61900 + help
61901 + If you say Y here, all failed fork() attempts will be logged.
61902 + This could suggest a fork bomb, or someone attempting to overstep
61903 + their process limit. If the sysctl option is enabled, a sysctl option
61904 + with name "forkfail_logging" is created.
61905 +
61906 +config GRKERNSEC_TIME
61907 + bool "Time change logging"
61908 + default y if GRKERNSEC_CONFIG_AUTO
61909 + help
61910 + If you say Y here, any changes of the system clock will be logged.
61911 + If the sysctl option is enabled, a sysctl option with name
61912 + "timechange_logging" is created.
61913 +
61914 +config GRKERNSEC_PROC_IPADDR
61915 + bool "/proc/<pid>/ipaddr support"
61916 + default y if GRKERNSEC_CONFIG_AUTO
61917 + help
61918 + If you say Y here, a new entry will be added to each /proc/<pid>
61919 + directory that contains the IP address of the person using the task.
61920 + The IP is carried across local TCP and AF_UNIX stream sockets.
61921 + This information can be useful for IDS/IPSes to perform remote response
61922 + to a local attack. The entry is readable by only the owner of the
61923 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
61924 + the RBAC system), and thus does not create privacy concerns.
61925 +
61926 +config GRKERNSEC_RWXMAP_LOG
61927 + bool 'Denied RWX mmap/mprotect logging'
61928 + default y if GRKERNSEC_CONFIG_AUTO
61929 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
61930 + help
61931 + If you say Y here, calls to mmap() and mprotect() with explicit
61932 + usage of PROT_WRITE and PROT_EXEC together will be logged when
61933 + denied by the PAX_MPROTECT feature. This feature will also
61934 + log other problematic scenarios that can occur when PAX_MPROTECT
61935 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
61936 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
61937 + is created.
61938 +
61939 +endmenu
61940 +
61941 +menu "Executable Protections"
61942 +depends on GRKERNSEC
61943 +
61944 +config GRKERNSEC_DMESG
61945 + bool "Dmesg(8) restriction"
61946 + default y if GRKERNSEC_CONFIG_AUTO
61947 + help
61948 + If you say Y here, non-root users will not be able to use dmesg(8)
61949 + to view the contents of the kernel's circular log buffer.
61950 + The kernel's log buffer often contains kernel addresses and other
61951 + identifying information useful to an attacker in fingerprinting a
61952 + system for a targeted exploit.
61953 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
61954 + created.
61955 +
61956 +config GRKERNSEC_HARDEN_PTRACE
61957 + bool "Deter ptrace-based process snooping"
61958 + default y if GRKERNSEC_CONFIG_AUTO
61959 + help
61960 + If you say Y here, TTY sniffers and other malicious monitoring
61961 + programs implemented through ptrace will be defeated. If you
61962 + have been using the RBAC system, this option has already been
61963 + enabled for several years for all users, with the ability to make
61964 + fine-grained exceptions.
61965 +
61966 + This option only affects the ability of non-root users to ptrace
61967 + processes that are not a descendent of the ptracing process.
61968 + This means that strace ./binary and gdb ./binary will still work,
61969 + but attaching to arbitrary processes will not. If the sysctl
61970 + option is enabled, a sysctl option with name "harden_ptrace" is
61971 + created.
61972 +
61973 +config GRKERNSEC_PTRACE_READEXEC
61974 + bool "Require read access to ptrace sensitive binaries"
61975 + default y if GRKERNSEC_CONFIG_AUTO
61976 + help
61977 + If you say Y here, unprivileged users will not be able to ptrace unreadable
61978 + binaries. This option is useful in environments that
61979 + remove the read bits (e.g. file mode 4711) from suid binaries to
61980 + prevent infoleaking of their contents. This option adds
61981 + consistency to the use of that file mode, as the binary could normally
61982 + be read out when run without privileges while ptracing.
61983 +
61984 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
61985 + is created.
61986 +
61987 +config GRKERNSEC_SETXID
61988 + bool "Enforce consistent multithreaded privileges"
61989 + default y if GRKERNSEC_CONFIG_AUTO
61990 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
61991 + help
61992 + If you say Y here, a change from a root uid to a non-root uid
61993 + in a multithreaded application will cause the resulting uids,
61994 + gids, supplementary groups, and capabilities in that thread
61995 + to be propagated to the other threads of the process. In most
61996 + cases this is unnecessary, as glibc will emulate this behavior
61997 + on behalf of the application. Other libcs do not act in the
61998 + same way, allowing the other threads of the process to continue
61999 + running with root privileges. If the sysctl option is enabled,
62000 + a sysctl option with name "consistent_setxid" is created.
62001 +
62002 +config GRKERNSEC_TPE
62003 + bool "Trusted Path Execution (TPE)"
62004 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62005 + help
62006 + If you say Y here, you will be able to choose a gid to add to the
62007 + supplementary groups of users you want to mark as "untrusted."
62008 + These users will not be able to execute any files that are not in
62009 + root-owned directories writable only by root. If the sysctl option
62010 + is enabled, a sysctl option with name "tpe" is created.
62011 +
62012 +config GRKERNSEC_TPE_ALL
62013 + bool "Partially restrict all non-root users"
62014 + depends on GRKERNSEC_TPE
62015 + help
62016 + If you say Y here, all non-root users will be covered under
62017 + a weaker TPE restriction. This is separate from, and in addition to,
62018 + the main TPE options that you have selected elsewhere. Thus, if a
62019 + "trusted" GID is chosen, this restriction applies to even that GID.
62020 + Under this restriction, all non-root users will only be allowed to
62021 + execute files in directories they own that are not group or
62022 + world-writable, or in directories owned by root and writable only by
62023 + root. If the sysctl option is enabled, a sysctl option with name
62024 + "tpe_restrict_all" is created.
62025 +
62026 +config GRKERNSEC_TPE_INVERT
62027 + bool "Invert GID option"
62028 + depends on GRKERNSEC_TPE
62029 + help
62030 + If you say Y here, the group you specify in the TPE configuration will
62031 + decide what group TPE restrictions will be *disabled* for. This
62032 + option is useful if you want TPE restrictions to be applied to most
62033 + users on the system. If the sysctl option is enabled, a sysctl option
62034 + with name "tpe_invert" is created. Unlike other sysctl options, this
62035 + entry will default to on for backward-compatibility.
62036 +
62037 +config GRKERNSEC_TPE_GID
62038 + int
62039 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
62040 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
62041 +
62042 +config GRKERNSEC_TPE_UNTRUSTED_GID
62043 + int "GID for TPE-untrusted users"
62044 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
62045 + default 1005
62046 + help
62047 + Setting this GID determines what group TPE restrictions will be
62048 + *enabled* for. If the sysctl option is enabled, a sysctl option
62049 + with name "tpe_gid" is created.
62050 +
62051 +config GRKERNSEC_TPE_TRUSTED_GID
62052 + int "GID for TPE-trusted users"
62053 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
62054 + default 1005
62055 + help
62056 + Setting this GID determines what group TPE restrictions will be
62057 + *disabled* for. If the sysctl option is enabled, a sysctl option
62058 + with name "tpe_gid" is created.
62059 +
62060 +endmenu
62061 +menu "Network Protections"
62062 +depends on GRKERNSEC
62063 +
62064 +config GRKERNSEC_RANDNET
62065 + bool "Larger entropy pools"
62066 + default y if GRKERNSEC_CONFIG_AUTO
62067 + help
62068 + If you say Y here, the entropy pools used for many features of Linux
62069 + and grsecurity will be doubled in size. Since several grsecurity
62070 + features use additional randomness, it is recommended that you say Y
62071 + here. Saying Y here has a similar effect as modifying
62072 + /proc/sys/kernel/random/poolsize.
62073 +
62074 +config GRKERNSEC_BLACKHOLE
62075 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
62076 + default y if GRKERNSEC_CONFIG_AUTO
62077 + depends on NET
62078 + help
62079 + If you say Y here, neither TCP resets nor ICMP
62080 + destination-unreachable packets will be sent in response to packets
62081 + sent to ports for which no associated listening process exists.
62082 + This feature supports both IPV4 and IPV6 and exempts the
62083 + loopback interface from blackholing. Enabling this feature
62084 + makes a host more resilient to DoS attacks and reduces network
62085 + visibility against scanners.
62086 +
62087 + The blackhole feature as-implemented is equivalent to the FreeBSD
62088 + blackhole feature, as it prevents RST responses to all packets, not
62089 + just SYNs. Under most application behavior this causes no
62090 + problems, but applications (like haproxy) may not close certain
62091 + connections in a way that cleanly terminates them on the remote
62092 + end, leaving the remote host in LAST_ACK state. Because of this
62093 + side-effect and to prevent intentional LAST_ACK DoSes, this
62094 + feature also adds automatic mitigation against such attacks.
62095 + The mitigation drastically reduces the amount of time a socket
62096 + can spend in LAST_ACK state. If you're using haproxy and not
62097 + all servers it connects to have this option enabled, consider
62098 + disabling this feature on the haproxy host.
62099 +
62100 + If the sysctl option is enabled, two sysctl options with names
62101 + "ip_blackhole" and "lastack_retries" will be created.
62102 + While "ip_blackhole" takes the standard zero/non-zero on/off
62103 + toggle, "lastack_retries" uses the same kinds of values as
62104 + "tcp_retries1" and "tcp_retries2". The default value of 4
62105 + prevents a socket from lasting more than 45 seconds in LAST_ACK
62106 + state.
62107 +
62108 +config GRKERNSEC_NO_SIMULT_CONNECT
62109 + bool "Disable TCP Simultaneous Connect"
62110 + default y if GRKERNSEC_CONFIG_AUTO
62111 + depends on NET
62112 + help
62113 + If you say Y here, a feature by Willy Tarreau will be enabled that
62114 + removes a weakness in Linux's strict implementation of TCP that
62115 + allows two clients to connect to each other without either entering
62116 + a listening state. The weakness allows an attacker to easily prevent
62117 + a client from connecting to a known server provided the source port
62118 + for the connection is guessed correctly.
62119 +
62120 + As the weakness could be used to prevent an antivirus or IPS from
62121 + fetching updates, or prevent an SSL gateway from fetching a CRL,
62122 + it should be eliminated by enabling this option. Though Linux is
62123 + one of few operating systems supporting simultaneous connect, it
62124 + has no legitimate use in practice and is rarely supported by firewalls.
62125 +
62126 +config GRKERNSEC_SOCKET
62127 + bool "Socket restrictions"
62128 + depends on NET
62129 + help
62130 + If you say Y here, you will be able to choose from several options.
62131 + If you assign a GID on your system and add it to the supplementary
62132 + groups of users you want to restrict socket access to, this patch
62133 + will perform up to three things, based on the option(s) you choose.
62134 +
62135 +config GRKERNSEC_SOCKET_ALL
62136 + bool "Deny any sockets to group"
62137 + depends on GRKERNSEC_SOCKET
62138 + help
62139 + If you say Y here, you will be able to choose a GID of whose users will
62140 + be unable to connect to other hosts from your machine or run server
62141 + applications from your machine. If the sysctl option is enabled, a
62142 + sysctl option with name "socket_all" is created.
62143 +
62144 +config GRKERNSEC_SOCKET_ALL_GID
62145 + int "GID to deny all sockets for"
62146 + depends on GRKERNSEC_SOCKET_ALL
62147 + default 1004
62148 + help
62149 + Here you can choose the GID to disable socket access for. Remember to
62150 + add the users you want socket access disabled for to the GID
62151 + specified here. If the sysctl option is enabled, a sysctl option
62152 + with name "socket_all_gid" is created.
62153 +
62154 +config GRKERNSEC_SOCKET_CLIENT
62155 + bool "Deny client sockets to group"
62156 + depends on GRKERNSEC_SOCKET
62157 + help
62158 + If you say Y here, you will be able to choose a GID of whose users will
62159 + be unable to connect to other hosts from your machine, but will be
62160 + able to run servers. If this option is enabled, all users in the group
62161 + you specify will have to use passive mode when initiating ftp transfers
62162 + from the shell on your machine. If the sysctl option is enabled, a
62163 + sysctl option with name "socket_client" is created.
62164 +
62165 +config GRKERNSEC_SOCKET_CLIENT_GID
62166 + int "GID to deny client sockets for"
62167 + depends on GRKERNSEC_SOCKET_CLIENT
62168 + default 1003
62169 + help
62170 + Here you can choose the GID to disable client socket access for.
62171 + Remember to add the users you want client socket access disabled for to
62172 + the GID specified here. If the sysctl option is enabled, a sysctl
62173 + option with name "socket_client_gid" is created.
62174 +
62175 +config GRKERNSEC_SOCKET_SERVER
62176 + bool "Deny server sockets to group"
62177 + depends on GRKERNSEC_SOCKET
62178 + help
62179 + If you say Y here, you will be able to choose a GID of whose users will
62180 + be unable to run server applications from your machine. If the sysctl
62181 + option is enabled, a sysctl option with name "socket_server" is created.
62182 +
62183 +config GRKERNSEC_SOCKET_SERVER_GID
62184 + int "GID to deny server sockets for"
62185 + depends on GRKERNSEC_SOCKET_SERVER
62186 + default 1002
62187 + help
62188 + Here you can choose the GID to disable server socket access for.
62189 + Remember to add the users you want server socket access disabled for to
62190 + the GID specified here. If the sysctl option is enabled, a sysctl
62191 + option with name "socket_server_gid" is created.
62192 +
62193 +endmenu
62194 +
62195 +menu "Physical Protections"
62196 +depends on GRKERNSEC
62197 +
62198 +config GRKERNSEC_DENYUSB
62199 + bool "Deny new USB connections after toggle"
62200 + default y if GRKERNSEC_CONFIG_AUTO
62201 + depends on SYSCTL && USB_SUPPORT
62202 + help
62203 + If you say Y here, a new sysctl option with name "deny_new_usb"
62204 + will be created. Setting its value to 1 will prevent any new
62205 + USB devices from being recognized by the OS. Any attempted USB
62206 + device insertion will be logged. This option is intended to be
62207 + used against custom USB devices designed to exploit vulnerabilities
62208 + in various USB device drivers.
62209 +
62210 + For greatest effectiveness, this sysctl should be set after any
62211 + relevant init scripts. This option is safe to enable in distros
62212 + as each user can choose whether or not to toggle the sysctl.
62213 +
62214 +config GRKERNSEC_DENYUSB_FORCE
62215 + bool "Reject all USB devices not connected at boot"
62216 + select USB
62217 + depends on GRKERNSEC_DENYUSB
62218 + help
62219 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
62220 + that doesn't involve a sysctl entry. This option should only be
62221 + enabled if you're sure you want to deny all new USB connections
62222 + at runtime and don't want to modify init scripts. This should not
62223 + be enabled by distros. It forces the core USB code to be built
62224 + into the kernel image so that all devices connected at boot time
62225 + can be recognized and new USB device connections can be prevented
62226 + prior to init running.
62227 +
62228 +endmenu
62229 +
62230 +menu "Sysctl Support"
62231 +depends on GRKERNSEC && SYSCTL
62232 +
62233 +config GRKERNSEC_SYSCTL
62234 + bool "Sysctl support"
62235 + default y if GRKERNSEC_CONFIG_AUTO
62236 + help
62237 + If you say Y here, you will be able to change the options that
62238 + grsecurity runs with at bootup, without having to recompile your
62239 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
62240 + to enable (1) or disable (0) various features. All the sysctl entries
62241 + are mutable until the "grsec_lock" entry is set to a non-zero value.
62242 + All features enabled in the kernel configuration are disabled at boot
62243 + if you do not say Y to the "Turn on features by default" option.
62244 + All options should be set at startup, and the grsec_lock entry should
62245 + be set to a non-zero value after all the options are set.
62246 + *THIS IS EXTREMELY IMPORTANT*
62247 +
62248 +config GRKERNSEC_SYSCTL_DISTRO
62249 + bool "Extra sysctl support for distro makers (READ HELP)"
62250 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
62251 + help
62252 + If you say Y here, additional sysctl options will be created
62253 + for features that affect processes running as root. Therefore,
62254 + it is critical when using this option that the grsec_lock entry be
62255 + enabled after boot. Only distros with prebuilt kernel packages
62256 + with this option enabled that can ensure grsec_lock is enabled
62257 + after boot should use this option.
62258 + *Failure to set grsec_lock after boot makes all grsec features
62259 + this option covers useless*
62260 +
62261 + Currently this option creates the following sysctl entries:
62262 + "Disable Privileged I/O": "disable_priv_io"
62263 +
62264 +config GRKERNSEC_SYSCTL_ON
62265 + bool "Turn on features by default"
62266 + default y if GRKERNSEC_CONFIG_AUTO
62267 + depends on GRKERNSEC_SYSCTL
62268 + help
62269 + If you say Y here, instead of having all features enabled in the
62270 + kernel configuration disabled at boot time, the features will be
62271 + enabled at boot time. It is recommended you say Y here unless
62272 + there is some reason you would want all sysctl-tunable features to
62273 + be disabled by default. As mentioned elsewhere, it is important
62274 + to enable the grsec_lock entry once you have finished modifying
62275 + the sysctl entries.
62276 +
62277 +endmenu
62278 +menu "Logging Options"
62279 +depends on GRKERNSEC
62280 +
62281 +config GRKERNSEC_FLOODTIME
62282 + int "Seconds in between log messages (minimum)"
62283 + default 10
62284 + help
62285 + This option allows you to enforce the number of seconds between
62286 + grsecurity log messages. The default should be suitable for most
62287 + people, however, if you choose to change it, choose a value small enough
62288 + to allow informative logs to be produced, but large enough to
62289 + prevent flooding.
62290 +
62291 +config GRKERNSEC_FLOODBURST
62292 + int "Number of messages in a burst (maximum)"
62293 + default 6
62294 + help
62295 + This option allows you to choose the maximum number of messages allowed
62296 + within the flood time interval you chose in a separate option. The
62297 + default should be suitable for most people, however if you find that
62298 + many of your logs are being interpreted as flooding, you may want to
62299 + raise this value.
62300 +
62301 +endmenu
62302 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
62303 new file mode 100644
62304 index 0000000..b0b77d5
62305 --- /dev/null
62306 +++ b/grsecurity/Makefile
62307 @@ -0,0 +1,43 @@
62308 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
62309 +# during 2001-2009 it has been completely redesigned by Brad Spengler
62310 +# into an RBAC system
62311 +#
62312 +# All code in this directory and various hooks inserted throughout the kernel
62313 +# are copyright Brad Spengler - Open Source Security, Inc., and released
62314 +# under the GPL v2 or higher
62315 +
62316 +KBUILD_CFLAGS += -Werror
62317 +
62318 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
62319 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
62320 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
62321 + grsec_usb.o
62322 +
62323 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
62324 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
62325 + gracl_learn.o grsec_log.o
62326 +ifdef CONFIG_COMPAT
62327 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
62328 +endif
62329 +
62330 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
62331 +
62332 +ifdef CONFIG_NET
62333 +obj-y += grsec_sock.o
62334 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
62335 +endif
62336 +
62337 +ifndef CONFIG_GRKERNSEC
62338 +obj-y += grsec_disabled.o
62339 +endif
62340 +
62341 +ifdef CONFIG_GRKERNSEC_HIDESYM
62342 +extra-y := grsec_hidesym.o
62343 +$(obj)/grsec_hidesym.o:
62344 + @-chmod -f 500 /boot
62345 + @-chmod -f 500 /lib/modules
62346 + @-chmod -f 500 /lib64/modules
62347 + @-chmod -f 500 /lib32/modules
62348 + @-chmod -f 700 .
62349 + @echo ' grsec: protected kernel image paths'
62350 +endif
62351 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
62352 new file mode 100644
62353 index 0000000..c0793fd
62354 --- /dev/null
62355 +++ b/grsecurity/gracl.c
62356 @@ -0,0 +1,4178 @@
62357 +#include <linux/kernel.h>
62358 +#include <linux/module.h>
62359 +#include <linux/sched.h>
62360 +#include <linux/mm.h>
62361 +#include <linux/file.h>
62362 +#include <linux/fs.h>
62363 +#include <linux/namei.h>
62364 +#include <linux/mount.h>
62365 +#include <linux/tty.h>
62366 +#include <linux/proc_fs.h>
62367 +#include <linux/lglock.h>
62368 +#include <linux/slab.h>
62369 +#include <linux/vmalloc.h>
62370 +#include <linux/types.h>
62371 +#include <linux/sysctl.h>
62372 +#include <linux/netdevice.h>
62373 +#include <linux/ptrace.h>
62374 +#include <linux/gracl.h>
62375 +#include <linux/gralloc.h>
62376 +#include <linux/security.h>
62377 +#include <linux/grinternal.h>
62378 +#include <linux/pid_namespace.h>
62379 +#include <linux/stop_machine.h>
62380 +#include <linux/fdtable.h>
62381 +#include <linux/percpu.h>
62382 +#include <linux/lglock.h>
62383 +#include <linux/hugetlb.h>
62384 +#include <linux/posix-timers.h>
62385 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62386 +#include <linux/magic.h>
62387 +#include <linux/pagemap.h>
62388 +#include "../fs/btrfs/async-thread.h"
62389 +#include "../fs/btrfs/ctree.h"
62390 +#include "../fs/btrfs/btrfs_inode.h"
62391 +#endif
62392 +#include "../fs/mount.h"
62393 +
62394 +#include <asm/uaccess.h>
62395 +#include <asm/errno.h>
62396 +#include <asm/mman.h>
62397 +
62398 +extern struct lglock vfsmount_lock;
62399 +
62400 +static struct acl_role_db acl_role_set;
62401 +static struct name_db name_set;
62402 +static struct inodev_db inodev_set;
62403 +
62404 +/* for keeping track of userspace pointers used for subjects, so we
62405 + can share references in the kernel as well
62406 +*/
62407 +
62408 +static struct path real_root;
62409 +
62410 +static struct acl_subj_map_db subj_map_set;
62411 +
62412 +static struct acl_role_label *default_role;
62413 +
62414 +static struct acl_role_label *role_list;
62415 +
62416 +static u16 acl_sp_role_value;
62417 +
62418 +extern char *gr_shared_page[4];
62419 +static DEFINE_MUTEX(gr_dev_mutex);
62420 +DEFINE_RWLOCK(gr_inode_lock);
62421 +
62422 +struct gr_arg *gr_usermode;
62423 +
62424 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
62425 +
62426 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
62427 +extern void gr_clear_learn_entries(void);
62428 +
62429 +unsigned char *gr_system_salt;
62430 +unsigned char *gr_system_sum;
62431 +
62432 +static struct sprole_pw **acl_special_roles = NULL;
62433 +static __u16 num_sprole_pws = 0;
62434 +
62435 +static struct acl_role_label *kernel_role = NULL;
62436 +
62437 +static unsigned int gr_auth_attempts = 0;
62438 +static unsigned long gr_auth_expires = 0UL;
62439 +
62440 +#ifdef CONFIG_NET
62441 +extern struct vfsmount *sock_mnt;
62442 +#endif
62443 +
62444 +extern struct vfsmount *pipe_mnt;
62445 +extern struct vfsmount *shm_mnt;
62446 +
62447 +#ifdef CONFIG_HUGETLBFS
62448 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
62449 +#endif
62450 +
62451 +static struct acl_object_label *fakefs_obj_rw;
62452 +static struct acl_object_label *fakefs_obj_rwx;
62453 +
62454 +extern int gr_init_uidset(void);
62455 +extern void gr_free_uidset(void);
62456 +extern void gr_remove_uid(uid_t uid);
62457 +extern int gr_find_uid(uid_t uid);
62458 +
62459 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
62460 +{
62461 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
62462 + return -EFAULT;
62463 +
62464 + return 0;
62465 +}
62466 +
62467 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
62468 +{
62469 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
62470 + return -EFAULT;
62471 +
62472 + return 0;
62473 +}
62474 +
62475 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
62476 +{
62477 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
62478 + return -EFAULT;
62479 +
62480 + return 0;
62481 +}
62482 +
62483 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
62484 +{
62485 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
62486 + return -EFAULT;
62487 +
62488 + return 0;
62489 +}
62490 +
62491 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
62492 +{
62493 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
62494 + return -EFAULT;
62495 +
62496 + return 0;
62497 +}
62498 +
62499 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
62500 +{
62501 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
62502 + return -EFAULT;
62503 +
62504 + return 0;
62505 +}
62506 +
62507 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
62508 +{
62509 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
62510 + return -EFAULT;
62511 +
62512 + return 0;
62513 +}
62514 +
62515 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
62516 +{
62517 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
62518 + return -EFAULT;
62519 +
62520 + return 0;
62521 +}
62522 +
62523 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
62524 +{
62525 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
62526 + return -EFAULT;
62527 +
62528 + return 0;
62529 +}
62530 +
62531 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
62532 +{
62533 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
62534 + return -EFAULT;
62535 +
62536 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
62537 + return -EINVAL;
62538 +
62539 + return 0;
62540 +}
62541 +
62542 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
62543 +{
62544 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
62545 + return -EFAULT;
62546 +
62547 + return 0;
62548 +}
62549 +
62550 +static size_t get_gr_arg_wrapper_size_normal(void)
62551 +{
62552 + return sizeof(struct gr_arg_wrapper);
62553 +}
62554 +
62555 +#ifdef CONFIG_COMPAT
62556 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
62557 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
62558 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
62559 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
62560 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
62561 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
62562 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
62563 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
62564 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
62565 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
62566 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
62567 +extern size_t get_gr_arg_wrapper_size_compat(void);
62568 +
62569 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
62570 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
62571 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
62572 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
62573 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
62574 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
62575 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
62576 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
62577 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
62578 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
62579 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
62580 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
62581 +
62582 +#else
62583 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
62584 +#define copy_gr_arg copy_gr_arg_normal
62585 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
62586 +#define copy_acl_object_label copy_acl_object_label_normal
62587 +#define copy_acl_subject_label copy_acl_subject_label_normal
62588 +#define copy_acl_role_label copy_acl_role_label_normal
62589 +#define copy_acl_ip_label copy_acl_ip_label_normal
62590 +#define copy_pointer_from_array copy_pointer_from_array_normal
62591 +#define copy_sprole_pw copy_sprole_pw_normal
62592 +#define copy_role_transition copy_role_transition_normal
62593 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
62594 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
62595 +#endif
62596 +
62597 +__inline__ int
62598 +gr_acl_is_enabled(void)
62599 +{
62600 + return (gr_status & GR_READY);
62601 +}
62602 +
62603 +static inline dev_t __get_dev(const struct dentry *dentry)
62604 +{
62605 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
62606 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
62607 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
62608 + else
62609 +#endif
62610 + return dentry->d_sb->s_dev;
62611 +}
62612 +
62613 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
62614 +{
62615 + return __get_dev(dentry);
62616 +}
62617 +
62618 +static char gr_task_roletype_to_char(struct task_struct *task)
62619 +{
62620 + switch (task->role->roletype &
62621 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
62622 + GR_ROLE_SPECIAL)) {
62623 + case GR_ROLE_DEFAULT:
62624 + return 'D';
62625 + case GR_ROLE_USER:
62626 + return 'U';
62627 + case GR_ROLE_GROUP:
62628 + return 'G';
62629 + case GR_ROLE_SPECIAL:
62630 + return 'S';
62631 + }
62632 +
62633 + return 'X';
62634 +}
62635 +
62636 +char gr_roletype_to_char(void)
62637 +{
62638 + return gr_task_roletype_to_char(current);
62639 +}
62640 +
62641 +__inline__ int
62642 +gr_acl_tpe_check(void)
62643 +{
62644 + if (unlikely(!(gr_status & GR_READY)))
62645 + return 0;
62646 + if (current->role->roletype & GR_ROLE_TPE)
62647 + return 1;
62648 + else
62649 + return 0;
62650 +}
62651 +
62652 +int
62653 +gr_handle_rawio(const struct inode *inode)
62654 +{
62655 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
62656 + if (inode && S_ISBLK(inode->i_mode) &&
62657 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
62658 + !capable(CAP_SYS_RAWIO))
62659 + return 1;
62660 +#endif
62661 + return 0;
62662 +}
62663 +
62664 +static int
62665 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
62666 +{
62667 + if (likely(lena != lenb))
62668 + return 0;
62669 +
62670 + return !memcmp(a, b, lena);
62671 +}
62672 +
62673 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
62674 +{
62675 + *buflen -= namelen;
62676 + if (*buflen < 0)
62677 + return -ENAMETOOLONG;
62678 + *buffer -= namelen;
62679 + memcpy(*buffer, str, namelen);
62680 + return 0;
62681 +}
62682 +
62683 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
62684 +{
62685 + return prepend(buffer, buflen, name->name, name->len);
62686 +}
62687 +
62688 +static int prepend_path(const struct path *path, struct path *root,
62689 + char **buffer, int *buflen)
62690 +{
62691 + struct dentry *dentry = path->dentry;
62692 + struct vfsmount *vfsmnt = path->mnt;
62693 + struct mount *mnt = real_mount(vfsmnt);
62694 + bool slash = false;
62695 + int error = 0;
62696 +
62697 + while (dentry != root->dentry || vfsmnt != root->mnt) {
62698 + struct dentry * parent;
62699 +
62700 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
62701 + /* Global root? */
62702 + if (!mnt_has_parent(mnt)) {
62703 + goto out;
62704 + }
62705 + dentry = mnt->mnt_mountpoint;
62706 + mnt = mnt->mnt_parent;
62707 + vfsmnt = &mnt->mnt;
62708 + continue;
62709 + }
62710 + parent = dentry->d_parent;
62711 + prefetch(parent);
62712 + spin_lock(&dentry->d_lock);
62713 + error = prepend_name(buffer, buflen, &dentry->d_name);
62714 + spin_unlock(&dentry->d_lock);
62715 + if (!error)
62716 + error = prepend(buffer, buflen, "/", 1);
62717 + if (error)
62718 + break;
62719 +
62720 + slash = true;
62721 + dentry = parent;
62722 + }
62723 +
62724 +out:
62725 + if (!error && !slash)
62726 + error = prepend(buffer, buflen, "/", 1);
62727 +
62728 + return error;
62729 +}
62730 +
62731 +/* this must be called with vfsmount_lock and rename_lock held */
62732 +
62733 +static char *__our_d_path(const struct path *path, struct path *root,
62734 + char *buf, int buflen)
62735 +{
62736 + char *res = buf + buflen;
62737 + int error;
62738 +
62739 + prepend(&res, &buflen, "\0", 1);
62740 + error = prepend_path(path, root, &res, &buflen);
62741 + if (error)
62742 + return ERR_PTR(error);
62743 +
62744 + return res;
62745 +}
62746 +
62747 +static char *
62748 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
62749 +{
62750 + char *retval;
62751 +
62752 + retval = __our_d_path(path, root, buf, buflen);
62753 + if (unlikely(IS_ERR(retval)))
62754 + retval = strcpy(buf, "<path too long>");
62755 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
62756 + retval[1] = '\0';
62757 +
62758 + return retval;
62759 +}
62760 +
62761 +static char *
62762 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62763 + char *buf, int buflen)
62764 +{
62765 + struct path path;
62766 + char *res;
62767 +
62768 + path.dentry = (struct dentry *)dentry;
62769 + path.mnt = (struct vfsmount *)vfsmnt;
62770 +
62771 + /* we can use real_root.dentry, real_root.mnt, because this is only called
62772 + by the RBAC system */
62773 + res = gen_full_path(&path, &real_root, buf, buflen);
62774 +
62775 + return res;
62776 +}
62777 +
62778 +static char *
62779 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
62780 + char *buf, int buflen)
62781 +{
62782 + char *res;
62783 + struct path path;
62784 + struct path root;
62785 + struct task_struct *reaper = init_pid_ns.child_reaper;
62786 +
62787 + path.dentry = (struct dentry *)dentry;
62788 + path.mnt = (struct vfsmount *)vfsmnt;
62789 +
62790 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
62791 + get_fs_root(reaper->fs, &root);
62792 +
62793 + br_read_lock(&vfsmount_lock);
62794 + write_seqlock(&rename_lock);
62795 + res = gen_full_path(&path, &root, buf, buflen);
62796 + write_sequnlock(&rename_lock);
62797 + br_read_unlock(&vfsmount_lock);
62798 +
62799 + path_put(&root);
62800 + return res;
62801 +}
62802 +
62803 +static char *
62804 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62805 +{
62806 + char *ret;
62807 + br_read_lock(&vfsmount_lock);
62808 + write_seqlock(&rename_lock);
62809 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62810 + PAGE_SIZE);
62811 + write_sequnlock(&rename_lock);
62812 + br_read_unlock(&vfsmount_lock);
62813 + return ret;
62814 +}
62815 +
62816 +static char *
62817 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
62818 +{
62819 + char *ret;
62820 + char *buf;
62821 + int buflen;
62822 +
62823 + br_read_lock(&vfsmount_lock);
62824 + write_seqlock(&rename_lock);
62825 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
62826 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
62827 + buflen = (int)(ret - buf);
62828 + if (buflen >= 5)
62829 + prepend(&ret, &buflen, "/proc", 5);
62830 + else
62831 + ret = strcpy(buf, "<path too long>");
62832 + write_sequnlock(&rename_lock);
62833 + br_read_unlock(&vfsmount_lock);
62834 + return ret;
62835 +}
62836 +
62837 +char *
62838 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
62839 +{
62840 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
62841 + PAGE_SIZE);
62842 +}
62843 +
62844 +char *
62845 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
62846 +{
62847 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62848 + PAGE_SIZE);
62849 +}
62850 +
62851 +char *
62852 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
62853 +{
62854 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
62855 + PAGE_SIZE);
62856 +}
62857 +
62858 +char *
62859 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
62860 +{
62861 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
62862 + PAGE_SIZE);
62863 +}
62864 +
62865 +char *
62866 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
62867 +{
62868 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
62869 + PAGE_SIZE);
62870 +}
62871 +
62872 +__inline__ __u32
62873 +to_gr_audit(const __u32 reqmode)
62874 +{
62875 + /* masks off auditable permission flags, then shifts them to create
62876 + auditing flags, and adds the special case of append auditing if
62877 + we're requesting write */
62878 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
62879 +}
62880 +
62881 +struct acl_subject_label *
62882 +lookup_subject_map(const struct acl_subject_label *userp)
62883 +{
62884 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
62885 + struct subject_map *match;
62886 +
62887 + match = subj_map_set.s_hash[index];
62888 +
62889 + while (match && match->user != userp)
62890 + match = match->next;
62891 +
62892 + if (match != NULL)
62893 + return match->kernel;
62894 + else
62895 + return NULL;
62896 +}
62897 +
62898 +static void
62899 +insert_subj_map_entry(struct subject_map *subjmap)
62900 +{
62901 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
62902 + struct subject_map **curr;
62903 +
62904 + subjmap->prev = NULL;
62905 +
62906 + curr = &subj_map_set.s_hash[index];
62907 + if (*curr != NULL)
62908 + (*curr)->prev = subjmap;
62909 +
62910 + subjmap->next = *curr;
62911 + *curr = subjmap;
62912 +
62913 + return;
62914 +}
62915 +
62916 +static struct acl_role_label *
62917 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
62918 + const gid_t gid)
62919 +{
62920 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
62921 + struct acl_role_label *match;
62922 + struct role_allowed_ip *ipp;
62923 + unsigned int x;
62924 + u32 curr_ip = task->signal->curr_ip;
62925 +
62926 + task->signal->saved_ip = curr_ip;
62927 +
62928 + match = acl_role_set.r_hash[index];
62929 +
62930 + while (match) {
62931 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
62932 + for (x = 0; x < match->domain_child_num; x++) {
62933 + if (match->domain_children[x] == uid)
62934 + goto found;
62935 + }
62936 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
62937 + break;
62938 + match = match->next;
62939 + }
62940 +found:
62941 + if (match == NULL) {
62942 + try_group:
62943 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
62944 + match = acl_role_set.r_hash[index];
62945 +
62946 + while (match) {
62947 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
62948 + for (x = 0; x < match->domain_child_num; x++) {
62949 + if (match->domain_children[x] == gid)
62950 + goto found2;
62951 + }
62952 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
62953 + break;
62954 + match = match->next;
62955 + }
62956 +found2:
62957 + if (match == NULL)
62958 + match = default_role;
62959 + if (match->allowed_ips == NULL)
62960 + return match;
62961 + else {
62962 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62963 + if (likely
62964 + ((ntohl(curr_ip) & ipp->netmask) ==
62965 + (ntohl(ipp->addr) & ipp->netmask)))
62966 + return match;
62967 + }
62968 + match = default_role;
62969 + }
62970 + } else if (match->allowed_ips == NULL) {
62971 + return match;
62972 + } else {
62973 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
62974 + if (likely
62975 + ((ntohl(curr_ip) & ipp->netmask) ==
62976 + (ntohl(ipp->addr) & ipp->netmask)))
62977 + return match;
62978 + }
62979 + goto try_group;
62980 + }
62981 +
62982 + return match;
62983 +}
62984 +
62985 +struct acl_subject_label *
62986 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
62987 + const struct acl_role_label *role)
62988 +{
62989 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
62990 + struct acl_subject_label *match;
62991 +
62992 + match = role->subj_hash[index];
62993 +
62994 + while (match && (match->inode != ino || match->device != dev ||
62995 + (match->mode & GR_DELETED))) {
62996 + match = match->next;
62997 + }
62998 +
62999 + if (match && !(match->mode & GR_DELETED))
63000 + return match;
63001 + else
63002 + return NULL;
63003 +}
63004 +
63005 +struct acl_subject_label *
63006 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
63007 + const struct acl_role_label *role)
63008 +{
63009 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
63010 + struct acl_subject_label *match;
63011 +
63012 + match = role->subj_hash[index];
63013 +
63014 + while (match && (match->inode != ino || match->device != dev ||
63015 + !(match->mode & GR_DELETED))) {
63016 + match = match->next;
63017 + }
63018 +
63019 + if (match && (match->mode & GR_DELETED))
63020 + return match;
63021 + else
63022 + return NULL;
63023 +}
63024 +
63025 +static struct acl_object_label *
63026 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
63027 + const struct acl_subject_label *subj)
63028 +{
63029 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63030 + struct acl_object_label *match;
63031 +
63032 + match = subj->obj_hash[index];
63033 +
63034 + while (match && (match->inode != ino || match->device != dev ||
63035 + (match->mode & GR_DELETED))) {
63036 + match = match->next;
63037 + }
63038 +
63039 + if (match && !(match->mode & GR_DELETED))
63040 + return match;
63041 + else
63042 + return NULL;
63043 +}
63044 +
63045 +static struct acl_object_label *
63046 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
63047 + const struct acl_subject_label *subj)
63048 +{
63049 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
63050 + struct acl_object_label *match;
63051 +
63052 + match = subj->obj_hash[index];
63053 +
63054 + while (match && (match->inode != ino || match->device != dev ||
63055 + !(match->mode & GR_DELETED))) {
63056 + match = match->next;
63057 + }
63058 +
63059 + if (match && (match->mode & GR_DELETED))
63060 + return match;
63061 +
63062 + match = subj->obj_hash[index];
63063 +
63064 + while (match && (match->inode != ino || match->device != dev ||
63065 + (match->mode & GR_DELETED))) {
63066 + match = match->next;
63067 + }
63068 +
63069 + if (match && !(match->mode & GR_DELETED))
63070 + return match;
63071 + else
63072 + return NULL;
63073 +}
63074 +
63075 +static struct name_entry *
63076 +lookup_name_entry(const char *name)
63077 +{
63078 + unsigned int len = strlen(name);
63079 + unsigned int key = full_name_hash(name, len);
63080 + unsigned int index = key % name_set.n_size;
63081 + struct name_entry *match;
63082 +
63083 + match = name_set.n_hash[index];
63084 +
63085 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
63086 + match = match->next;
63087 +
63088 + return match;
63089 +}
63090 +
63091 +static struct name_entry *
63092 +lookup_name_entry_create(const char *name)
63093 +{
63094 + unsigned int len = strlen(name);
63095 + unsigned int key = full_name_hash(name, len);
63096 + unsigned int index = key % name_set.n_size;
63097 + struct name_entry *match;
63098 +
63099 + match = name_set.n_hash[index];
63100 +
63101 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63102 + !match->deleted))
63103 + match = match->next;
63104 +
63105 + if (match && match->deleted)
63106 + return match;
63107 +
63108 + match = name_set.n_hash[index];
63109 +
63110 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
63111 + match->deleted))
63112 + match = match->next;
63113 +
63114 + if (match && !match->deleted)
63115 + return match;
63116 + else
63117 + return NULL;
63118 +}
63119 +
63120 +static struct inodev_entry *
63121 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
63122 +{
63123 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
63124 + struct inodev_entry *match;
63125 +
63126 + match = inodev_set.i_hash[index];
63127 +
63128 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
63129 + match = match->next;
63130 +
63131 + return match;
63132 +}
63133 +
63134 +static void
63135 +insert_inodev_entry(struct inodev_entry *entry)
63136 +{
63137 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
63138 + inodev_set.i_size);
63139 + struct inodev_entry **curr;
63140 +
63141 + entry->prev = NULL;
63142 +
63143 + curr = &inodev_set.i_hash[index];
63144 + if (*curr != NULL)
63145 + (*curr)->prev = entry;
63146 +
63147 + entry->next = *curr;
63148 + *curr = entry;
63149 +
63150 + return;
63151 +}
63152 +
63153 +static void
63154 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
63155 +{
63156 + unsigned int index =
63157 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
63158 + struct acl_role_label **curr;
63159 + struct acl_role_label *tmp, *tmp2;
63160 +
63161 + curr = &acl_role_set.r_hash[index];
63162 +
63163 + /* simple case, slot is empty, just set it to our role */
63164 + if (*curr == NULL) {
63165 + *curr = role;
63166 + } else {
63167 + /* example:
63168 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
63169 + 2 -> 3
63170 + */
63171 + /* first check to see if we can already be reached via this slot */
63172 + tmp = *curr;
63173 + while (tmp && tmp != role)
63174 + tmp = tmp->next;
63175 + if (tmp == role) {
63176 + /* we don't need to add ourselves to this slot's chain */
63177 + return;
63178 + }
63179 + /* we need to add ourselves to this chain, two cases */
63180 + if (role->next == NULL) {
63181 + /* simple case, append the current chain to our role */
63182 + role->next = *curr;
63183 + *curr = role;
63184 + } else {
63185 + /* 1 -> 2 -> 3 -> 4
63186 + 2 -> 3 -> 4
63187 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
63188 + */
63189 + /* trickier case: walk our role's chain until we find
63190 + the role for the start of the current slot's chain */
63191 + tmp = role;
63192 + tmp2 = *curr;
63193 + while (tmp->next && tmp->next != tmp2)
63194 + tmp = tmp->next;
63195 + if (tmp->next == tmp2) {
63196 + /* from example above, we found 3, so just
63197 + replace this slot's chain with ours */
63198 + *curr = role;
63199 + } else {
63200 + /* we didn't find a subset of our role's chain
63201 + in the current slot's chain, so append their
63202 + chain to ours, and set us as the first role in
63203 + the slot's chain
63204 +
63205 + we could fold this case with the case above,
63206 + but making it explicit for clarity
63207 + */
63208 + tmp->next = tmp2;
63209 + *curr = role;
63210 + }
63211 + }
63212 + }
63213 +
63214 + return;
63215 +}
63216 +
63217 +static void
63218 +insert_acl_role_label(struct acl_role_label *role)
63219 +{
63220 + int i;
63221 +
63222 + if (role_list == NULL) {
63223 + role_list = role;
63224 + role->prev = NULL;
63225 + } else {
63226 + role->prev = role_list;
63227 + role_list = role;
63228 + }
63229 +
63230 + /* used for hash chains */
63231 + role->next = NULL;
63232 +
63233 + if (role->roletype & GR_ROLE_DOMAIN) {
63234 + for (i = 0; i < role->domain_child_num; i++)
63235 + __insert_acl_role_label(role, role->domain_children[i]);
63236 + } else
63237 + __insert_acl_role_label(role, role->uidgid);
63238 +}
63239 +
63240 +static int
63241 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
63242 +{
63243 + struct name_entry **curr, *nentry;
63244 + struct inodev_entry *ientry;
63245 + unsigned int len = strlen(name);
63246 + unsigned int key = full_name_hash(name, len);
63247 + unsigned int index = key % name_set.n_size;
63248 +
63249 + curr = &name_set.n_hash[index];
63250 +
63251 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
63252 + curr = &((*curr)->next);
63253 +
63254 + if (*curr != NULL)
63255 + return 1;
63256 +
63257 + nentry = acl_alloc(sizeof (struct name_entry));
63258 + if (nentry == NULL)
63259 + return 0;
63260 + ientry = acl_alloc(sizeof (struct inodev_entry));
63261 + if (ientry == NULL)
63262 + return 0;
63263 + ientry->nentry = nentry;
63264 +
63265 + nentry->key = key;
63266 + nentry->name = name;
63267 + nentry->inode = inode;
63268 + nentry->device = device;
63269 + nentry->len = len;
63270 + nentry->deleted = deleted;
63271 +
63272 + nentry->prev = NULL;
63273 + curr = &name_set.n_hash[index];
63274 + if (*curr != NULL)
63275 + (*curr)->prev = nentry;
63276 + nentry->next = *curr;
63277 + *curr = nentry;
63278 +
63279 + /* insert us into the table searchable by inode/dev */
63280 + insert_inodev_entry(ientry);
63281 +
63282 + return 1;
63283 +}
63284 +
63285 +static void
63286 +insert_acl_obj_label(struct acl_object_label *obj,
63287 + struct acl_subject_label *subj)
63288 +{
63289 + unsigned int index =
63290 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
63291 + struct acl_object_label **curr;
63292 +
63293 +
63294 + obj->prev = NULL;
63295 +
63296 + curr = &subj->obj_hash[index];
63297 + if (*curr != NULL)
63298 + (*curr)->prev = obj;
63299 +
63300 + obj->next = *curr;
63301 + *curr = obj;
63302 +
63303 + return;
63304 +}
63305 +
63306 +static void
63307 +insert_acl_subj_label(struct acl_subject_label *obj,
63308 + struct acl_role_label *role)
63309 +{
63310 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
63311 + struct acl_subject_label **curr;
63312 +
63313 + obj->prev = NULL;
63314 +
63315 + curr = &role->subj_hash[index];
63316 + if (*curr != NULL)
63317 + (*curr)->prev = obj;
63318 +
63319 + obj->next = *curr;
63320 + *curr = obj;
63321 +
63322 + return;
63323 +}
63324 +
63325 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
63326 +
63327 +static void *
63328 +create_table(__u32 * len, int elementsize)
63329 +{
63330 + unsigned int table_sizes[] = {
63331 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
63332 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
63333 + 4194301, 8388593, 16777213, 33554393, 67108859
63334 + };
63335 + void *newtable = NULL;
63336 + unsigned int pwr = 0;
63337 +
63338 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
63339 + table_sizes[pwr] <= *len)
63340 + pwr++;
63341 +
63342 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
63343 + return newtable;
63344 +
63345 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
63346 + newtable =
63347 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
63348 + else
63349 + newtable = vmalloc(table_sizes[pwr] * elementsize);
63350 +
63351 + *len = table_sizes[pwr];
63352 +
63353 + return newtable;
63354 +}
63355 +
63356 +static int
63357 +init_variables(const struct gr_arg *arg)
63358 +{
63359 + struct task_struct *reaper = init_pid_ns.child_reaper;
63360 + unsigned int stacksize;
63361 +
63362 + subj_map_set.s_size = arg->role_db.num_subjects;
63363 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
63364 + name_set.n_size = arg->role_db.num_objects;
63365 + inodev_set.i_size = arg->role_db.num_objects;
63366 +
63367 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
63368 + !name_set.n_size || !inodev_set.i_size)
63369 + return 1;
63370 +
63371 + if (!gr_init_uidset())
63372 + return 1;
63373 +
63374 + /* set up the stack that holds allocation info */
63375 +
63376 + stacksize = arg->role_db.num_pointers + 5;
63377 +
63378 + if (!acl_alloc_stack_init(stacksize))
63379 + return 1;
63380 +
63381 + /* grab reference for the real root dentry and vfsmount */
63382 + get_fs_root(reaper->fs, &real_root);
63383 +
63384 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63385 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
63386 +#endif
63387 +
63388 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
63389 + if (fakefs_obj_rw == NULL)
63390 + return 1;
63391 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
63392 +
63393 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
63394 + if (fakefs_obj_rwx == NULL)
63395 + return 1;
63396 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
63397 +
63398 + subj_map_set.s_hash =
63399 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
63400 + acl_role_set.r_hash =
63401 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
63402 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
63403 + inodev_set.i_hash =
63404 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
63405 +
63406 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
63407 + !name_set.n_hash || !inodev_set.i_hash)
63408 + return 1;
63409 +
63410 + memset(subj_map_set.s_hash, 0,
63411 + sizeof(struct subject_map *) * subj_map_set.s_size);
63412 + memset(acl_role_set.r_hash, 0,
63413 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
63414 + memset(name_set.n_hash, 0,
63415 + sizeof (struct name_entry *) * name_set.n_size);
63416 + memset(inodev_set.i_hash, 0,
63417 + sizeof (struct inodev_entry *) * inodev_set.i_size);
63418 +
63419 + return 0;
63420 +}
63421 +
63422 +/* free information not needed after startup
63423 + currently contains user->kernel pointer mappings for subjects
63424 +*/
63425 +
63426 +static void
63427 +free_init_variables(void)
63428 +{
63429 + __u32 i;
63430 +
63431 + if (subj_map_set.s_hash) {
63432 + for (i = 0; i < subj_map_set.s_size; i++) {
63433 + if (subj_map_set.s_hash[i]) {
63434 + kfree(subj_map_set.s_hash[i]);
63435 + subj_map_set.s_hash[i] = NULL;
63436 + }
63437 + }
63438 +
63439 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
63440 + PAGE_SIZE)
63441 + kfree(subj_map_set.s_hash);
63442 + else
63443 + vfree(subj_map_set.s_hash);
63444 + }
63445 +
63446 + return;
63447 +}
63448 +
63449 +static void
63450 +free_variables(void)
63451 +{
63452 + struct acl_subject_label *s;
63453 + struct acl_role_label *r;
63454 + struct task_struct *task, *task2;
63455 + unsigned int x;
63456 +
63457 + gr_clear_learn_entries();
63458 +
63459 + read_lock(&tasklist_lock);
63460 + do_each_thread(task2, task) {
63461 + task->acl_sp_role = 0;
63462 + task->acl_role_id = 0;
63463 + task->acl = NULL;
63464 + task->role = NULL;
63465 + } while_each_thread(task2, task);
63466 + read_unlock(&tasklist_lock);
63467 +
63468 + /* release the reference to the real root dentry and vfsmount */
63469 + path_put(&real_root);
63470 + memset(&real_root, 0, sizeof(real_root));
63471 +
63472 + /* free all object hash tables */
63473 +
63474 + FOR_EACH_ROLE_START(r)
63475 + if (r->subj_hash == NULL)
63476 + goto next_role;
63477 + FOR_EACH_SUBJECT_START(r, s, x)
63478 + if (s->obj_hash == NULL)
63479 + break;
63480 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63481 + kfree(s->obj_hash);
63482 + else
63483 + vfree(s->obj_hash);
63484 + FOR_EACH_SUBJECT_END(s, x)
63485 + FOR_EACH_NESTED_SUBJECT_START(r, s)
63486 + if (s->obj_hash == NULL)
63487 + break;
63488 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
63489 + kfree(s->obj_hash);
63490 + else
63491 + vfree(s->obj_hash);
63492 + FOR_EACH_NESTED_SUBJECT_END(s)
63493 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
63494 + kfree(r->subj_hash);
63495 + else
63496 + vfree(r->subj_hash);
63497 + r->subj_hash = NULL;
63498 +next_role:
63499 + FOR_EACH_ROLE_END(r)
63500 +
63501 + acl_free_all();
63502 +
63503 + if (acl_role_set.r_hash) {
63504 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
63505 + PAGE_SIZE)
63506 + kfree(acl_role_set.r_hash);
63507 + else
63508 + vfree(acl_role_set.r_hash);
63509 + }
63510 + if (name_set.n_hash) {
63511 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
63512 + PAGE_SIZE)
63513 + kfree(name_set.n_hash);
63514 + else
63515 + vfree(name_set.n_hash);
63516 + }
63517 +
63518 + if (inodev_set.i_hash) {
63519 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
63520 + PAGE_SIZE)
63521 + kfree(inodev_set.i_hash);
63522 + else
63523 + vfree(inodev_set.i_hash);
63524 + }
63525 +
63526 + gr_free_uidset();
63527 +
63528 + memset(&name_set, 0, sizeof (struct name_db));
63529 + memset(&inodev_set, 0, sizeof (struct inodev_db));
63530 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
63531 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
63532 +
63533 + default_role = NULL;
63534 + kernel_role = NULL;
63535 + role_list = NULL;
63536 +
63537 + return;
63538 +}
63539 +
63540 +static struct acl_subject_label *
63541 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
63542 +
63543 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
63544 +{
63545 + unsigned int len = strnlen_user(*name, maxlen);
63546 + char *tmp;
63547 +
63548 + if (!len || len >= maxlen)
63549 + return -EINVAL;
63550 +
63551 + if ((tmp = (char *) acl_alloc(len)) == NULL)
63552 + return -ENOMEM;
63553 +
63554 + if (copy_from_user(tmp, *name, len))
63555 + return -EFAULT;
63556 +
63557 + tmp[len-1] = '\0';
63558 + *name = tmp;
63559 +
63560 + return 0;
63561 +}
63562 +
63563 +static int
63564 +copy_user_glob(struct acl_object_label *obj)
63565 +{
63566 + struct acl_object_label *g_tmp, **guser;
63567 + int error;
63568 +
63569 + if (obj->globbed == NULL)
63570 + return 0;
63571 +
63572 + guser = &obj->globbed;
63573 + while (*guser) {
63574 + g_tmp = (struct acl_object_label *)
63575 + acl_alloc(sizeof (struct acl_object_label));
63576 + if (g_tmp == NULL)
63577 + return -ENOMEM;
63578 +
63579 + if (copy_acl_object_label(g_tmp, *guser))
63580 + return -EFAULT;
63581 +
63582 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
63583 + if (error)
63584 + return error;
63585 +
63586 + *guser = g_tmp;
63587 + guser = &(g_tmp->next);
63588 + }
63589 +
63590 + return 0;
63591 +}
63592 +
63593 +static int
63594 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
63595 + struct acl_role_label *role)
63596 +{
63597 + struct acl_object_label *o_tmp;
63598 + int ret;
63599 +
63600 + while (userp) {
63601 + if ((o_tmp = (struct acl_object_label *)
63602 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
63603 + return -ENOMEM;
63604 +
63605 + if (copy_acl_object_label(o_tmp, userp))
63606 + return -EFAULT;
63607 +
63608 + userp = o_tmp->prev;
63609 +
63610 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
63611 + if (ret)
63612 + return ret;
63613 +
63614 + insert_acl_obj_label(o_tmp, subj);
63615 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
63616 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
63617 + return -ENOMEM;
63618 +
63619 + ret = copy_user_glob(o_tmp);
63620 + if (ret)
63621 + return ret;
63622 +
63623 + if (o_tmp->nested) {
63624 + int already_copied;
63625 +
63626 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
63627 + if (IS_ERR(o_tmp->nested))
63628 + return PTR_ERR(o_tmp->nested);
63629 +
63630 + /* insert into nested subject list if we haven't copied this one yet
63631 + to prevent duplicate entries */
63632 + if (!already_copied) {
63633 + o_tmp->nested->next = role->hash->first;
63634 + role->hash->first = o_tmp->nested;
63635 + }
63636 + }
63637 + }
63638 +
63639 + return 0;
63640 +}
63641 +
63642 +static __u32
63643 +count_user_subjs(struct acl_subject_label *userp)
63644 +{
63645 + struct acl_subject_label s_tmp;
63646 + __u32 num = 0;
63647 +
63648 + while (userp) {
63649 + if (copy_acl_subject_label(&s_tmp, userp))
63650 + break;
63651 +
63652 + userp = s_tmp.prev;
63653 + }
63654 +
63655 + return num;
63656 +}
63657 +
63658 +static int
63659 +copy_user_allowedips(struct acl_role_label *rolep)
63660 +{
63661 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
63662 +
63663 + ruserip = rolep->allowed_ips;
63664 +
63665 + while (ruserip) {
63666 + rlast = rtmp;
63667 +
63668 + if ((rtmp = (struct role_allowed_ip *)
63669 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
63670 + return -ENOMEM;
63671 +
63672 + if (copy_role_allowed_ip(rtmp, ruserip))
63673 + return -EFAULT;
63674 +
63675 + ruserip = rtmp->prev;
63676 +
63677 + if (!rlast) {
63678 + rtmp->prev = NULL;
63679 + rolep->allowed_ips = rtmp;
63680 + } else {
63681 + rlast->next = rtmp;
63682 + rtmp->prev = rlast;
63683 + }
63684 +
63685 + if (!ruserip)
63686 + rtmp->next = NULL;
63687 + }
63688 +
63689 + return 0;
63690 +}
63691 +
63692 +static int
63693 +copy_user_transitions(struct acl_role_label *rolep)
63694 +{
63695 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
63696 + int error;
63697 +
63698 + rusertp = rolep->transitions;
63699 +
63700 + while (rusertp) {
63701 + rlast = rtmp;
63702 +
63703 + if ((rtmp = (struct role_transition *)
63704 + acl_alloc(sizeof (struct role_transition))) == NULL)
63705 + return -ENOMEM;
63706 +
63707 + if (copy_role_transition(rtmp, rusertp))
63708 + return -EFAULT;
63709 +
63710 + rusertp = rtmp->prev;
63711 +
63712 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
63713 + if (error)
63714 + return error;
63715 +
63716 + if (!rlast) {
63717 + rtmp->prev = NULL;
63718 + rolep->transitions = rtmp;
63719 + } else {
63720 + rlast->next = rtmp;
63721 + rtmp->prev = rlast;
63722 + }
63723 +
63724 + if (!rusertp)
63725 + rtmp->next = NULL;
63726 + }
63727 +
63728 + return 0;
63729 +}
63730 +
63731 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
63732 +{
63733 + struct acl_object_label o_tmp;
63734 + __u32 num = 0;
63735 +
63736 + while (userp) {
63737 + if (copy_acl_object_label(&o_tmp, userp))
63738 + break;
63739 +
63740 + userp = o_tmp.prev;
63741 + num++;
63742 + }
63743 +
63744 + return num;
63745 +}
63746 +
63747 +static struct acl_subject_label *
63748 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
63749 +{
63750 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
63751 + __u32 num_objs;
63752 + struct acl_ip_label **i_tmp, *i_utmp2;
63753 + struct gr_hash_struct ghash;
63754 + struct subject_map *subjmap;
63755 + unsigned int i_num;
63756 + int err;
63757 +
63758 + if (already_copied != NULL)
63759 + *already_copied = 0;
63760 +
63761 + s_tmp = lookup_subject_map(userp);
63762 +
63763 + /* we've already copied this subject into the kernel, just return
63764 + the reference to it, and don't copy it over again
63765 + */
63766 + if (s_tmp) {
63767 + if (already_copied != NULL)
63768 + *already_copied = 1;
63769 + return(s_tmp);
63770 + }
63771 +
63772 + if ((s_tmp = (struct acl_subject_label *)
63773 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
63774 + return ERR_PTR(-ENOMEM);
63775 +
63776 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
63777 + if (subjmap == NULL)
63778 + return ERR_PTR(-ENOMEM);
63779 +
63780 + subjmap->user = userp;
63781 + subjmap->kernel = s_tmp;
63782 + insert_subj_map_entry(subjmap);
63783 +
63784 + if (copy_acl_subject_label(s_tmp, userp))
63785 + return ERR_PTR(-EFAULT);
63786 +
63787 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
63788 + if (err)
63789 + return ERR_PTR(err);
63790 +
63791 + if (!strcmp(s_tmp->filename, "/"))
63792 + role->root_label = s_tmp;
63793 +
63794 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
63795 + return ERR_PTR(-EFAULT);
63796 +
63797 + /* copy user and group transition tables */
63798 +
63799 + if (s_tmp->user_trans_num) {
63800 + uid_t *uidlist;
63801 +
63802 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
63803 + if (uidlist == NULL)
63804 + return ERR_PTR(-ENOMEM);
63805 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
63806 + return ERR_PTR(-EFAULT);
63807 +
63808 + s_tmp->user_transitions = uidlist;
63809 + }
63810 +
63811 + if (s_tmp->group_trans_num) {
63812 + gid_t *gidlist;
63813 +
63814 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
63815 + if (gidlist == NULL)
63816 + return ERR_PTR(-ENOMEM);
63817 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
63818 + return ERR_PTR(-EFAULT);
63819 +
63820 + s_tmp->group_transitions = gidlist;
63821 + }
63822 +
63823 + /* set up object hash table */
63824 + num_objs = count_user_objs(ghash.first);
63825 +
63826 + s_tmp->obj_hash_size = num_objs;
63827 + s_tmp->obj_hash =
63828 + (struct acl_object_label **)
63829 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
63830 +
63831 + if (!s_tmp->obj_hash)
63832 + return ERR_PTR(-ENOMEM);
63833 +
63834 + memset(s_tmp->obj_hash, 0,
63835 + s_tmp->obj_hash_size *
63836 + sizeof (struct acl_object_label *));
63837 +
63838 + /* add in objects */
63839 + err = copy_user_objs(ghash.first, s_tmp, role);
63840 +
63841 + if (err)
63842 + return ERR_PTR(err);
63843 +
63844 + /* set pointer for parent subject */
63845 + if (s_tmp->parent_subject) {
63846 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
63847 +
63848 + if (IS_ERR(s_tmp2))
63849 + return s_tmp2;
63850 +
63851 + s_tmp->parent_subject = s_tmp2;
63852 + }
63853 +
63854 + /* add in ip acls */
63855 +
63856 + if (!s_tmp->ip_num) {
63857 + s_tmp->ips = NULL;
63858 + goto insert;
63859 + }
63860 +
63861 + i_tmp =
63862 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
63863 + sizeof (struct acl_ip_label *));
63864 +
63865 + if (!i_tmp)
63866 + return ERR_PTR(-ENOMEM);
63867 +
63868 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
63869 + *(i_tmp + i_num) =
63870 + (struct acl_ip_label *)
63871 + acl_alloc(sizeof (struct acl_ip_label));
63872 + if (!*(i_tmp + i_num))
63873 + return ERR_PTR(-ENOMEM);
63874 +
63875 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
63876 + return ERR_PTR(-EFAULT);
63877 +
63878 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
63879 + return ERR_PTR(-EFAULT);
63880 +
63881 + if ((*(i_tmp + i_num))->iface == NULL)
63882 + continue;
63883 +
63884 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
63885 + if (err)
63886 + return ERR_PTR(err);
63887 + }
63888 +
63889 + s_tmp->ips = i_tmp;
63890 +
63891 +insert:
63892 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
63893 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
63894 + return ERR_PTR(-ENOMEM);
63895 +
63896 + return s_tmp;
63897 +}
63898 +
63899 +static int
63900 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
63901 +{
63902 + struct acl_subject_label s_pre;
63903 + struct acl_subject_label * ret;
63904 + int err;
63905 +
63906 + while (userp) {
63907 + if (copy_acl_subject_label(&s_pre, userp))
63908 + return -EFAULT;
63909 +
63910 + ret = do_copy_user_subj(userp, role, NULL);
63911 +
63912 + err = PTR_ERR(ret);
63913 + if (IS_ERR(ret))
63914 + return err;
63915 +
63916 + insert_acl_subj_label(ret, role);
63917 +
63918 + userp = s_pre.prev;
63919 + }
63920 +
63921 + return 0;
63922 +}
63923 +
63924 +static int
63925 +copy_user_acl(struct gr_arg *arg)
63926 +{
63927 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
63928 + struct acl_subject_label *subj_list;
63929 + struct sprole_pw *sptmp;
63930 + struct gr_hash_struct *ghash;
63931 + uid_t *domainlist;
63932 + unsigned int r_num;
63933 + int err = 0;
63934 + __u16 i;
63935 + __u32 num_subjs;
63936 +
63937 + /* we need a default and kernel role */
63938 + if (arg->role_db.num_roles < 2)
63939 + return -EINVAL;
63940 +
63941 + /* copy special role authentication info from userspace */
63942 +
63943 + num_sprole_pws = arg->num_sprole_pws;
63944 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
63945 +
63946 + if (!acl_special_roles && num_sprole_pws)
63947 + return -ENOMEM;
63948 +
63949 + for (i = 0; i < num_sprole_pws; i++) {
63950 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
63951 + if (!sptmp)
63952 + return -ENOMEM;
63953 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
63954 + return -EFAULT;
63955 +
63956 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
63957 + if (err)
63958 + return err;
63959 +
63960 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63961 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
63962 +#endif
63963 +
63964 + acl_special_roles[i] = sptmp;
63965 + }
63966 +
63967 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
63968 +
63969 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
63970 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
63971 +
63972 + if (!r_tmp)
63973 + return -ENOMEM;
63974 +
63975 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
63976 + return -EFAULT;
63977 +
63978 + if (copy_acl_role_label(r_tmp, r_utmp2))
63979 + return -EFAULT;
63980 +
63981 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
63982 + if (err)
63983 + return err;
63984 +
63985 + if (!strcmp(r_tmp->rolename, "default")
63986 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
63987 + default_role = r_tmp;
63988 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
63989 + kernel_role = r_tmp;
63990 + }
63991 +
63992 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
63993 + return -ENOMEM;
63994 +
63995 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
63996 + return -EFAULT;
63997 +
63998 + r_tmp->hash = ghash;
63999 +
64000 + num_subjs = count_user_subjs(r_tmp->hash->first);
64001 +
64002 + r_tmp->subj_hash_size = num_subjs;
64003 + r_tmp->subj_hash =
64004 + (struct acl_subject_label **)
64005 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
64006 +
64007 + if (!r_tmp->subj_hash)
64008 + return -ENOMEM;
64009 +
64010 + err = copy_user_allowedips(r_tmp);
64011 + if (err)
64012 + return err;
64013 +
64014 + /* copy domain info */
64015 + if (r_tmp->domain_children != NULL) {
64016 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
64017 + if (domainlist == NULL)
64018 + return -ENOMEM;
64019 +
64020 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
64021 + return -EFAULT;
64022 +
64023 + r_tmp->domain_children = domainlist;
64024 + }
64025 +
64026 + err = copy_user_transitions(r_tmp);
64027 + if (err)
64028 + return err;
64029 +
64030 + memset(r_tmp->subj_hash, 0,
64031 + r_tmp->subj_hash_size *
64032 + sizeof (struct acl_subject_label *));
64033 +
64034 + /* acquire the list of subjects, then NULL out
64035 + the list prior to parsing the subjects for this role,
64036 + as during this parsing the list is replaced with a list
64037 + of *nested* subjects for the role
64038 + */
64039 + subj_list = r_tmp->hash->first;
64040 +
64041 + /* set nested subject list to null */
64042 + r_tmp->hash->first = NULL;
64043 +
64044 + err = copy_user_subjs(subj_list, r_tmp);
64045 +
64046 + if (err)
64047 + return err;
64048 +
64049 + insert_acl_role_label(r_tmp);
64050 + }
64051 +
64052 + if (default_role == NULL || kernel_role == NULL)
64053 + return -EINVAL;
64054 +
64055 + return err;
64056 +}
64057 +
64058 +static int
64059 +gracl_init(struct gr_arg *args)
64060 +{
64061 + int error = 0;
64062 +
64063 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
64064 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
64065 +
64066 + if (init_variables(args)) {
64067 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
64068 + error = -ENOMEM;
64069 + free_variables();
64070 + goto out;
64071 + }
64072 +
64073 + error = copy_user_acl(args);
64074 + free_init_variables();
64075 + if (error) {
64076 + free_variables();
64077 + goto out;
64078 + }
64079 +
64080 + if ((error = gr_set_acls(0))) {
64081 + free_variables();
64082 + goto out;
64083 + }
64084 +
64085 + pax_open_kernel();
64086 + gr_status |= GR_READY;
64087 + pax_close_kernel();
64088 +
64089 + out:
64090 + return error;
64091 +}
64092 +
64093 +/* derived from glibc fnmatch() 0: match, 1: no match*/
64094 +
64095 +static int
64096 +glob_match(const char *p, const char *n)
64097 +{
64098 + char c;
64099 +
64100 + while ((c = *p++) != '\0') {
64101 + switch (c) {
64102 + case '?':
64103 + if (*n == '\0')
64104 + return 1;
64105 + else if (*n == '/')
64106 + return 1;
64107 + break;
64108 + case '\\':
64109 + if (*n != c)
64110 + return 1;
64111 + break;
64112 + case '*':
64113 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
64114 + if (*n == '/')
64115 + return 1;
64116 + else if (c == '?') {
64117 + if (*n == '\0')
64118 + return 1;
64119 + else
64120 + ++n;
64121 + }
64122 + }
64123 + if (c == '\0') {
64124 + return 0;
64125 + } else {
64126 + const char *endp;
64127 +
64128 + if ((endp = strchr(n, '/')) == NULL)
64129 + endp = n + strlen(n);
64130 +
64131 + if (c == '[') {
64132 + for (--p; n < endp; ++n)
64133 + if (!glob_match(p, n))
64134 + return 0;
64135 + } else if (c == '/') {
64136 + while (*n != '\0' && *n != '/')
64137 + ++n;
64138 + if (*n == '/' && !glob_match(p, n + 1))
64139 + return 0;
64140 + } else {
64141 + for (--p; n < endp; ++n)
64142 + if (*n == c && !glob_match(p, n))
64143 + return 0;
64144 + }
64145 +
64146 + return 1;
64147 + }
64148 + case '[':
64149 + {
64150 + int not;
64151 + char cold;
64152 +
64153 + if (*n == '\0' || *n == '/')
64154 + return 1;
64155 +
64156 + not = (*p == '!' || *p == '^');
64157 + if (not)
64158 + ++p;
64159 +
64160 + c = *p++;
64161 + for (;;) {
64162 + unsigned char fn = (unsigned char)*n;
64163 +
64164 + if (c == '\0')
64165 + return 1;
64166 + else {
64167 + if (c == fn)
64168 + goto matched;
64169 + cold = c;
64170 + c = *p++;
64171 +
64172 + if (c == '-' && *p != ']') {
64173 + unsigned char cend = *p++;
64174 +
64175 + if (cend == '\0')
64176 + return 1;
64177 +
64178 + if (cold <= fn && fn <= cend)
64179 + goto matched;
64180 +
64181 + c = *p++;
64182 + }
64183 + }
64184 +
64185 + if (c == ']')
64186 + break;
64187 + }
64188 + if (!not)
64189 + return 1;
64190 + break;
64191 + matched:
64192 + while (c != ']') {
64193 + if (c == '\0')
64194 + return 1;
64195 +
64196 + c = *p++;
64197 + }
64198 + if (not)
64199 + return 1;
64200 + }
64201 + break;
64202 + default:
64203 + if (c != *n)
64204 + return 1;
64205 + }
64206 +
64207 + ++n;
64208 + }
64209 +
64210 + if (*n == '\0')
64211 + return 0;
64212 +
64213 + if (*n == '/')
64214 + return 0;
64215 +
64216 + return 1;
64217 +}
64218 +
64219 +static struct acl_object_label *
64220 +chk_glob_label(struct acl_object_label *globbed,
64221 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64222 +{
64223 + struct acl_object_label *tmp;
64224 +
64225 + if (*path == NULL)
64226 + *path = gr_to_filename_nolock(dentry, mnt);
64227 +
64228 + tmp = globbed;
64229 +
64230 + while (tmp) {
64231 + if (!glob_match(tmp->filename, *path))
64232 + return tmp;
64233 + tmp = tmp->next;
64234 + }
64235 +
64236 + return NULL;
64237 +}
64238 +
64239 +static struct acl_object_label *
64240 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64241 + const ino_t curr_ino, const dev_t curr_dev,
64242 + const struct acl_subject_label *subj, char **path, const int checkglob)
64243 +{
64244 + struct acl_subject_label *tmpsubj;
64245 + struct acl_object_label *retval;
64246 + struct acl_object_label *retval2;
64247 +
64248 + tmpsubj = (struct acl_subject_label *) subj;
64249 + read_lock(&gr_inode_lock);
64250 + do {
64251 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64252 + if (retval) {
64253 + if (checkglob && retval->globbed) {
64254 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64255 + if (retval2)
64256 + retval = retval2;
64257 + }
64258 + break;
64259 + }
64260 + } while ((tmpsubj = tmpsubj->parent_subject));
64261 + read_unlock(&gr_inode_lock);
64262 +
64263 + return retval;
64264 +}
64265 +
64266 +static __inline__ struct acl_object_label *
64267 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64268 + struct dentry *curr_dentry,
64269 + const struct acl_subject_label *subj, char **path, const int checkglob)
64270 +{
64271 + int newglob = checkglob;
64272 + ino_t inode;
64273 + dev_t device;
64274 +
64275 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64276 + as we don't want a / * rule to match instead of the / object
64277 + don't do this for create lookups that call this function though, since they're looking up
64278 + on the parent and thus need globbing checks on all paths
64279 + */
64280 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64281 + newglob = GR_NO_GLOB;
64282 +
64283 + spin_lock(&curr_dentry->d_lock);
64284 + inode = curr_dentry->d_inode->i_ino;
64285 + device = __get_dev(curr_dentry);
64286 + spin_unlock(&curr_dentry->d_lock);
64287 +
64288 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64289 +}
64290 +
64291 +#ifdef CONFIG_HUGETLBFS
64292 +static inline bool
64293 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64294 +{
64295 + int i;
64296 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64297 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64298 + return true;
64299 + }
64300 +
64301 + return false;
64302 +}
64303 +#endif
64304 +
64305 +static struct acl_object_label *
64306 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64307 + const struct acl_subject_label *subj, char *path, const int checkglob)
64308 +{
64309 + struct dentry *dentry = (struct dentry *) l_dentry;
64310 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64311 + struct mount *real_mnt = real_mount(mnt);
64312 + struct acl_object_label *retval;
64313 + struct dentry *parent;
64314 +
64315 + br_read_lock(&vfsmount_lock);
64316 + write_seqlock(&rename_lock);
64317 +
64318 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64319 +#ifdef CONFIG_NET
64320 + mnt == sock_mnt ||
64321 +#endif
64322 +#ifdef CONFIG_HUGETLBFS
64323 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64324 +#endif
64325 + /* ignore Eric Biederman */
64326 + IS_PRIVATE(l_dentry->d_inode))) {
64327 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64328 + goto out;
64329 + }
64330 +
64331 + for (;;) {
64332 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64333 + break;
64334 +
64335 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64336 + if (!mnt_has_parent(real_mnt))
64337 + break;
64338 +
64339 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64340 + if (retval != NULL)
64341 + goto out;
64342 +
64343 + dentry = real_mnt->mnt_mountpoint;
64344 + real_mnt = real_mnt->mnt_parent;
64345 + mnt = &real_mnt->mnt;
64346 + continue;
64347 + }
64348 +
64349 + parent = dentry->d_parent;
64350 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64351 + if (retval != NULL)
64352 + goto out;
64353 +
64354 + dentry = parent;
64355 + }
64356 +
64357 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64358 +
64359 + /* real_root is pinned so we don't have to hold a reference */
64360 + if (retval == NULL)
64361 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
64362 +out:
64363 + write_sequnlock(&rename_lock);
64364 + br_read_unlock(&vfsmount_lock);
64365 +
64366 + BUG_ON(retval == NULL);
64367 +
64368 + return retval;
64369 +}
64370 +
64371 +static __inline__ struct acl_object_label *
64372 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64373 + const struct acl_subject_label *subj)
64374 +{
64375 + char *path = NULL;
64376 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64377 +}
64378 +
64379 +static __inline__ struct acl_object_label *
64380 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64381 + const struct acl_subject_label *subj)
64382 +{
64383 + char *path = NULL;
64384 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64385 +}
64386 +
64387 +static __inline__ struct acl_object_label *
64388 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64389 + const struct acl_subject_label *subj, char *path)
64390 +{
64391 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64392 +}
64393 +
64394 +static struct acl_subject_label *
64395 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64396 + const struct acl_role_label *role)
64397 +{
64398 + struct dentry *dentry = (struct dentry *) l_dentry;
64399 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64400 + struct mount *real_mnt = real_mount(mnt);
64401 + struct acl_subject_label *retval;
64402 + struct dentry *parent;
64403 +
64404 + br_read_lock(&vfsmount_lock);
64405 + write_seqlock(&rename_lock);
64406 +
64407 + for (;;) {
64408 + if (dentry == real_root.dentry && mnt == real_root.mnt)
64409 + break;
64410 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64411 + if (!mnt_has_parent(real_mnt))
64412 + break;
64413 +
64414 + spin_lock(&dentry->d_lock);
64415 + read_lock(&gr_inode_lock);
64416 + retval =
64417 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64418 + __get_dev(dentry), role);
64419 + read_unlock(&gr_inode_lock);
64420 + spin_unlock(&dentry->d_lock);
64421 + if (retval != NULL)
64422 + goto out;
64423 +
64424 + dentry = real_mnt->mnt_mountpoint;
64425 + real_mnt = real_mnt->mnt_parent;
64426 + mnt = &real_mnt->mnt;
64427 + continue;
64428 + }
64429 +
64430 + spin_lock(&dentry->d_lock);
64431 + read_lock(&gr_inode_lock);
64432 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64433 + __get_dev(dentry), role);
64434 + read_unlock(&gr_inode_lock);
64435 + parent = dentry->d_parent;
64436 + spin_unlock(&dentry->d_lock);
64437 +
64438 + if (retval != NULL)
64439 + goto out;
64440 +
64441 + dentry = parent;
64442 + }
64443 +
64444 + spin_lock(&dentry->d_lock);
64445 + read_lock(&gr_inode_lock);
64446 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64447 + __get_dev(dentry), role);
64448 + read_unlock(&gr_inode_lock);
64449 + spin_unlock(&dentry->d_lock);
64450 +
64451 + if (unlikely(retval == NULL)) {
64452 + /* real_root is pinned, we don't need to hold a reference */
64453 + read_lock(&gr_inode_lock);
64454 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
64455 + __get_dev(real_root.dentry), role);
64456 + read_unlock(&gr_inode_lock);
64457 + }
64458 +out:
64459 + write_sequnlock(&rename_lock);
64460 + br_read_unlock(&vfsmount_lock);
64461 +
64462 + BUG_ON(retval == NULL);
64463 +
64464 + return retval;
64465 +}
64466 +
64467 +static void
64468 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64469 +{
64470 + struct task_struct *task = current;
64471 + const struct cred *cred = current_cred();
64472 +
64473 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64474 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64475 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64476 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64477 +
64478 + return;
64479 +}
64480 +
64481 +static void
64482 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64483 +{
64484 + struct task_struct *task = current;
64485 + const struct cred *cred = current_cred();
64486 +
64487 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64488 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64489 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64490 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64491 +
64492 + return;
64493 +}
64494 +
64495 +static void
64496 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64497 +{
64498 + struct task_struct *task = current;
64499 + const struct cred *cred = current_cred();
64500 +
64501 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64502 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64503 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64504 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64505 +
64506 + return;
64507 +}
64508 +
64509 +__u32
64510 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64511 + const struct vfsmount * mnt)
64512 +{
64513 + __u32 retval = mode;
64514 + struct acl_subject_label *curracl;
64515 + struct acl_object_label *currobj;
64516 +
64517 + if (unlikely(!(gr_status & GR_READY)))
64518 + return (mode & ~GR_AUDITS);
64519 +
64520 + curracl = current->acl;
64521 +
64522 + currobj = chk_obj_label(dentry, mnt, curracl);
64523 + retval = currobj->mode & mode;
64524 +
64525 + /* if we're opening a specified transfer file for writing
64526 + (e.g. /dev/initctl), then transfer our role to init
64527 + */
64528 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64529 + current->role->roletype & GR_ROLE_PERSIST)) {
64530 + struct task_struct *task = init_pid_ns.child_reaper;
64531 +
64532 + if (task->role != current->role) {
64533 + task->acl_sp_role = 0;
64534 + task->acl_role_id = current->acl_role_id;
64535 + task->role = current->role;
64536 + rcu_read_lock();
64537 + read_lock(&grsec_exec_file_lock);
64538 + gr_apply_subject_to_task(task);
64539 + read_unlock(&grsec_exec_file_lock);
64540 + rcu_read_unlock();
64541 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
64542 + }
64543 + }
64544 +
64545 + if (unlikely
64546 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
64547 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
64548 + __u32 new_mode = mode;
64549 +
64550 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64551 +
64552 + retval = new_mode;
64553 +
64554 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
64555 + new_mode |= GR_INHERIT;
64556 +
64557 + if (!(mode & GR_NOLEARN))
64558 + gr_log_learn(dentry, mnt, new_mode);
64559 + }
64560 +
64561 + return retval;
64562 +}
64563 +
64564 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
64565 + const struct dentry *parent,
64566 + const struct vfsmount *mnt)
64567 +{
64568 + struct name_entry *match;
64569 + struct acl_object_label *matchpo;
64570 + struct acl_subject_label *curracl;
64571 + char *path;
64572 +
64573 + if (unlikely(!(gr_status & GR_READY)))
64574 + return NULL;
64575 +
64576 + preempt_disable();
64577 + path = gr_to_filename_rbac(new_dentry, mnt);
64578 + match = lookup_name_entry_create(path);
64579 +
64580 + curracl = current->acl;
64581 +
64582 + if (match) {
64583 + read_lock(&gr_inode_lock);
64584 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
64585 + read_unlock(&gr_inode_lock);
64586 +
64587 + if (matchpo) {
64588 + preempt_enable();
64589 + return matchpo;
64590 + }
64591 + }
64592 +
64593 + // lookup parent
64594 +
64595 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
64596 +
64597 + preempt_enable();
64598 + return matchpo;
64599 +}
64600 +
64601 +__u32
64602 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
64603 + const struct vfsmount * mnt, const __u32 mode)
64604 +{
64605 + struct acl_object_label *matchpo;
64606 + __u32 retval;
64607 +
64608 + if (unlikely(!(gr_status & GR_READY)))
64609 + return (mode & ~GR_AUDITS);
64610 +
64611 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
64612 +
64613 + retval = matchpo->mode & mode;
64614 +
64615 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
64616 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
64617 + __u32 new_mode = mode;
64618 +
64619 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
64620 +
64621 + gr_log_learn(new_dentry, mnt, new_mode);
64622 + return new_mode;
64623 + }
64624 +
64625 + return retval;
64626 +}
64627 +
64628 +__u32
64629 +gr_check_link(const struct dentry * new_dentry,
64630 + const struct dentry * parent_dentry,
64631 + const struct vfsmount * parent_mnt,
64632 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
64633 +{
64634 + struct acl_object_label *obj;
64635 + __u32 oldmode, newmode;
64636 + __u32 needmode;
64637 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
64638 + GR_DELETE | GR_INHERIT;
64639 +
64640 + if (unlikely(!(gr_status & GR_READY)))
64641 + return (GR_CREATE | GR_LINK);
64642 +
64643 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
64644 + oldmode = obj->mode;
64645 +
64646 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
64647 + newmode = obj->mode;
64648 +
64649 + needmode = newmode & checkmodes;
64650 +
64651 + // old name for hardlink must have at least the permissions of the new name
64652 + if ((oldmode & needmode) != needmode)
64653 + goto bad;
64654 +
64655 + // if old name had restrictions/auditing, make sure the new name does as well
64656 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
64657 +
64658 + // don't allow hardlinking of suid/sgid/fcapped files without permission
64659 + if (is_privileged_binary(old_dentry))
64660 + needmode |= GR_SETID;
64661 +
64662 + if ((newmode & needmode) != needmode)
64663 + goto bad;
64664 +
64665 + // enforce minimum permissions
64666 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
64667 + return newmode;
64668 +bad:
64669 + needmode = oldmode;
64670 + if (is_privileged_binary(old_dentry))
64671 + needmode |= GR_SETID;
64672 +
64673 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
64674 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
64675 + return (GR_CREATE | GR_LINK);
64676 + } else if (newmode & GR_SUPPRESS)
64677 + return GR_SUPPRESS;
64678 + else
64679 + return 0;
64680 +}
64681 +
64682 +int
64683 +gr_check_hidden_task(const struct task_struct *task)
64684 +{
64685 + if (unlikely(!(gr_status & GR_READY)))
64686 + return 0;
64687 +
64688 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
64689 + return 1;
64690 +
64691 + return 0;
64692 +}
64693 +
64694 +int
64695 +gr_check_protected_task(const struct task_struct *task)
64696 +{
64697 + if (unlikely(!(gr_status & GR_READY) || !task))
64698 + return 0;
64699 +
64700 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64701 + task->acl != current->acl)
64702 + return 1;
64703 +
64704 + return 0;
64705 +}
64706 +
64707 +int
64708 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64709 +{
64710 + struct task_struct *p;
64711 + int ret = 0;
64712 +
64713 + if (unlikely(!(gr_status & GR_READY) || !pid))
64714 + return ret;
64715 +
64716 + read_lock(&tasklist_lock);
64717 + do_each_pid_task(pid, type, p) {
64718 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
64719 + p->acl != current->acl) {
64720 + ret = 1;
64721 + goto out;
64722 + }
64723 + } while_each_pid_task(pid, type, p);
64724 +out:
64725 + read_unlock(&tasklist_lock);
64726 +
64727 + return ret;
64728 +}
64729 +
64730 +void
64731 +gr_copy_label(struct task_struct *tsk)
64732 +{
64733 + tsk->signal->used_accept = 0;
64734 + tsk->acl_sp_role = 0;
64735 + tsk->acl_role_id = current->acl_role_id;
64736 + tsk->acl = current->acl;
64737 + tsk->role = current->role;
64738 + tsk->signal->curr_ip = current->signal->curr_ip;
64739 + tsk->signal->saved_ip = current->signal->saved_ip;
64740 + if (current->exec_file)
64741 + get_file(current->exec_file);
64742 + tsk->exec_file = current->exec_file;
64743 + tsk->is_writable = current->is_writable;
64744 + if (unlikely(current->signal->used_accept)) {
64745 + current->signal->curr_ip = 0;
64746 + current->signal->saved_ip = 0;
64747 + }
64748 +
64749 + return;
64750 +}
64751 +
64752 +static void
64753 +gr_set_proc_res(struct task_struct *task)
64754 +{
64755 + struct acl_subject_label *proc;
64756 + unsigned short i;
64757 +
64758 + proc = task->acl;
64759 +
64760 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64761 + return;
64762 +
64763 + for (i = 0; i < RLIM_NLIMITS; i++) {
64764 + if (!(proc->resmask & (1U << i)))
64765 + continue;
64766 +
64767 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64768 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64769 +
64770 + if (i == RLIMIT_CPU)
64771 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64772 + }
64773 +
64774 + return;
64775 +}
64776 +
64777 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
64778 +
64779 +int
64780 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64781 +{
64782 + unsigned int i;
64783 + __u16 num;
64784 + uid_t *uidlist;
64785 + uid_t curuid;
64786 + int realok = 0;
64787 + int effectiveok = 0;
64788 + int fsok = 0;
64789 + uid_t globalreal, globaleffective, globalfs;
64790 +
64791 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
64792 + struct user_struct *user;
64793 +
64794 + if (!uid_valid(real))
64795 + goto skipit;
64796 +
64797 + /* find user based on global namespace */
64798 +
64799 + globalreal = GR_GLOBAL_UID(real);
64800 +
64801 + user = find_user(make_kuid(&init_user_ns, globalreal));
64802 + if (user == NULL)
64803 + goto skipit;
64804 +
64805 + if (gr_process_kernel_setuid_ban(user)) {
64806 + /* for find_user */
64807 + free_uid(user);
64808 + return 1;
64809 + }
64810 +
64811 + /* for find_user */
64812 + free_uid(user);
64813 +
64814 +skipit:
64815 +#endif
64816 +
64817 + if (unlikely(!(gr_status & GR_READY)))
64818 + return 0;
64819 +
64820 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64821 + gr_log_learn_uid_change(real, effective, fs);
64822 +
64823 + num = current->acl->user_trans_num;
64824 + uidlist = current->acl->user_transitions;
64825 +
64826 + if (uidlist == NULL)
64827 + return 0;
64828 +
64829 + if (!uid_valid(real)) {
64830 + realok = 1;
64831 + globalreal = (uid_t)-1;
64832 + } else {
64833 + globalreal = GR_GLOBAL_UID(real);
64834 + }
64835 + if (!uid_valid(effective)) {
64836 + effectiveok = 1;
64837 + globaleffective = (uid_t)-1;
64838 + } else {
64839 + globaleffective = GR_GLOBAL_UID(effective);
64840 + }
64841 + if (!uid_valid(fs)) {
64842 + fsok = 1;
64843 + globalfs = (uid_t)-1;
64844 + } else {
64845 + globalfs = GR_GLOBAL_UID(fs);
64846 + }
64847 +
64848 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
64849 + for (i = 0; i < num; i++) {
64850 + curuid = uidlist[i];
64851 + if (globalreal == curuid)
64852 + realok = 1;
64853 + if (globaleffective == curuid)
64854 + effectiveok = 1;
64855 + if (globalfs == curuid)
64856 + fsok = 1;
64857 + }
64858 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
64859 + for (i = 0; i < num; i++) {
64860 + curuid = uidlist[i];
64861 + if (globalreal == curuid)
64862 + break;
64863 + if (globaleffective == curuid)
64864 + break;
64865 + if (globalfs == curuid)
64866 + break;
64867 + }
64868 + /* not in deny list */
64869 + if (i == num) {
64870 + realok = 1;
64871 + effectiveok = 1;
64872 + fsok = 1;
64873 + }
64874 + }
64875 +
64876 + if (realok && effectiveok && fsok)
64877 + return 0;
64878 + else {
64879 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64880 + return 1;
64881 + }
64882 +}
64883 +
64884 +int
64885 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64886 +{
64887 + unsigned int i;
64888 + __u16 num;
64889 + gid_t *gidlist;
64890 + gid_t curgid;
64891 + int realok = 0;
64892 + int effectiveok = 0;
64893 + int fsok = 0;
64894 + gid_t globalreal, globaleffective, globalfs;
64895 +
64896 + if (unlikely(!(gr_status & GR_READY)))
64897 + return 0;
64898 +
64899 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64900 + gr_log_learn_gid_change(real, effective, fs);
64901 +
64902 + num = current->acl->group_trans_num;
64903 + gidlist = current->acl->group_transitions;
64904 +
64905 + if (gidlist == NULL)
64906 + return 0;
64907 +
64908 + if (!gid_valid(real)) {
64909 + realok = 1;
64910 + globalreal = (gid_t)-1;
64911 + } else {
64912 + globalreal = GR_GLOBAL_GID(real);
64913 + }
64914 + if (!gid_valid(effective)) {
64915 + effectiveok = 1;
64916 + globaleffective = (gid_t)-1;
64917 + } else {
64918 + globaleffective = GR_GLOBAL_GID(effective);
64919 + }
64920 + if (!gid_valid(fs)) {
64921 + fsok = 1;
64922 + globalfs = (gid_t)-1;
64923 + } else {
64924 + globalfs = GR_GLOBAL_GID(fs);
64925 + }
64926 +
64927 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
64928 + for (i = 0; i < num; i++) {
64929 + curgid = gidlist[i];
64930 + if (globalreal == curgid)
64931 + realok = 1;
64932 + if (globaleffective == curgid)
64933 + effectiveok = 1;
64934 + if (globalfs == curgid)
64935 + fsok = 1;
64936 + }
64937 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
64938 + for (i = 0; i < num; i++) {
64939 + curgid = gidlist[i];
64940 + if (globalreal == curgid)
64941 + break;
64942 + if (globaleffective == curgid)
64943 + break;
64944 + if (globalfs == curgid)
64945 + break;
64946 + }
64947 + /* not in deny list */
64948 + if (i == num) {
64949 + realok = 1;
64950 + effectiveok = 1;
64951 + fsok = 1;
64952 + }
64953 + }
64954 +
64955 + if (realok && effectiveok && fsok)
64956 + return 0;
64957 + else {
64958 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
64959 + return 1;
64960 + }
64961 +}
64962 +
64963 +extern int gr_acl_is_capable(const int cap);
64964 +
64965 +void
64966 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
64967 +{
64968 + struct acl_role_label *role = task->role;
64969 + struct acl_subject_label *subj = NULL;
64970 + struct acl_object_label *obj;
64971 + struct file *filp;
64972 + uid_t uid;
64973 + gid_t gid;
64974 +
64975 + if (unlikely(!(gr_status & GR_READY)))
64976 + return;
64977 +
64978 + uid = GR_GLOBAL_UID(kuid);
64979 + gid = GR_GLOBAL_GID(kgid);
64980 +
64981 + filp = task->exec_file;
64982 +
64983 + /* kernel process, we'll give them the kernel role */
64984 + if (unlikely(!filp)) {
64985 + task->role = kernel_role;
64986 + task->acl = kernel_role->root_label;
64987 + return;
64988 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
64989 + role = lookup_acl_role_label(task, uid, gid);
64990 +
64991 + /* don't change the role if we're not a privileged process */
64992 + if (role && task->role != role &&
64993 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
64994 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
64995 + return;
64996 +
64997 + /* perform subject lookup in possibly new role
64998 + we can use this result below in the case where role == task->role
64999 + */
65000 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
65001 +
65002 + /* if we changed uid/gid, but result in the same role
65003 + and are using inheritance, don't lose the inherited subject
65004 + if current subject is other than what normal lookup
65005 + would result in, we arrived via inheritance, don't
65006 + lose subject
65007 + */
65008 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
65009 + (subj == task->acl)))
65010 + task->acl = subj;
65011 +
65012 + task->role = role;
65013 +
65014 + task->is_writable = 0;
65015 +
65016 + /* ignore additional mmap checks for processes that are writable
65017 + by the default ACL */
65018 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65019 + if (unlikely(obj->mode & GR_WRITE))
65020 + task->is_writable = 1;
65021 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65022 + if (unlikely(obj->mode & GR_WRITE))
65023 + task->is_writable = 1;
65024 +
65025 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65026 + 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);
65027 +#endif
65028 +
65029 + gr_set_proc_res(task);
65030 +
65031 + return;
65032 +}
65033 +
65034 +int
65035 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
65036 + const int unsafe_flags)
65037 +{
65038 + struct task_struct *task = current;
65039 + struct acl_subject_label *newacl;
65040 + struct acl_object_label *obj;
65041 + __u32 retmode;
65042 +
65043 + if (unlikely(!(gr_status & GR_READY)))
65044 + return 0;
65045 +
65046 + newacl = chk_subj_label(dentry, mnt, task->role);
65047 +
65048 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
65049 + did an exec
65050 + */
65051 + rcu_read_lock();
65052 + read_lock(&tasklist_lock);
65053 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
65054 + (task->parent->acl->mode & GR_POVERRIDE))) {
65055 + read_unlock(&tasklist_lock);
65056 + rcu_read_unlock();
65057 + goto skip_check;
65058 + }
65059 + read_unlock(&tasklist_lock);
65060 + rcu_read_unlock();
65061 +
65062 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
65063 + !(task->role->roletype & GR_ROLE_GOD) &&
65064 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
65065 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65066 + if (unsafe_flags & LSM_UNSAFE_SHARE)
65067 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
65068 + else
65069 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
65070 + return -EACCES;
65071 + }
65072 +
65073 +skip_check:
65074 +
65075 + obj = chk_obj_label(dentry, mnt, task->acl);
65076 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
65077 +
65078 + if (!(task->acl->mode & GR_INHERITLEARN) &&
65079 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
65080 + if (obj->nested)
65081 + task->acl = obj->nested;
65082 + else
65083 + task->acl = newacl;
65084 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
65085 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
65086 +
65087 + task->is_writable = 0;
65088 +
65089 + /* ignore additional mmap checks for processes that are writable
65090 + by the default ACL */
65091 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
65092 + if (unlikely(obj->mode & GR_WRITE))
65093 + task->is_writable = 1;
65094 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
65095 + if (unlikely(obj->mode & GR_WRITE))
65096 + task->is_writable = 1;
65097 +
65098 + gr_set_proc_res(task);
65099 +
65100 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65101 + 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);
65102 +#endif
65103 + return 0;
65104 +}
65105 +
65106 +/* always called with valid inodev ptr */
65107 +static void
65108 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
65109 +{
65110 + struct acl_object_label *matchpo;
65111 + struct acl_subject_label *matchps;
65112 + struct acl_subject_label *subj;
65113 + struct acl_role_label *role;
65114 + unsigned int x;
65115 +
65116 + FOR_EACH_ROLE_START(role)
65117 + FOR_EACH_SUBJECT_START(role, subj, x)
65118 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65119 + matchpo->mode |= GR_DELETED;
65120 + FOR_EACH_SUBJECT_END(subj,x)
65121 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65122 + /* nested subjects aren't in the role's subj_hash table */
65123 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65124 + matchpo->mode |= GR_DELETED;
65125 + FOR_EACH_NESTED_SUBJECT_END(subj)
65126 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
65127 + matchps->mode |= GR_DELETED;
65128 + FOR_EACH_ROLE_END(role)
65129 +
65130 + inodev->nentry->deleted = 1;
65131 +
65132 + return;
65133 +}
65134 +
65135 +void
65136 +gr_handle_delete(const ino_t ino, const dev_t dev)
65137 +{
65138 + struct inodev_entry *inodev;
65139 +
65140 + if (unlikely(!(gr_status & GR_READY)))
65141 + return;
65142 +
65143 + write_lock(&gr_inode_lock);
65144 + inodev = lookup_inodev_entry(ino, dev);
65145 + if (inodev != NULL)
65146 + do_handle_delete(inodev, ino, dev);
65147 + write_unlock(&gr_inode_lock);
65148 +
65149 + return;
65150 +}
65151 +
65152 +static void
65153 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
65154 + const ino_t newinode, const dev_t newdevice,
65155 + struct acl_subject_label *subj)
65156 +{
65157 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
65158 + struct acl_object_label *match;
65159 +
65160 + match = subj->obj_hash[index];
65161 +
65162 + while (match && (match->inode != oldinode ||
65163 + match->device != olddevice ||
65164 + !(match->mode & GR_DELETED)))
65165 + match = match->next;
65166 +
65167 + if (match && (match->inode == oldinode)
65168 + && (match->device == olddevice)
65169 + && (match->mode & GR_DELETED)) {
65170 + if (match->prev == NULL) {
65171 + subj->obj_hash[index] = match->next;
65172 + if (match->next != NULL)
65173 + match->next->prev = NULL;
65174 + } else {
65175 + match->prev->next = match->next;
65176 + if (match->next != NULL)
65177 + match->next->prev = match->prev;
65178 + }
65179 + match->prev = NULL;
65180 + match->next = NULL;
65181 + match->inode = newinode;
65182 + match->device = newdevice;
65183 + match->mode &= ~GR_DELETED;
65184 +
65185 + insert_acl_obj_label(match, subj);
65186 + }
65187 +
65188 + return;
65189 +}
65190 +
65191 +static void
65192 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65193 + const ino_t newinode, const dev_t newdevice,
65194 + struct acl_role_label *role)
65195 +{
65196 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65197 + struct acl_subject_label *match;
65198 +
65199 + match = role->subj_hash[index];
65200 +
65201 + while (match && (match->inode != oldinode ||
65202 + match->device != olddevice ||
65203 + !(match->mode & GR_DELETED)))
65204 + match = match->next;
65205 +
65206 + if (match && (match->inode == oldinode)
65207 + && (match->device == olddevice)
65208 + && (match->mode & GR_DELETED)) {
65209 + if (match->prev == NULL) {
65210 + role->subj_hash[index] = match->next;
65211 + if (match->next != NULL)
65212 + match->next->prev = NULL;
65213 + } else {
65214 + match->prev->next = match->next;
65215 + if (match->next != NULL)
65216 + match->next->prev = match->prev;
65217 + }
65218 + match->prev = NULL;
65219 + match->next = NULL;
65220 + match->inode = newinode;
65221 + match->device = newdevice;
65222 + match->mode &= ~GR_DELETED;
65223 +
65224 + insert_acl_subj_label(match, role);
65225 + }
65226 +
65227 + return;
65228 +}
65229 +
65230 +static void
65231 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65232 + const ino_t newinode, const dev_t newdevice)
65233 +{
65234 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
65235 + struct inodev_entry *match;
65236 +
65237 + match = inodev_set.i_hash[index];
65238 +
65239 + while (match && (match->nentry->inode != oldinode ||
65240 + match->nentry->device != olddevice || !match->nentry->deleted))
65241 + match = match->next;
65242 +
65243 + if (match && (match->nentry->inode == oldinode)
65244 + && (match->nentry->device == olddevice) &&
65245 + match->nentry->deleted) {
65246 + if (match->prev == NULL) {
65247 + inodev_set.i_hash[index] = match->next;
65248 + if (match->next != NULL)
65249 + match->next->prev = NULL;
65250 + } else {
65251 + match->prev->next = match->next;
65252 + if (match->next != NULL)
65253 + match->next->prev = match->prev;
65254 + }
65255 + match->prev = NULL;
65256 + match->next = NULL;
65257 + match->nentry->inode = newinode;
65258 + match->nentry->device = newdevice;
65259 + match->nentry->deleted = 0;
65260 +
65261 + insert_inodev_entry(match);
65262 + }
65263 +
65264 + return;
65265 +}
65266 +
65267 +static void
65268 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65269 +{
65270 + struct acl_subject_label *subj;
65271 + struct acl_role_label *role;
65272 + unsigned int x;
65273 +
65274 + FOR_EACH_ROLE_START(role)
65275 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65276 +
65277 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65278 + if ((subj->inode == ino) && (subj->device == dev)) {
65279 + subj->inode = ino;
65280 + subj->device = dev;
65281 + }
65282 + /* nested subjects aren't in the role's subj_hash table */
65283 + update_acl_obj_label(matchn->inode, matchn->device,
65284 + ino, dev, subj);
65285 + FOR_EACH_NESTED_SUBJECT_END(subj)
65286 + FOR_EACH_SUBJECT_START(role, subj, x)
65287 + update_acl_obj_label(matchn->inode, matchn->device,
65288 + ino, dev, subj);
65289 + FOR_EACH_SUBJECT_END(subj,x)
65290 + FOR_EACH_ROLE_END(role)
65291 +
65292 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65293 +
65294 + return;
65295 +}
65296 +
65297 +static void
65298 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65299 + const struct vfsmount *mnt)
65300 +{
65301 + ino_t ino = dentry->d_inode->i_ino;
65302 + dev_t dev = __get_dev(dentry);
65303 +
65304 + __do_handle_create(matchn, ino, dev);
65305 +
65306 + return;
65307 +}
65308 +
65309 +void
65310 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65311 +{
65312 + struct name_entry *matchn;
65313 +
65314 + if (unlikely(!(gr_status & GR_READY)))
65315 + return;
65316 +
65317 + preempt_disable();
65318 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65319 +
65320 + if (unlikely((unsigned long)matchn)) {
65321 + write_lock(&gr_inode_lock);
65322 + do_handle_create(matchn, dentry, mnt);
65323 + write_unlock(&gr_inode_lock);
65324 + }
65325 + preempt_enable();
65326 +
65327 + return;
65328 +}
65329 +
65330 +void
65331 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65332 +{
65333 + struct name_entry *matchn;
65334 +
65335 + if (unlikely(!(gr_status & GR_READY)))
65336 + return;
65337 +
65338 + preempt_disable();
65339 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65340 +
65341 + if (unlikely((unsigned long)matchn)) {
65342 + write_lock(&gr_inode_lock);
65343 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65344 + write_unlock(&gr_inode_lock);
65345 + }
65346 + preempt_enable();
65347 +
65348 + return;
65349 +}
65350 +
65351 +void
65352 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65353 + struct dentry *old_dentry,
65354 + struct dentry *new_dentry,
65355 + struct vfsmount *mnt, const __u8 replace)
65356 +{
65357 + struct name_entry *matchn;
65358 + struct inodev_entry *inodev;
65359 + struct inode *inode = new_dentry->d_inode;
65360 + ino_t old_ino = old_dentry->d_inode->i_ino;
65361 + dev_t old_dev = __get_dev(old_dentry);
65362 +
65363 + /* vfs_rename swaps the name and parent link for old_dentry and
65364 + new_dentry
65365 + at this point, old_dentry has the new name, parent link, and inode
65366 + for the renamed file
65367 + if a file is being replaced by a rename, new_dentry has the inode
65368 + and name for the replaced file
65369 + */
65370 +
65371 + if (unlikely(!(gr_status & GR_READY)))
65372 + return;
65373 +
65374 + preempt_disable();
65375 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65376 +
65377 + /* we wouldn't have to check d_inode if it weren't for
65378 + NFS silly-renaming
65379 + */
65380 +
65381 + write_lock(&gr_inode_lock);
65382 + if (unlikely(replace && inode)) {
65383 + ino_t new_ino = inode->i_ino;
65384 + dev_t new_dev = __get_dev(new_dentry);
65385 +
65386 + inodev = lookup_inodev_entry(new_ino, new_dev);
65387 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65388 + do_handle_delete(inodev, new_ino, new_dev);
65389 + }
65390 +
65391 + inodev = lookup_inodev_entry(old_ino, old_dev);
65392 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65393 + do_handle_delete(inodev, old_ino, old_dev);
65394 +
65395 + if (unlikely((unsigned long)matchn))
65396 + do_handle_create(matchn, old_dentry, mnt);
65397 +
65398 + write_unlock(&gr_inode_lock);
65399 + preempt_enable();
65400 +
65401 + return;
65402 +}
65403 +
65404 +static int
65405 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
65406 + unsigned char **sum)
65407 +{
65408 + struct acl_role_label *r;
65409 + struct role_allowed_ip *ipp;
65410 + struct role_transition *trans;
65411 + unsigned int i;
65412 + int found = 0;
65413 + u32 curr_ip = current->signal->curr_ip;
65414 +
65415 + current->signal->saved_ip = curr_ip;
65416 +
65417 + /* check transition table */
65418 +
65419 + for (trans = current->role->transitions; trans; trans = trans->next) {
65420 + if (!strcmp(rolename, trans->rolename)) {
65421 + found = 1;
65422 + break;
65423 + }
65424 + }
65425 +
65426 + if (!found)
65427 + return 0;
65428 +
65429 + /* handle special roles that do not require authentication
65430 + and check ip */
65431 +
65432 + FOR_EACH_ROLE_START(r)
65433 + if (!strcmp(rolename, r->rolename) &&
65434 + (r->roletype & GR_ROLE_SPECIAL)) {
65435 + found = 0;
65436 + if (r->allowed_ips != NULL) {
65437 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
65438 + if ((ntohl(curr_ip) & ipp->netmask) ==
65439 + (ntohl(ipp->addr) & ipp->netmask))
65440 + found = 1;
65441 + }
65442 + } else
65443 + found = 2;
65444 + if (!found)
65445 + return 0;
65446 +
65447 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
65448 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
65449 + *salt = NULL;
65450 + *sum = NULL;
65451 + return 1;
65452 + }
65453 + }
65454 + FOR_EACH_ROLE_END(r)
65455 +
65456 + for (i = 0; i < num_sprole_pws; i++) {
65457 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
65458 + *salt = acl_special_roles[i]->salt;
65459 + *sum = acl_special_roles[i]->sum;
65460 + return 1;
65461 + }
65462 + }
65463 +
65464 + return 0;
65465 +}
65466 +
65467 +static void
65468 +assign_special_role(char *rolename)
65469 +{
65470 + struct acl_object_label *obj;
65471 + struct acl_role_label *r;
65472 + struct acl_role_label *assigned = NULL;
65473 + struct task_struct *tsk;
65474 + struct file *filp;
65475 +
65476 + FOR_EACH_ROLE_START(r)
65477 + if (!strcmp(rolename, r->rolename) &&
65478 + (r->roletype & GR_ROLE_SPECIAL)) {
65479 + assigned = r;
65480 + break;
65481 + }
65482 + FOR_EACH_ROLE_END(r)
65483 +
65484 + if (!assigned)
65485 + return;
65486 +
65487 + read_lock(&tasklist_lock);
65488 + read_lock(&grsec_exec_file_lock);
65489 +
65490 + tsk = current->real_parent;
65491 + if (tsk == NULL)
65492 + goto out_unlock;
65493 +
65494 + filp = tsk->exec_file;
65495 + if (filp == NULL)
65496 + goto out_unlock;
65497 +
65498 + tsk->is_writable = 0;
65499 +
65500 + tsk->acl_sp_role = 1;
65501 + tsk->acl_role_id = ++acl_sp_role_value;
65502 + tsk->role = assigned;
65503 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
65504 +
65505 + /* ignore additional mmap checks for processes that are writable
65506 + by the default ACL */
65507 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65508 + if (unlikely(obj->mode & GR_WRITE))
65509 + tsk->is_writable = 1;
65510 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
65511 + if (unlikely(obj->mode & GR_WRITE))
65512 + tsk->is_writable = 1;
65513 +
65514 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65515 + 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));
65516 +#endif
65517 +
65518 +out_unlock:
65519 + read_unlock(&grsec_exec_file_lock);
65520 + read_unlock(&tasklist_lock);
65521 + return;
65522 +}
65523 +
65524 +int gr_check_secure_terminal(struct task_struct *task)
65525 +{
65526 + struct task_struct *p, *p2, *p3;
65527 + struct files_struct *files;
65528 + struct fdtable *fdt;
65529 + struct file *our_file = NULL, *file;
65530 + int i;
65531 +
65532 + if (task->signal->tty == NULL)
65533 + return 1;
65534 +
65535 + files = get_files_struct(task);
65536 + if (files != NULL) {
65537 + rcu_read_lock();
65538 + fdt = files_fdtable(files);
65539 + for (i=0; i < fdt->max_fds; i++) {
65540 + file = fcheck_files(files, i);
65541 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
65542 + get_file(file);
65543 + our_file = file;
65544 + }
65545 + }
65546 + rcu_read_unlock();
65547 + put_files_struct(files);
65548 + }
65549 +
65550 + if (our_file == NULL)
65551 + return 1;
65552 +
65553 + read_lock(&tasklist_lock);
65554 + do_each_thread(p2, p) {
65555 + files = get_files_struct(p);
65556 + if (files == NULL ||
65557 + (p->signal && p->signal->tty == task->signal->tty)) {
65558 + if (files != NULL)
65559 + put_files_struct(files);
65560 + continue;
65561 + }
65562 + rcu_read_lock();
65563 + fdt = files_fdtable(files);
65564 + for (i=0; i < fdt->max_fds; i++) {
65565 + file = fcheck_files(files, i);
65566 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
65567 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
65568 + p3 = task;
65569 + while (task_pid_nr(p3) > 0) {
65570 + if (p3 == p)
65571 + break;
65572 + p3 = p3->real_parent;
65573 + }
65574 + if (p3 == p)
65575 + break;
65576 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
65577 + gr_handle_alertkill(p);
65578 + rcu_read_unlock();
65579 + put_files_struct(files);
65580 + read_unlock(&tasklist_lock);
65581 + fput(our_file);
65582 + return 0;
65583 + }
65584 + }
65585 + rcu_read_unlock();
65586 + put_files_struct(files);
65587 + } while_each_thread(p2, p);
65588 + read_unlock(&tasklist_lock);
65589 +
65590 + fput(our_file);
65591 + return 1;
65592 +}
65593 +
65594 +static int gr_rbac_disable(void *unused)
65595 +{
65596 + pax_open_kernel();
65597 + gr_status &= ~GR_READY;
65598 + pax_close_kernel();
65599 +
65600 + return 0;
65601 +}
65602 +
65603 +ssize_t
65604 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
65605 +{
65606 + struct gr_arg_wrapper uwrap;
65607 + unsigned char *sprole_salt = NULL;
65608 + unsigned char *sprole_sum = NULL;
65609 + int error = 0;
65610 + int error2 = 0;
65611 + size_t req_count = 0;
65612 +
65613 + mutex_lock(&gr_dev_mutex);
65614 +
65615 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
65616 + error = -EPERM;
65617 + goto out;
65618 + }
65619 +
65620 +#ifdef CONFIG_COMPAT
65621 + pax_open_kernel();
65622 + if (is_compat_task()) {
65623 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
65624 + copy_gr_arg = &copy_gr_arg_compat;
65625 + copy_acl_object_label = &copy_acl_object_label_compat;
65626 + copy_acl_subject_label = &copy_acl_subject_label_compat;
65627 + copy_acl_role_label = &copy_acl_role_label_compat;
65628 + copy_acl_ip_label = &copy_acl_ip_label_compat;
65629 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
65630 + copy_role_transition = &copy_role_transition_compat;
65631 + copy_sprole_pw = &copy_sprole_pw_compat;
65632 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
65633 + copy_pointer_from_array = &copy_pointer_from_array_compat;
65634 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
65635 + } else {
65636 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
65637 + copy_gr_arg = &copy_gr_arg_normal;
65638 + copy_acl_object_label = &copy_acl_object_label_normal;
65639 + copy_acl_subject_label = &copy_acl_subject_label_normal;
65640 + copy_acl_role_label = &copy_acl_role_label_normal;
65641 + copy_acl_ip_label = &copy_acl_ip_label_normal;
65642 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
65643 + copy_role_transition = &copy_role_transition_normal;
65644 + copy_sprole_pw = &copy_sprole_pw_normal;
65645 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
65646 + copy_pointer_from_array = &copy_pointer_from_array_normal;
65647 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
65648 + }
65649 + pax_close_kernel();
65650 +#endif
65651 +
65652 + req_count = get_gr_arg_wrapper_size();
65653 +
65654 + if (count != req_count) {
65655 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
65656 + error = -EINVAL;
65657 + goto out;
65658 + }
65659 +
65660 +
65661 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
65662 + gr_auth_expires = 0;
65663 + gr_auth_attempts = 0;
65664 + }
65665 +
65666 + error = copy_gr_arg_wrapper(buf, &uwrap);
65667 + if (error)
65668 + goto out;
65669 +
65670 + error = copy_gr_arg(uwrap.arg, gr_usermode);
65671 + if (error)
65672 + goto out;
65673 +
65674 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65675 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65676 + time_after(gr_auth_expires, get_seconds())) {
65677 + error = -EBUSY;
65678 + goto out;
65679 + }
65680 +
65681 + /* if non-root trying to do anything other than use a special role,
65682 + do not attempt authentication, do not count towards authentication
65683 + locking
65684 + */
65685 +
65686 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
65687 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
65688 + gr_is_global_nonroot(current_uid())) {
65689 + error = -EPERM;
65690 + goto out;
65691 + }
65692 +
65693 + /* ensure pw and special role name are null terminated */
65694 +
65695 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
65696 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
65697 +
65698 + /* Okay.
65699 + * We have our enough of the argument structure..(we have yet
65700 + * to copy_from_user the tables themselves) . Copy the tables
65701 + * only if we need them, i.e. for loading operations. */
65702 +
65703 + switch (gr_usermode->mode) {
65704 + case GR_STATUS:
65705 + if (gr_status & GR_READY) {
65706 + error = 1;
65707 + if (!gr_check_secure_terminal(current))
65708 + error = 3;
65709 + } else
65710 + error = 2;
65711 + goto out;
65712 + case GR_SHUTDOWN:
65713 + if ((gr_status & GR_READY)
65714 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65715 + stop_machine(gr_rbac_disable, NULL, NULL);
65716 + free_variables();
65717 + memset(gr_usermode, 0, sizeof (struct gr_arg));
65718 + memset(gr_system_salt, 0, GR_SALT_LEN);
65719 + memset(gr_system_sum, 0, GR_SHA_LEN);
65720 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
65721 + } else if (gr_status & GR_READY) {
65722 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
65723 + error = -EPERM;
65724 + } else {
65725 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
65726 + error = -EAGAIN;
65727 + }
65728 + break;
65729 + case GR_ENABLE:
65730 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
65731 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
65732 + else {
65733 + if (gr_status & GR_READY)
65734 + error = -EAGAIN;
65735 + else
65736 + error = error2;
65737 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
65738 + }
65739 + break;
65740 + case GR_RELOAD:
65741 + if (!(gr_status & GR_READY)) {
65742 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
65743 + error = -EAGAIN;
65744 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65745 + stop_machine(gr_rbac_disable, NULL, NULL);
65746 + free_variables();
65747 + error2 = gracl_init(gr_usermode);
65748 + if (!error2)
65749 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
65750 + else {
65751 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65752 + error = error2;
65753 + }
65754 + } else {
65755 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
65756 + error = -EPERM;
65757 + }
65758 + break;
65759 + case GR_SEGVMOD:
65760 + if (unlikely(!(gr_status & GR_READY))) {
65761 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
65762 + error = -EAGAIN;
65763 + break;
65764 + }
65765 +
65766 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
65767 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
65768 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
65769 + struct acl_subject_label *segvacl;
65770 + segvacl =
65771 + lookup_acl_subj_label(gr_usermode->segv_inode,
65772 + gr_usermode->segv_device,
65773 + current->role);
65774 + if (segvacl) {
65775 + segvacl->crashes = 0;
65776 + segvacl->expires = 0;
65777 + }
65778 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
65779 + gr_remove_uid(gr_usermode->segv_uid);
65780 + }
65781 + } else {
65782 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
65783 + error = -EPERM;
65784 + }
65785 + break;
65786 + case GR_SPROLE:
65787 + case GR_SPROLEPAM:
65788 + if (unlikely(!(gr_status & GR_READY))) {
65789 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
65790 + error = -EAGAIN;
65791 + break;
65792 + }
65793 +
65794 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
65795 + current->role->expires = 0;
65796 + current->role->auth_attempts = 0;
65797 + }
65798 +
65799 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
65800 + time_after(current->role->expires, get_seconds())) {
65801 + error = -EBUSY;
65802 + goto out;
65803 + }
65804 +
65805 + if (lookup_special_role_auth
65806 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
65807 + && ((!sprole_salt && !sprole_sum)
65808 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
65809 + char *p = "";
65810 + assign_special_role(gr_usermode->sp_role);
65811 + read_lock(&tasklist_lock);
65812 + if (current->real_parent)
65813 + p = current->real_parent->role->rolename;
65814 + read_unlock(&tasklist_lock);
65815 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
65816 + p, acl_sp_role_value);
65817 + } else {
65818 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
65819 + error = -EPERM;
65820 + if(!(current->role->auth_attempts++))
65821 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65822 +
65823 + goto out;
65824 + }
65825 + break;
65826 + case GR_UNSPROLE:
65827 + if (unlikely(!(gr_status & GR_READY))) {
65828 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
65829 + error = -EAGAIN;
65830 + break;
65831 + }
65832 +
65833 + if (current->role->roletype & GR_ROLE_SPECIAL) {
65834 + char *p = "";
65835 + int i = 0;
65836 +
65837 + read_lock(&tasklist_lock);
65838 + if (current->real_parent) {
65839 + p = current->real_parent->role->rolename;
65840 + i = current->real_parent->acl_role_id;
65841 + }
65842 + read_unlock(&tasklist_lock);
65843 +
65844 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
65845 + gr_set_acls(1);
65846 + } else {
65847 + error = -EPERM;
65848 + goto out;
65849 + }
65850 + break;
65851 + default:
65852 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
65853 + error = -EINVAL;
65854 + break;
65855 + }
65856 +
65857 + if (error != -EPERM)
65858 + goto out;
65859 +
65860 + if(!(gr_auth_attempts++))
65861 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
65862 +
65863 + out:
65864 + mutex_unlock(&gr_dev_mutex);
65865 +
65866 + if (!error)
65867 + error = req_count;
65868 +
65869 + return error;
65870 +}
65871 +
65872 +/* must be called with
65873 + rcu_read_lock();
65874 + read_lock(&tasklist_lock);
65875 + read_lock(&grsec_exec_file_lock);
65876 +*/
65877 +int gr_apply_subject_to_task(struct task_struct *task)
65878 +{
65879 + struct acl_object_label *obj;
65880 + char *tmpname;
65881 + struct acl_subject_label *tmpsubj;
65882 + struct file *filp;
65883 + struct name_entry *nmatch;
65884 +
65885 + filp = task->exec_file;
65886 + if (filp == NULL)
65887 + return 0;
65888 +
65889 + /* the following is to apply the correct subject
65890 + on binaries running when the RBAC system
65891 + is enabled, when the binaries have been
65892 + replaced or deleted since their execution
65893 + -----
65894 + when the RBAC system starts, the inode/dev
65895 + from exec_file will be one the RBAC system
65896 + is unaware of. It only knows the inode/dev
65897 + of the present file on disk, or the absence
65898 + of it.
65899 + */
65900 + preempt_disable();
65901 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
65902 +
65903 + nmatch = lookup_name_entry(tmpname);
65904 + preempt_enable();
65905 + tmpsubj = NULL;
65906 + if (nmatch) {
65907 + if (nmatch->deleted)
65908 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
65909 + else
65910 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
65911 + if (tmpsubj != NULL)
65912 + task->acl = tmpsubj;
65913 + }
65914 + if (tmpsubj == NULL)
65915 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
65916 + task->role);
65917 + if (task->acl) {
65918 + task->is_writable = 0;
65919 + /* ignore additional mmap checks for processes that are writable
65920 + by the default ACL */
65921 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
65922 + if (unlikely(obj->mode & GR_WRITE))
65923 + task->is_writable = 1;
65924 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65925 + if (unlikely(obj->mode & GR_WRITE))
65926 + task->is_writable = 1;
65927 +
65928 + gr_set_proc_res(task);
65929 +
65930 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65931 + 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);
65932 +#endif
65933 + } else {
65934 + return 1;
65935 + }
65936 +
65937 + return 0;
65938 +}
65939 +
65940 +int
65941 +gr_set_acls(const int type)
65942 +{
65943 + struct task_struct *task, *task2;
65944 + struct acl_role_label *role = current->role;
65945 + __u16 acl_role_id = current->acl_role_id;
65946 + const struct cred *cred;
65947 + int ret;
65948 +
65949 + rcu_read_lock();
65950 + read_lock(&tasklist_lock);
65951 + read_lock(&grsec_exec_file_lock);
65952 + do_each_thread(task2, task) {
65953 + /* check to see if we're called from the exit handler,
65954 + if so, only replace ACLs that have inherited the admin
65955 + ACL */
65956 +
65957 + if (type && (task->role != role ||
65958 + task->acl_role_id != acl_role_id))
65959 + continue;
65960 +
65961 + task->acl_role_id = 0;
65962 + task->acl_sp_role = 0;
65963 +
65964 + if (task->exec_file) {
65965 + cred = __task_cred(task);
65966 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
65967 + ret = gr_apply_subject_to_task(task);
65968 + if (ret) {
65969 + read_unlock(&grsec_exec_file_lock);
65970 + read_unlock(&tasklist_lock);
65971 + rcu_read_unlock();
65972 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
65973 + return ret;
65974 + }
65975 + } else {
65976 + // it's a kernel process
65977 + task->role = kernel_role;
65978 + task->acl = kernel_role->root_label;
65979 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
65980 + task->acl->mode &= ~GR_PROCFIND;
65981 +#endif
65982 + }
65983 + } while_each_thread(task2, task);
65984 + read_unlock(&grsec_exec_file_lock);
65985 + read_unlock(&tasklist_lock);
65986 + rcu_read_unlock();
65987 +
65988 + return 0;
65989 +}
65990 +
65991 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65992 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65993 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65994 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65995 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65996 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65997 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65998 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65999 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
66000 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
66001 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
66002 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
66003 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
66004 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
66005 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
66006 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
66007 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
66008 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
66009 +};
66010 +
66011 +void
66012 +gr_learn_resource(const struct task_struct *task,
66013 + const int res, const unsigned long wanted, const int gt)
66014 +{
66015 + struct acl_subject_label *acl;
66016 + const struct cred *cred;
66017 +
66018 + if (unlikely((gr_status & GR_READY) &&
66019 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
66020 + goto skip_reslog;
66021 +
66022 + gr_log_resource(task, res, wanted, gt);
66023 +skip_reslog:
66024 +
66025 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
66026 + return;
66027 +
66028 + acl = task->acl;
66029 +
66030 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
66031 + !(acl->resmask & (1U << (unsigned short) res))))
66032 + return;
66033 +
66034 + if (wanted >= acl->res[res].rlim_cur) {
66035 + unsigned long res_add;
66036 +
66037 + res_add = wanted + res_learn_bumps[res];
66038 +
66039 + acl->res[res].rlim_cur = res_add;
66040 +
66041 + if (wanted > acl->res[res].rlim_max)
66042 + acl->res[res].rlim_max = res_add;
66043 +
66044 + /* only log the subject filename, since resource logging is supported for
66045 + single-subject learning only */
66046 + rcu_read_lock();
66047 + cred = __task_cred(task);
66048 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66049 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
66050 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
66051 + "", (unsigned long) res, &task->signal->saved_ip);
66052 + rcu_read_unlock();
66053 + }
66054 +
66055 + return;
66056 +}
66057 +EXPORT_SYMBOL(gr_learn_resource);
66058 +#endif
66059 +
66060 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
66061 +void
66062 +pax_set_initial_flags(struct linux_binprm *bprm)
66063 +{
66064 + struct task_struct *task = current;
66065 + struct acl_subject_label *proc;
66066 + unsigned long flags;
66067 +
66068 + if (unlikely(!(gr_status & GR_READY)))
66069 + return;
66070 +
66071 + flags = pax_get_flags(task);
66072 +
66073 + proc = task->acl;
66074 +
66075 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
66076 + flags &= ~MF_PAX_PAGEEXEC;
66077 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
66078 + flags &= ~MF_PAX_SEGMEXEC;
66079 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
66080 + flags &= ~MF_PAX_RANDMMAP;
66081 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
66082 + flags &= ~MF_PAX_EMUTRAMP;
66083 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
66084 + flags &= ~MF_PAX_MPROTECT;
66085 +
66086 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
66087 + flags |= MF_PAX_PAGEEXEC;
66088 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
66089 + flags |= MF_PAX_SEGMEXEC;
66090 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
66091 + flags |= MF_PAX_RANDMMAP;
66092 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
66093 + flags |= MF_PAX_EMUTRAMP;
66094 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
66095 + flags |= MF_PAX_MPROTECT;
66096 +
66097 + pax_set_flags(task, flags);
66098 +
66099 + return;
66100 +}
66101 +#endif
66102 +
66103 +int
66104 +gr_handle_proc_ptrace(struct task_struct *task)
66105 +{
66106 + struct file *filp;
66107 + struct task_struct *tmp = task;
66108 + struct task_struct *curtemp = current;
66109 + __u32 retmode;
66110 +
66111 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66112 + if (unlikely(!(gr_status & GR_READY)))
66113 + return 0;
66114 +#endif
66115 +
66116 + read_lock(&tasklist_lock);
66117 + read_lock(&grsec_exec_file_lock);
66118 + filp = task->exec_file;
66119 +
66120 + while (task_pid_nr(tmp) > 0) {
66121 + if (tmp == curtemp)
66122 + break;
66123 + tmp = tmp->real_parent;
66124 + }
66125 +
66126 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66127 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
66128 + read_unlock(&grsec_exec_file_lock);
66129 + read_unlock(&tasklist_lock);
66130 + return 1;
66131 + }
66132 +
66133 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66134 + if (!(gr_status & GR_READY)) {
66135 + read_unlock(&grsec_exec_file_lock);
66136 + read_unlock(&tasklist_lock);
66137 + return 0;
66138 + }
66139 +#endif
66140 +
66141 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
66142 + read_unlock(&grsec_exec_file_lock);
66143 + read_unlock(&tasklist_lock);
66144 +
66145 + if (retmode & GR_NOPTRACE)
66146 + return 1;
66147 +
66148 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
66149 + && (current->acl != task->acl || (current->acl != current->role->root_label
66150 + && task_pid_nr(current) != task_pid_nr(task))))
66151 + return 1;
66152 +
66153 + return 0;
66154 +}
66155 +
66156 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
66157 +{
66158 + if (unlikely(!(gr_status & GR_READY)))
66159 + return;
66160 +
66161 + if (!(current->role->roletype & GR_ROLE_GOD))
66162 + return;
66163 +
66164 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
66165 + p->role->rolename, gr_task_roletype_to_char(p),
66166 + p->acl->filename);
66167 +}
66168 +
66169 +int
66170 +gr_handle_ptrace(struct task_struct *task, const long request)
66171 +{
66172 + struct task_struct *tmp = task;
66173 + struct task_struct *curtemp = current;
66174 + __u32 retmode;
66175 +
66176 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66177 + if (unlikely(!(gr_status & GR_READY)))
66178 + return 0;
66179 +#endif
66180 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66181 + read_lock(&tasklist_lock);
66182 + while (task_pid_nr(tmp) > 0) {
66183 + if (tmp == curtemp)
66184 + break;
66185 + tmp = tmp->real_parent;
66186 + }
66187 +
66188 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66189 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66190 + read_unlock(&tasklist_lock);
66191 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66192 + return 1;
66193 + }
66194 + read_unlock(&tasklist_lock);
66195 + }
66196 +
66197 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66198 + if (!(gr_status & GR_READY))
66199 + return 0;
66200 +#endif
66201 +
66202 + read_lock(&grsec_exec_file_lock);
66203 + if (unlikely(!task->exec_file)) {
66204 + read_unlock(&grsec_exec_file_lock);
66205 + return 0;
66206 + }
66207 +
66208 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66209 + read_unlock(&grsec_exec_file_lock);
66210 +
66211 + if (retmode & GR_NOPTRACE) {
66212 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66213 + return 1;
66214 + }
66215 +
66216 + if (retmode & GR_PTRACERD) {
66217 + switch (request) {
66218 + case PTRACE_SEIZE:
66219 + case PTRACE_POKETEXT:
66220 + case PTRACE_POKEDATA:
66221 + case PTRACE_POKEUSR:
66222 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66223 + case PTRACE_SETREGS:
66224 + case PTRACE_SETFPREGS:
66225 +#endif
66226 +#ifdef CONFIG_X86
66227 + case PTRACE_SETFPXREGS:
66228 +#endif
66229 +#ifdef CONFIG_ALTIVEC
66230 + case PTRACE_SETVRREGS:
66231 +#endif
66232 + return 1;
66233 + default:
66234 + return 0;
66235 + }
66236 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66237 + !(current->role->roletype & GR_ROLE_GOD) &&
66238 + (current->acl != task->acl)) {
66239 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66240 + return 1;
66241 + }
66242 +
66243 + return 0;
66244 +}
66245 +
66246 +static int is_writable_mmap(const struct file *filp)
66247 +{
66248 + struct task_struct *task = current;
66249 + struct acl_object_label *obj, *obj2;
66250 +
66251 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66252 + !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))) {
66253 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
66254 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66255 + task->role->root_label);
66256 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66257 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66258 + return 1;
66259 + }
66260 + }
66261 + return 0;
66262 +}
66263 +
66264 +int
66265 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66266 +{
66267 + __u32 mode;
66268 +
66269 + if (unlikely(!file || !(prot & PROT_EXEC)))
66270 + return 1;
66271 +
66272 + if (is_writable_mmap(file))
66273 + return 0;
66274 +
66275 + mode =
66276 + gr_search_file(file->f_path.dentry,
66277 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66278 + file->f_path.mnt);
66279 +
66280 + if (!gr_tpe_allow(file))
66281 + return 0;
66282 +
66283 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66284 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66285 + return 0;
66286 + } else if (unlikely(!(mode & GR_EXEC))) {
66287 + return 0;
66288 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66289 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66290 + return 1;
66291 + }
66292 +
66293 + return 1;
66294 +}
66295 +
66296 +int
66297 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66298 +{
66299 + __u32 mode;
66300 +
66301 + if (unlikely(!file || !(prot & PROT_EXEC)))
66302 + return 1;
66303 +
66304 + if (is_writable_mmap(file))
66305 + return 0;
66306 +
66307 + mode =
66308 + gr_search_file(file->f_path.dentry,
66309 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66310 + file->f_path.mnt);
66311 +
66312 + if (!gr_tpe_allow(file))
66313 + return 0;
66314 +
66315 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66316 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66317 + return 0;
66318 + } else if (unlikely(!(mode & GR_EXEC))) {
66319 + return 0;
66320 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66321 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66322 + return 1;
66323 + }
66324 +
66325 + return 1;
66326 +}
66327 +
66328 +void
66329 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66330 +{
66331 + unsigned long runtime;
66332 + unsigned long cputime;
66333 + unsigned int wday, cday;
66334 + __u8 whr, chr;
66335 + __u8 wmin, cmin;
66336 + __u8 wsec, csec;
66337 + struct timespec timeval;
66338 +
66339 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66340 + !(task->acl->mode & GR_PROCACCT)))
66341 + return;
66342 +
66343 + do_posix_clock_monotonic_gettime(&timeval);
66344 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66345 + wday = runtime / (3600 * 24);
66346 + runtime -= wday * (3600 * 24);
66347 + whr = runtime / 3600;
66348 + runtime -= whr * 3600;
66349 + wmin = runtime / 60;
66350 + runtime -= wmin * 60;
66351 + wsec = runtime;
66352 +
66353 + cputime = (task->utime + task->stime) / HZ;
66354 + cday = cputime / (3600 * 24);
66355 + cputime -= cday * (3600 * 24);
66356 + chr = cputime / 3600;
66357 + cputime -= chr * 3600;
66358 + cmin = cputime / 60;
66359 + cputime -= cmin * 60;
66360 + csec = cputime;
66361 +
66362 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66363 +
66364 + return;
66365 +}
66366 +
66367 +void gr_set_kernel_label(struct task_struct *task)
66368 +{
66369 + if (gr_status & GR_READY) {
66370 + task->role = kernel_role;
66371 + task->acl = kernel_role->root_label;
66372 + }
66373 + return;
66374 +}
66375 +
66376 +#ifdef CONFIG_TASKSTATS
66377 +int gr_is_taskstats_denied(int pid)
66378 +{
66379 + struct task_struct *task;
66380 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66381 + const struct cred *cred;
66382 +#endif
66383 + int ret = 0;
66384 +
66385 + /* restrict taskstats viewing to un-chrooted root users
66386 + who have the 'view' subject flag if the RBAC system is enabled
66387 + */
66388 +
66389 + rcu_read_lock();
66390 + read_lock(&tasklist_lock);
66391 + task = find_task_by_vpid(pid);
66392 + if (task) {
66393 +#ifdef CONFIG_GRKERNSEC_CHROOT
66394 + if (proc_is_chrooted(task))
66395 + ret = -EACCES;
66396 +#endif
66397 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66398 + cred = __task_cred(task);
66399 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66400 + if (gr_is_global_nonroot(cred->uid))
66401 + ret = -EACCES;
66402 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66403 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66404 + ret = -EACCES;
66405 +#endif
66406 +#endif
66407 + if (gr_status & GR_READY) {
66408 + if (!(task->acl->mode & GR_VIEW))
66409 + ret = -EACCES;
66410 + }
66411 + } else
66412 + ret = -ENOENT;
66413 +
66414 + read_unlock(&tasklist_lock);
66415 + rcu_read_unlock();
66416 +
66417 + return ret;
66418 +}
66419 +#endif
66420 +
66421 +/* AUXV entries are filled via a descendant of search_binary_handler
66422 + after we've already applied the subject for the target
66423 +*/
66424 +int gr_acl_enable_at_secure(void)
66425 +{
66426 + if (unlikely(!(gr_status & GR_READY)))
66427 + return 0;
66428 +
66429 + if (current->acl->mode & GR_ATSECURE)
66430 + return 1;
66431 +
66432 + return 0;
66433 +}
66434 +
66435 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66436 +{
66437 + struct task_struct *task = current;
66438 + struct dentry *dentry = file->f_path.dentry;
66439 + struct vfsmount *mnt = file->f_path.mnt;
66440 + struct acl_object_label *obj, *tmp;
66441 + struct acl_subject_label *subj;
66442 + unsigned int bufsize;
66443 + int is_not_root;
66444 + char *path;
66445 + dev_t dev = __get_dev(dentry);
66446 +
66447 + if (unlikely(!(gr_status & GR_READY)))
66448 + return 1;
66449 +
66450 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66451 + return 1;
66452 +
66453 + /* ignore Eric Biederman */
66454 + if (IS_PRIVATE(dentry->d_inode))
66455 + return 1;
66456 +
66457 + subj = task->acl;
66458 + read_lock(&gr_inode_lock);
66459 + do {
66460 + obj = lookup_acl_obj_label(ino, dev, subj);
66461 + if (obj != NULL) {
66462 + read_unlock(&gr_inode_lock);
66463 + return (obj->mode & GR_FIND) ? 1 : 0;
66464 + }
66465 + } while ((subj = subj->parent_subject));
66466 + read_unlock(&gr_inode_lock);
66467 +
66468 + /* this is purely an optimization since we're looking for an object
66469 + for the directory we're doing a readdir on
66470 + if it's possible for any globbed object to match the entry we're
66471 + filling into the directory, then the object we find here will be
66472 + an anchor point with attached globbed objects
66473 + */
66474 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66475 + if (obj->globbed == NULL)
66476 + return (obj->mode & GR_FIND) ? 1 : 0;
66477 +
66478 + is_not_root = ((obj->filename[0] == '/') &&
66479 + (obj->filename[1] == '\0')) ? 0 : 1;
66480 + bufsize = PAGE_SIZE - namelen - is_not_root;
66481 +
66482 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66483 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66484 + return 1;
66485 +
66486 + preempt_disable();
66487 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66488 + bufsize);
66489 +
66490 + bufsize = strlen(path);
66491 +
66492 + /* if base is "/", don't append an additional slash */
66493 + if (is_not_root)
66494 + *(path + bufsize) = '/';
66495 + memcpy(path + bufsize + is_not_root, name, namelen);
66496 + *(path + bufsize + namelen + is_not_root) = '\0';
66497 +
66498 + tmp = obj->globbed;
66499 + while (tmp) {
66500 + if (!glob_match(tmp->filename, path)) {
66501 + preempt_enable();
66502 + return (tmp->mode & GR_FIND) ? 1 : 0;
66503 + }
66504 + tmp = tmp->next;
66505 + }
66506 + preempt_enable();
66507 + return (obj->mode & GR_FIND) ? 1 : 0;
66508 +}
66509 +
66510 +void gr_put_exec_file(struct task_struct *task)
66511 +{
66512 + struct file *filp;
66513 +
66514 + write_lock(&grsec_exec_file_lock);
66515 + filp = task->exec_file;
66516 + task->exec_file = NULL;
66517 + write_unlock(&grsec_exec_file_lock);
66518 +
66519 + if (filp)
66520 + fput(filp);
66521 +
66522 + return;
66523 +}
66524 +
66525 +
66526 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66527 +EXPORT_SYMBOL(gr_acl_is_enabled);
66528 +#endif
66529 +EXPORT_SYMBOL(gr_set_kernel_label);
66530 +#ifdef CONFIG_SECURITY
66531 +EXPORT_SYMBOL(gr_check_user_change);
66532 +EXPORT_SYMBOL(gr_check_group_change);
66533 +#endif
66534 +
66535 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66536 new file mode 100644
66537 index 0000000..34fefda
66538 --- /dev/null
66539 +++ b/grsecurity/gracl_alloc.c
66540 @@ -0,0 +1,105 @@
66541 +#include <linux/kernel.h>
66542 +#include <linux/mm.h>
66543 +#include <linux/slab.h>
66544 +#include <linux/vmalloc.h>
66545 +#include <linux/gracl.h>
66546 +#include <linux/grsecurity.h>
66547 +
66548 +static unsigned long alloc_stack_next = 1;
66549 +static unsigned long alloc_stack_size = 1;
66550 +static void **alloc_stack;
66551 +
66552 +static __inline__ int
66553 +alloc_pop(void)
66554 +{
66555 + if (alloc_stack_next == 1)
66556 + return 0;
66557 +
66558 + kfree(alloc_stack[alloc_stack_next - 2]);
66559 +
66560 + alloc_stack_next--;
66561 +
66562 + return 1;
66563 +}
66564 +
66565 +static __inline__ int
66566 +alloc_push(void *buf)
66567 +{
66568 + if (alloc_stack_next >= alloc_stack_size)
66569 + return 1;
66570 +
66571 + alloc_stack[alloc_stack_next - 1] = buf;
66572 +
66573 + alloc_stack_next++;
66574 +
66575 + return 0;
66576 +}
66577 +
66578 +void *
66579 +acl_alloc(unsigned long len)
66580 +{
66581 + void *ret = NULL;
66582 +
66583 + if (!len || len > PAGE_SIZE)
66584 + goto out;
66585 +
66586 + ret = kmalloc(len, GFP_KERNEL);
66587 +
66588 + if (ret) {
66589 + if (alloc_push(ret)) {
66590 + kfree(ret);
66591 + ret = NULL;
66592 + }
66593 + }
66594 +
66595 +out:
66596 + return ret;
66597 +}
66598 +
66599 +void *
66600 +acl_alloc_num(unsigned long num, unsigned long len)
66601 +{
66602 + if (!len || (num > (PAGE_SIZE / len)))
66603 + return NULL;
66604 +
66605 + return acl_alloc(num * len);
66606 +}
66607 +
66608 +void
66609 +acl_free_all(void)
66610 +{
66611 + if (gr_acl_is_enabled() || !alloc_stack)
66612 + return;
66613 +
66614 + while (alloc_pop()) ;
66615 +
66616 + if (alloc_stack) {
66617 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66618 + kfree(alloc_stack);
66619 + else
66620 + vfree(alloc_stack);
66621 + }
66622 +
66623 + alloc_stack = NULL;
66624 + alloc_stack_size = 1;
66625 + alloc_stack_next = 1;
66626 +
66627 + return;
66628 +}
66629 +
66630 +int
66631 +acl_alloc_stack_init(unsigned long size)
66632 +{
66633 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66634 + alloc_stack =
66635 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66636 + else
66637 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
66638 +
66639 + alloc_stack_size = size;
66640 +
66641 + if (!alloc_stack)
66642 + return 0;
66643 + else
66644 + return 1;
66645 +}
66646 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66647 new file mode 100644
66648 index 0000000..bdd51ea
66649 --- /dev/null
66650 +++ b/grsecurity/gracl_cap.c
66651 @@ -0,0 +1,110 @@
66652 +#include <linux/kernel.h>
66653 +#include <linux/module.h>
66654 +#include <linux/sched.h>
66655 +#include <linux/gracl.h>
66656 +#include <linux/grsecurity.h>
66657 +#include <linux/grinternal.h>
66658 +
66659 +extern const char *captab_log[];
66660 +extern int captab_log_entries;
66661 +
66662 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66663 +{
66664 + struct acl_subject_label *curracl;
66665 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66666 + kernel_cap_t cap_audit = __cap_empty_set;
66667 +
66668 + if (!gr_acl_is_enabled())
66669 + return 1;
66670 +
66671 + curracl = task->acl;
66672 +
66673 + cap_drop = curracl->cap_lower;
66674 + cap_mask = curracl->cap_mask;
66675 + cap_audit = curracl->cap_invert_audit;
66676 +
66677 + while ((curracl = curracl->parent_subject)) {
66678 + /* if the cap isn't specified in the current computed mask but is specified in the
66679 + current level subject, and is lowered in the current level subject, then add
66680 + it to the set of dropped capabilities
66681 + otherwise, add the current level subject's mask to the current computed mask
66682 + */
66683 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66684 + cap_raise(cap_mask, cap);
66685 + if (cap_raised(curracl->cap_lower, cap))
66686 + cap_raise(cap_drop, cap);
66687 + if (cap_raised(curracl->cap_invert_audit, cap))
66688 + cap_raise(cap_audit, cap);
66689 + }
66690 + }
66691 +
66692 + if (!cap_raised(cap_drop, cap)) {
66693 + if (cap_raised(cap_audit, cap))
66694 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66695 + return 1;
66696 + }
66697 +
66698 + curracl = task->acl;
66699 +
66700 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66701 + && cap_raised(cred->cap_effective, cap)) {
66702 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66703 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66704 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66705 + gr_to_filename(task->exec_file->f_path.dentry,
66706 + task->exec_file->f_path.mnt) : curracl->filename,
66707 + curracl->filename, 0UL,
66708 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66709 + return 1;
66710 + }
66711 +
66712 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66713 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66714 +
66715 + return 0;
66716 +}
66717 +
66718 +int
66719 +gr_acl_is_capable(const int cap)
66720 +{
66721 + return gr_task_acl_is_capable(current, current_cred(), cap);
66722 +}
66723 +
66724 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66725 +{
66726 + struct acl_subject_label *curracl;
66727 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66728 +
66729 + if (!gr_acl_is_enabled())
66730 + return 1;
66731 +
66732 + curracl = task->acl;
66733 +
66734 + cap_drop = curracl->cap_lower;
66735 + cap_mask = curracl->cap_mask;
66736 +
66737 + while ((curracl = curracl->parent_subject)) {
66738 + /* if the cap isn't specified in the current computed mask but is specified in the
66739 + current level subject, and is lowered in the current level subject, then add
66740 + it to the set of dropped capabilities
66741 + otherwise, add the current level subject's mask to the current computed mask
66742 + */
66743 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66744 + cap_raise(cap_mask, cap);
66745 + if (cap_raised(curracl->cap_lower, cap))
66746 + cap_raise(cap_drop, cap);
66747 + }
66748 + }
66749 +
66750 + if (!cap_raised(cap_drop, cap))
66751 + return 1;
66752 +
66753 + return 0;
66754 +}
66755 +
66756 +int
66757 +gr_acl_is_capable_nolog(const int cap)
66758 +{
66759 + return gr_task_acl_is_capable_nolog(current, cap);
66760 +}
66761 +
66762 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66763 new file mode 100644
66764 index 0000000..a43dd06
66765 --- /dev/null
66766 +++ b/grsecurity/gracl_compat.c
66767 @@ -0,0 +1,269 @@
66768 +#include <linux/kernel.h>
66769 +#include <linux/gracl.h>
66770 +#include <linux/compat.h>
66771 +#include <linux/gracl_compat.h>
66772 +
66773 +#include <asm/uaccess.h>
66774 +
66775 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66776 +{
66777 + struct gr_arg_wrapper_compat uwrapcompat;
66778 +
66779 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66780 + return -EFAULT;
66781 +
66782 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
66783 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66784 + return -EINVAL;
66785 +
66786 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66787 + uwrap->version = uwrapcompat.version;
66788 + uwrap->size = sizeof(struct gr_arg);
66789 +
66790 + return 0;
66791 +}
66792 +
66793 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66794 +{
66795 + struct gr_arg_compat argcompat;
66796 +
66797 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66798 + return -EFAULT;
66799 +
66800 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66801 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66802 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66803 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66804 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66805 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66806 +
66807 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66808 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66809 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66810 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66811 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66812 + arg->segv_device = argcompat.segv_device;
66813 + arg->segv_inode = argcompat.segv_inode;
66814 + arg->segv_uid = argcompat.segv_uid;
66815 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66816 + arg->mode = argcompat.mode;
66817 +
66818 + return 0;
66819 +}
66820 +
66821 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66822 +{
66823 + struct acl_object_label_compat objcompat;
66824 +
66825 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66826 + return -EFAULT;
66827 +
66828 + obj->filename = compat_ptr(objcompat.filename);
66829 + obj->inode = objcompat.inode;
66830 + obj->device = objcompat.device;
66831 + obj->mode = objcompat.mode;
66832 +
66833 + obj->nested = compat_ptr(objcompat.nested);
66834 + obj->globbed = compat_ptr(objcompat.globbed);
66835 +
66836 + obj->prev = compat_ptr(objcompat.prev);
66837 + obj->next = compat_ptr(objcompat.next);
66838 +
66839 + return 0;
66840 +}
66841 +
66842 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66843 +{
66844 + unsigned int i;
66845 + struct acl_subject_label_compat subjcompat;
66846 +
66847 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66848 + return -EFAULT;
66849 +
66850 + subj->filename = compat_ptr(subjcompat.filename);
66851 + subj->inode = subjcompat.inode;
66852 + subj->device = subjcompat.device;
66853 + subj->mode = subjcompat.mode;
66854 + subj->cap_mask = subjcompat.cap_mask;
66855 + subj->cap_lower = subjcompat.cap_lower;
66856 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66857 +
66858 + for (i = 0; i < GR_NLIMITS; i++) {
66859 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66860 + subj->res[i].rlim_cur = RLIM_INFINITY;
66861 + else
66862 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66863 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66864 + subj->res[i].rlim_max = RLIM_INFINITY;
66865 + else
66866 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66867 + }
66868 + subj->resmask = subjcompat.resmask;
66869 +
66870 + subj->user_trans_type = subjcompat.user_trans_type;
66871 + subj->group_trans_type = subjcompat.group_trans_type;
66872 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66873 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66874 + subj->user_trans_num = subjcompat.user_trans_num;
66875 + subj->group_trans_num = subjcompat.group_trans_num;
66876 +
66877 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66878 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66879 + subj->ip_type = subjcompat.ip_type;
66880 + subj->ips = compat_ptr(subjcompat.ips);
66881 + subj->ip_num = subjcompat.ip_num;
66882 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66883 +
66884 + subj->crashes = subjcompat.crashes;
66885 + subj->expires = subjcompat.expires;
66886 +
66887 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66888 + subj->hash = compat_ptr(subjcompat.hash);
66889 + subj->prev = compat_ptr(subjcompat.prev);
66890 + subj->next = compat_ptr(subjcompat.next);
66891 +
66892 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66893 + subj->obj_hash_size = subjcompat.obj_hash_size;
66894 + subj->pax_flags = subjcompat.pax_flags;
66895 +
66896 + return 0;
66897 +}
66898 +
66899 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66900 +{
66901 + struct acl_role_label_compat rolecompat;
66902 +
66903 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66904 + return -EFAULT;
66905 +
66906 + role->rolename = compat_ptr(rolecompat.rolename);
66907 + role->uidgid = rolecompat.uidgid;
66908 + role->roletype = rolecompat.roletype;
66909 +
66910 + role->auth_attempts = rolecompat.auth_attempts;
66911 + role->expires = rolecompat.expires;
66912 +
66913 + role->root_label = compat_ptr(rolecompat.root_label);
66914 + role->hash = compat_ptr(rolecompat.hash);
66915 +
66916 + role->prev = compat_ptr(rolecompat.prev);
66917 + role->next = compat_ptr(rolecompat.next);
66918 +
66919 + role->transitions = compat_ptr(rolecompat.transitions);
66920 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66921 + role->domain_children = compat_ptr(rolecompat.domain_children);
66922 + role->domain_child_num = rolecompat.domain_child_num;
66923 +
66924 + role->umask = rolecompat.umask;
66925 +
66926 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66927 + role->subj_hash_size = rolecompat.subj_hash_size;
66928 +
66929 + return 0;
66930 +}
66931 +
66932 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66933 +{
66934 + struct role_allowed_ip_compat roleip_compat;
66935 +
66936 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66937 + return -EFAULT;
66938 +
66939 + roleip->addr = roleip_compat.addr;
66940 + roleip->netmask = roleip_compat.netmask;
66941 +
66942 + roleip->prev = compat_ptr(roleip_compat.prev);
66943 + roleip->next = compat_ptr(roleip_compat.next);
66944 +
66945 + return 0;
66946 +}
66947 +
66948 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66949 +{
66950 + struct role_transition_compat trans_compat;
66951 +
66952 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66953 + return -EFAULT;
66954 +
66955 + trans->rolename = compat_ptr(trans_compat.rolename);
66956 +
66957 + trans->prev = compat_ptr(trans_compat.prev);
66958 + trans->next = compat_ptr(trans_compat.next);
66959 +
66960 + return 0;
66961 +
66962 +}
66963 +
66964 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66965 +{
66966 + struct gr_hash_struct_compat hash_compat;
66967 +
66968 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66969 + return -EFAULT;
66970 +
66971 + hash->table = compat_ptr(hash_compat.table);
66972 + hash->nametable = compat_ptr(hash_compat.nametable);
66973 + hash->first = compat_ptr(hash_compat.first);
66974 +
66975 + hash->table_size = hash_compat.table_size;
66976 + hash->used_size = hash_compat.used_size;
66977 +
66978 + hash->type = hash_compat.type;
66979 +
66980 + return 0;
66981 +}
66982 +
66983 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66984 +{
66985 + compat_uptr_t ptrcompat;
66986 +
66987 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66988 + return -EFAULT;
66989 +
66990 + *(void **)ptr = compat_ptr(ptrcompat);
66991 +
66992 + return 0;
66993 +}
66994 +
66995 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66996 +{
66997 + struct acl_ip_label_compat ip_compat;
66998 +
66999 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
67000 + return -EFAULT;
67001 +
67002 + ip->iface = compat_ptr(ip_compat.iface);
67003 + ip->addr = ip_compat.addr;
67004 + ip->netmask = ip_compat.netmask;
67005 + ip->low = ip_compat.low;
67006 + ip->high = ip_compat.high;
67007 + ip->mode = ip_compat.mode;
67008 + ip->type = ip_compat.type;
67009 +
67010 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
67011 +
67012 + ip->prev = compat_ptr(ip_compat.prev);
67013 + ip->next = compat_ptr(ip_compat.next);
67014 +
67015 + return 0;
67016 +}
67017 +
67018 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
67019 +{
67020 + struct sprole_pw_compat pw_compat;
67021 +
67022 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
67023 + return -EFAULT;
67024 +
67025 + pw->rolename = compat_ptr(pw_compat.rolename);
67026 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
67027 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
67028 +
67029 + return 0;
67030 +}
67031 +
67032 +size_t get_gr_arg_wrapper_size_compat(void)
67033 +{
67034 + return sizeof(struct gr_arg_wrapper_compat);
67035 +}
67036 +
67037 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
67038 new file mode 100644
67039 index 0000000..a340c17
67040 --- /dev/null
67041 +++ b/grsecurity/gracl_fs.c
67042 @@ -0,0 +1,431 @@
67043 +#include <linux/kernel.h>
67044 +#include <linux/sched.h>
67045 +#include <linux/types.h>
67046 +#include <linux/fs.h>
67047 +#include <linux/file.h>
67048 +#include <linux/stat.h>
67049 +#include <linux/grsecurity.h>
67050 +#include <linux/grinternal.h>
67051 +#include <linux/gracl.h>
67052 +
67053 +umode_t
67054 +gr_acl_umask(void)
67055 +{
67056 + if (unlikely(!gr_acl_is_enabled()))
67057 + return 0;
67058 +
67059 + return current->role->umask;
67060 +}
67061 +
67062 +__u32
67063 +gr_acl_handle_hidden_file(const struct dentry * dentry,
67064 + const struct vfsmount * mnt)
67065 +{
67066 + __u32 mode;
67067 +
67068 + if (unlikely(!dentry->d_inode))
67069 + return GR_FIND;
67070 +
67071 + mode =
67072 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
67073 +
67074 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
67075 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
67076 + return mode;
67077 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
67078 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
67079 + return 0;
67080 + } else if (unlikely(!(mode & GR_FIND)))
67081 + return 0;
67082 +
67083 + return GR_FIND;
67084 +}
67085 +
67086 +__u32
67087 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
67088 + int acc_mode)
67089 +{
67090 + __u32 reqmode = GR_FIND;
67091 + __u32 mode;
67092 +
67093 + if (unlikely(!dentry->d_inode))
67094 + return reqmode;
67095 +
67096 + if (acc_mode & MAY_APPEND)
67097 + reqmode |= GR_APPEND;
67098 + else if (acc_mode & MAY_WRITE)
67099 + reqmode |= GR_WRITE;
67100 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
67101 + reqmode |= GR_READ;
67102 +
67103 + mode =
67104 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67105 + mnt);
67106 +
67107 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67108 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
67109 + reqmode & GR_READ ? " reading" : "",
67110 + reqmode & GR_WRITE ? " writing" : reqmode &
67111 + GR_APPEND ? " appending" : "");
67112 + return reqmode;
67113 + } else
67114 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67115 + {
67116 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
67117 + reqmode & GR_READ ? " reading" : "",
67118 + reqmode & GR_WRITE ? " writing" : reqmode &
67119 + GR_APPEND ? " appending" : "");
67120 + return 0;
67121 + } else if (unlikely((mode & reqmode) != reqmode))
67122 + return 0;
67123 +
67124 + return reqmode;
67125 +}
67126 +
67127 +__u32
67128 +gr_acl_handle_creat(const struct dentry * dentry,
67129 + const struct dentry * p_dentry,
67130 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
67131 + const int imode)
67132 +{
67133 + __u32 reqmode = GR_WRITE | GR_CREATE;
67134 + __u32 mode;
67135 +
67136 + if (acc_mode & MAY_APPEND)
67137 + reqmode |= GR_APPEND;
67138 + // if a directory was required or the directory already exists, then
67139 + // don't count this open as a read
67140 + if ((acc_mode & MAY_READ) &&
67141 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
67142 + reqmode |= GR_READ;
67143 + if ((open_flags & O_CREAT) &&
67144 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67145 + reqmode |= GR_SETID;
67146 +
67147 + mode =
67148 + gr_check_create(dentry, p_dentry, p_mnt,
67149 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67150 +
67151 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67152 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67153 + reqmode & GR_READ ? " reading" : "",
67154 + reqmode & GR_WRITE ? " writing" : reqmode &
67155 + GR_APPEND ? " appending" : "");
67156 + return reqmode;
67157 + } else
67158 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67159 + {
67160 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67161 + reqmode & GR_READ ? " reading" : "",
67162 + reqmode & GR_WRITE ? " writing" : reqmode &
67163 + GR_APPEND ? " appending" : "");
67164 + return 0;
67165 + } else if (unlikely((mode & reqmode) != reqmode))
67166 + return 0;
67167 +
67168 + return reqmode;
67169 +}
67170 +
67171 +__u32
67172 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
67173 + const int fmode)
67174 +{
67175 + __u32 mode, reqmode = GR_FIND;
67176 +
67177 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67178 + reqmode |= GR_EXEC;
67179 + if (fmode & S_IWOTH)
67180 + reqmode |= GR_WRITE;
67181 + if (fmode & S_IROTH)
67182 + reqmode |= GR_READ;
67183 +
67184 + mode =
67185 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67186 + mnt);
67187 +
67188 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67189 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67190 + reqmode & GR_READ ? " reading" : "",
67191 + reqmode & GR_WRITE ? " writing" : "",
67192 + reqmode & GR_EXEC ? " executing" : "");
67193 + return reqmode;
67194 + } else
67195 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67196 + {
67197 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67198 + reqmode & GR_READ ? " reading" : "",
67199 + reqmode & GR_WRITE ? " writing" : "",
67200 + reqmode & GR_EXEC ? " executing" : "");
67201 + return 0;
67202 + } else if (unlikely((mode & reqmode) != reqmode))
67203 + return 0;
67204 +
67205 + return reqmode;
67206 +}
67207 +
67208 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67209 +{
67210 + __u32 mode;
67211 +
67212 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67213 +
67214 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67215 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67216 + return mode;
67217 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67218 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67219 + return 0;
67220 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67221 + return 0;
67222 +
67223 + return (reqmode);
67224 +}
67225 +
67226 +__u32
67227 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67228 +{
67229 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67230 +}
67231 +
67232 +__u32
67233 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67234 +{
67235 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67236 +}
67237 +
67238 +__u32
67239 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67240 +{
67241 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67242 +}
67243 +
67244 +__u32
67245 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67246 +{
67247 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67248 +}
67249 +
67250 +__u32
67251 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67252 + umode_t *modeptr)
67253 +{
67254 + umode_t mode;
67255 +
67256 + *modeptr &= ~gr_acl_umask();
67257 + mode = *modeptr;
67258 +
67259 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67260 + return 1;
67261 +
67262 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67263 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67264 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67265 + GR_CHMOD_ACL_MSG);
67266 + } else {
67267 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67268 + }
67269 +}
67270 +
67271 +__u32
67272 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67273 +{
67274 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67275 +}
67276 +
67277 +__u32
67278 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67279 +{
67280 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67281 +}
67282 +
67283 +__u32
67284 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67285 +{
67286 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67287 +}
67288 +
67289 +__u32
67290 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67291 +{
67292 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67293 + GR_UNIXCONNECT_ACL_MSG);
67294 +}
67295 +
67296 +/* hardlinks require at minimum create and link permission,
67297 + any additional privilege required is based on the
67298 + privilege of the file being linked to
67299 +*/
67300 +__u32
67301 +gr_acl_handle_link(const struct dentry * new_dentry,
67302 + const struct dentry * parent_dentry,
67303 + const struct vfsmount * parent_mnt,
67304 + const struct dentry * old_dentry,
67305 + const struct vfsmount * old_mnt, const struct filename *to)
67306 +{
67307 + __u32 mode;
67308 + __u32 needmode = GR_CREATE | GR_LINK;
67309 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67310 +
67311 + mode =
67312 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67313 + old_mnt);
67314 +
67315 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67316 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67317 + return mode;
67318 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67319 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67320 + return 0;
67321 + } else if (unlikely((mode & needmode) != needmode))
67322 + return 0;
67323 +
67324 + return 1;
67325 +}
67326 +
67327 +__u32
67328 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67329 + const struct dentry * parent_dentry,
67330 + const struct vfsmount * parent_mnt, const struct filename *from)
67331 +{
67332 + __u32 needmode = GR_WRITE | GR_CREATE;
67333 + __u32 mode;
67334 +
67335 + mode =
67336 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67337 + GR_CREATE | GR_AUDIT_CREATE |
67338 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67339 +
67340 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67341 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67342 + return mode;
67343 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67344 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67345 + return 0;
67346 + } else if (unlikely((mode & needmode) != needmode))
67347 + return 0;
67348 +
67349 + return (GR_WRITE | GR_CREATE);
67350 +}
67351 +
67352 +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)
67353 +{
67354 + __u32 mode;
67355 +
67356 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67357 +
67358 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67359 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67360 + return mode;
67361 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67362 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67363 + return 0;
67364 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67365 + return 0;
67366 +
67367 + return (reqmode);
67368 +}
67369 +
67370 +__u32
67371 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67372 + const struct dentry * parent_dentry,
67373 + const struct vfsmount * parent_mnt,
67374 + const int mode)
67375 +{
67376 + __u32 reqmode = GR_WRITE | GR_CREATE;
67377 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67378 + reqmode |= GR_SETID;
67379 +
67380 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67381 + reqmode, GR_MKNOD_ACL_MSG);
67382 +}
67383 +
67384 +__u32
67385 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67386 + const struct dentry *parent_dentry,
67387 + const struct vfsmount *parent_mnt)
67388 +{
67389 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67390 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67391 +}
67392 +
67393 +#define RENAME_CHECK_SUCCESS(old, new) \
67394 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67395 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67396 +
67397 +int
67398 +gr_acl_handle_rename(struct dentry *new_dentry,
67399 + struct dentry *parent_dentry,
67400 + const struct vfsmount *parent_mnt,
67401 + struct dentry *old_dentry,
67402 + struct inode *old_parent_inode,
67403 + struct vfsmount *old_mnt, const struct filename *newname)
67404 +{
67405 + __u32 comp1, comp2;
67406 + int error = 0;
67407 +
67408 + if (unlikely(!gr_acl_is_enabled()))
67409 + return 0;
67410 +
67411 + if (!new_dentry->d_inode) {
67412 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67413 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67414 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67415 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67416 + GR_DELETE | GR_AUDIT_DELETE |
67417 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67418 + GR_SUPPRESS, old_mnt);
67419 + } else {
67420 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67421 + GR_CREATE | GR_DELETE |
67422 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67423 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67424 + GR_SUPPRESS, parent_mnt);
67425 + comp2 =
67426 + gr_search_file(old_dentry,
67427 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67428 + GR_DELETE | GR_AUDIT_DELETE |
67429 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67430 + }
67431 +
67432 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67433 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67434 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67435 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67436 + && !(comp2 & GR_SUPPRESS)) {
67437 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67438 + error = -EACCES;
67439 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67440 + error = -EACCES;
67441 +
67442 + return error;
67443 +}
67444 +
67445 +void
67446 +gr_acl_handle_exit(void)
67447 +{
67448 + u16 id;
67449 + char *rolename;
67450 +
67451 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67452 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67453 + id = current->acl_role_id;
67454 + rolename = current->role->rolename;
67455 + gr_set_acls(1);
67456 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67457 + }
67458 +
67459 + gr_put_exec_file(current);
67460 + return;
67461 +}
67462 +
67463 +int
67464 +gr_acl_handle_procpidmem(const struct task_struct *task)
67465 +{
67466 + if (unlikely(!gr_acl_is_enabled()))
67467 + return 0;
67468 +
67469 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67470 + return -EACCES;
67471 +
67472 + return 0;
67473 +}
67474 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67475 new file mode 100644
67476 index 0000000..f056b81
67477 --- /dev/null
67478 +++ b/grsecurity/gracl_ip.c
67479 @@ -0,0 +1,386 @@
67480 +#include <linux/kernel.h>
67481 +#include <asm/uaccess.h>
67482 +#include <asm/errno.h>
67483 +#include <net/sock.h>
67484 +#include <linux/file.h>
67485 +#include <linux/fs.h>
67486 +#include <linux/net.h>
67487 +#include <linux/in.h>
67488 +#include <linux/skbuff.h>
67489 +#include <linux/ip.h>
67490 +#include <linux/udp.h>
67491 +#include <linux/types.h>
67492 +#include <linux/sched.h>
67493 +#include <linux/netdevice.h>
67494 +#include <linux/inetdevice.h>
67495 +#include <linux/gracl.h>
67496 +#include <linux/grsecurity.h>
67497 +#include <linux/grinternal.h>
67498 +
67499 +#define GR_BIND 0x01
67500 +#define GR_CONNECT 0x02
67501 +#define GR_INVERT 0x04
67502 +#define GR_BINDOVERRIDE 0x08
67503 +#define GR_CONNECTOVERRIDE 0x10
67504 +#define GR_SOCK_FAMILY 0x20
67505 +
67506 +static const char * gr_protocols[IPPROTO_MAX] = {
67507 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67508 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67509 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67510 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67511 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67512 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67513 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67514 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67515 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67516 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67517 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67518 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67519 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67520 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67521 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67522 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67523 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67524 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67525 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67526 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67527 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67528 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67529 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67530 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67531 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67532 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67533 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67534 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67535 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67536 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67537 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67538 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67539 + };
67540 +
67541 +static const char * gr_socktypes[SOCK_MAX] = {
67542 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67543 + "unknown:7", "unknown:8", "unknown:9", "packet"
67544 + };
67545 +
67546 +static const char * gr_sockfamilies[AF_MAX+1] = {
67547 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67548 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67549 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67550 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67551 + };
67552 +
67553 +const char *
67554 +gr_proto_to_name(unsigned char proto)
67555 +{
67556 + return gr_protocols[proto];
67557 +}
67558 +
67559 +const char *
67560 +gr_socktype_to_name(unsigned char type)
67561 +{
67562 + return gr_socktypes[type];
67563 +}
67564 +
67565 +const char *
67566 +gr_sockfamily_to_name(unsigned char family)
67567 +{
67568 + return gr_sockfamilies[family];
67569 +}
67570 +
67571 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67572 +
67573 +int
67574 +gr_search_socket(const int domain, const int type, const int protocol)
67575 +{
67576 + struct acl_subject_label *curr;
67577 + const struct cred *cred = current_cred();
67578 +
67579 + if (unlikely(!gr_acl_is_enabled()))
67580 + goto exit;
67581 +
67582 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67583 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67584 + goto exit; // let the kernel handle it
67585 +
67586 + curr = current->acl;
67587 +
67588 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67589 + /* the family is allowed, if this is PF_INET allow it only if
67590 + the extra sock type/protocol checks pass */
67591 + if (domain == PF_INET)
67592 + goto inet_check;
67593 + goto exit;
67594 + } else {
67595 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67596 + __u32 fakeip = 0;
67597 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67598 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67599 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67600 + gr_to_filename(current->exec_file->f_path.dentry,
67601 + current->exec_file->f_path.mnt) :
67602 + curr->filename, curr->filename,
67603 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67604 + &current->signal->saved_ip);
67605 + goto exit;
67606 + }
67607 + goto exit_fail;
67608 + }
67609 +
67610 +inet_check:
67611 + /* the rest of this checking is for IPv4 only */
67612 + if (!curr->ips)
67613 + goto exit;
67614 +
67615 + if ((curr->ip_type & (1U << type)) &&
67616 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67617 + goto exit;
67618 +
67619 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67620 + /* we don't place acls on raw sockets , and sometimes
67621 + dgram/ip sockets are opened for ioctl and not
67622 + bind/connect, so we'll fake a bind learn log */
67623 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67624 + __u32 fakeip = 0;
67625 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67626 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67627 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67628 + gr_to_filename(current->exec_file->f_path.dentry,
67629 + current->exec_file->f_path.mnt) :
67630 + curr->filename, curr->filename,
67631 + &fakeip, 0, type,
67632 + protocol, GR_CONNECT, &current->signal->saved_ip);
67633 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67634 + __u32 fakeip = 0;
67635 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67636 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67637 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67638 + gr_to_filename(current->exec_file->f_path.dentry,
67639 + current->exec_file->f_path.mnt) :
67640 + curr->filename, curr->filename,
67641 + &fakeip, 0, type,
67642 + protocol, GR_BIND, &current->signal->saved_ip);
67643 + }
67644 + /* we'll log when they use connect or bind */
67645 + goto exit;
67646 + }
67647 +
67648 +exit_fail:
67649 + if (domain == PF_INET)
67650 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67651 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67652 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67653 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67654 + gr_socktype_to_name(type), protocol);
67655 +
67656 + return 0;
67657 +exit:
67658 + return 1;
67659 +}
67660 +
67661 +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)
67662 +{
67663 + if ((ip->mode & mode) &&
67664 + (ip_port >= ip->low) &&
67665 + (ip_port <= ip->high) &&
67666 + ((ntohl(ip_addr) & our_netmask) ==
67667 + (ntohl(our_addr) & our_netmask))
67668 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67669 + && (ip->type & (1U << type))) {
67670 + if (ip->mode & GR_INVERT)
67671 + return 2; // specifically denied
67672 + else
67673 + return 1; // allowed
67674 + }
67675 +
67676 + return 0; // not specifically allowed, may continue parsing
67677 +}
67678 +
67679 +static int
67680 +gr_search_connectbind(const int full_mode, struct sock *sk,
67681 + struct sockaddr_in *addr, const int type)
67682 +{
67683 + char iface[IFNAMSIZ] = {0};
67684 + struct acl_subject_label *curr;
67685 + struct acl_ip_label *ip;
67686 + struct inet_sock *isk;
67687 + struct net_device *dev;
67688 + struct in_device *idev;
67689 + unsigned long i;
67690 + int ret;
67691 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67692 + __u32 ip_addr = 0;
67693 + __u32 our_addr;
67694 + __u32 our_netmask;
67695 + char *p;
67696 + __u16 ip_port = 0;
67697 + const struct cred *cred = current_cred();
67698 +
67699 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67700 + return 0;
67701 +
67702 + curr = current->acl;
67703 + isk = inet_sk(sk);
67704 +
67705 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67706 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67707 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67708 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67709 + struct sockaddr_in saddr;
67710 + int err;
67711 +
67712 + saddr.sin_family = AF_INET;
67713 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67714 + saddr.sin_port = isk->inet_sport;
67715 +
67716 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67717 + if (err)
67718 + return err;
67719 +
67720 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67721 + if (err)
67722 + return err;
67723 + }
67724 +
67725 + if (!curr->ips)
67726 + return 0;
67727 +
67728 + ip_addr = addr->sin_addr.s_addr;
67729 + ip_port = ntohs(addr->sin_port);
67730 +
67731 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67732 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67733 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67734 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67735 + gr_to_filename(current->exec_file->f_path.dentry,
67736 + current->exec_file->f_path.mnt) :
67737 + curr->filename, curr->filename,
67738 + &ip_addr, ip_port, type,
67739 + sk->sk_protocol, mode, &current->signal->saved_ip);
67740 + return 0;
67741 + }
67742 +
67743 + for (i = 0; i < curr->ip_num; i++) {
67744 + ip = *(curr->ips + i);
67745 + if (ip->iface != NULL) {
67746 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67747 + p = strchr(iface, ':');
67748 + if (p != NULL)
67749 + *p = '\0';
67750 + dev = dev_get_by_name(sock_net(sk), iface);
67751 + if (dev == NULL)
67752 + continue;
67753 + idev = in_dev_get(dev);
67754 + if (idev == NULL) {
67755 + dev_put(dev);
67756 + continue;
67757 + }
67758 + rcu_read_lock();
67759 + for_ifa(idev) {
67760 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67761 + our_addr = ifa->ifa_address;
67762 + our_netmask = 0xffffffff;
67763 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67764 + if (ret == 1) {
67765 + rcu_read_unlock();
67766 + in_dev_put(idev);
67767 + dev_put(dev);
67768 + return 0;
67769 + } else if (ret == 2) {
67770 + rcu_read_unlock();
67771 + in_dev_put(idev);
67772 + dev_put(dev);
67773 + goto denied;
67774 + }
67775 + }
67776 + } endfor_ifa(idev);
67777 + rcu_read_unlock();
67778 + in_dev_put(idev);
67779 + dev_put(dev);
67780 + } else {
67781 + our_addr = ip->addr;
67782 + our_netmask = ip->netmask;
67783 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67784 + if (ret == 1)
67785 + return 0;
67786 + else if (ret == 2)
67787 + goto denied;
67788 + }
67789 + }
67790 +
67791 +denied:
67792 + if (mode == GR_BIND)
67793 + 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));
67794 + else if (mode == GR_CONNECT)
67795 + 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));
67796 +
67797 + return -EACCES;
67798 +}
67799 +
67800 +int
67801 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67802 +{
67803 + /* always allow disconnection of dgram sockets with connect */
67804 + if (addr->sin_family == AF_UNSPEC)
67805 + return 0;
67806 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67807 +}
67808 +
67809 +int
67810 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67811 +{
67812 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67813 +}
67814 +
67815 +int gr_search_listen(struct socket *sock)
67816 +{
67817 + struct sock *sk = sock->sk;
67818 + struct sockaddr_in addr;
67819 +
67820 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67821 + addr.sin_port = inet_sk(sk)->inet_sport;
67822 +
67823 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67824 +}
67825 +
67826 +int gr_search_accept(struct socket *sock)
67827 +{
67828 + struct sock *sk = sock->sk;
67829 + struct sockaddr_in addr;
67830 +
67831 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67832 + addr.sin_port = inet_sk(sk)->inet_sport;
67833 +
67834 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67835 +}
67836 +
67837 +int
67838 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67839 +{
67840 + if (addr)
67841 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67842 + else {
67843 + struct sockaddr_in sin;
67844 + const struct inet_sock *inet = inet_sk(sk);
67845 +
67846 + sin.sin_addr.s_addr = inet->inet_daddr;
67847 + sin.sin_port = inet->inet_dport;
67848 +
67849 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67850 + }
67851 +}
67852 +
67853 +int
67854 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67855 +{
67856 + struct sockaddr_in sin;
67857 +
67858 + if (unlikely(skb->len < sizeof (struct udphdr)))
67859 + return 0; // skip this packet
67860 +
67861 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67862 + sin.sin_port = udp_hdr(skb)->source;
67863 +
67864 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67865 +}
67866 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67867 new file mode 100644
67868 index 0000000..25f54ef
67869 --- /dev/null
67870 +++ b/grsecurity/gracl_learn.c
67871 @@ -0,0 +1,207 @@
67872 +#include <linux/kernel.h>
67873 +#include <linux/mm.h>
67874 +#include <linux/sched.h>
67875 +#include <linux/poll.h>
67876 +#include <linux/string.h>
67877 +#include <linux/file.h>
67878 +#include <linux/types.h>
67879 +#include <linux/vmalloc.h>
67880 +#include <linux/grinternal.h>
67881 +
67882 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67883 + size_t count, loff_t *ppos);
67884 +extern int gr_acl_is_enabled(void);
67885 +
67886 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67887 +static int gr_learn_attached;
67888 +
67889 +/* use a 512k buffer */
67890 +#define LEARN_BUFFER_SIZE (512 * 1024)
67891 +
67892 +static DEFINE_SPINLOCK(gr_learn_lock);
67893 +static DEFINE_MUTEX(gr_learn_user_mutex);
67894 +
67895 +/* we need to maintain two buffers, so that the kernel context of grlearn
67896 + uses a semaphore around the userspace copying, and the other kernel contexts
67897 + use a spinlock when copying into the buffer, since they cannot sleep
67898 +*/
67899 +static char *learn_buffer;
67900 +static char *learn_buffer_user;
67901 +static int learn_buffer_len;
67902 +static int learn_buffer_user_len;
67903 +
67904 +static ssize_t
67905 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67906 +{
67907 + DECLARE_WAITQUEUE(wait, current);
67908 + ssize_t retval = 0;
67909 +
67910 + add_wait_queue(&learn_wait, &wait);
67911 + set_current_state(TASK_INTERRUPTIBLE);
67912 + do {
67913 + mutex_lock(&gr_learn_user_mutex);
67914 + spin_lock(&gr_learn_lock);
67915 + if (learn_buffer_len)
67916 + break;
67917 + spin_unlock(&gr_learn_lock);
67918 + mutex_unlock(&gr_learn_user_mutex);
67919 + if (file->f_flags & O_NONBLOCK) {
67920 + retval = -EAGAIN;
67921 + goto out;
67922 + }
67923 + if (signal_pending(current)) {
67924 + retval = -ERESTARTSYS;
67925 + goto out;
67926 + }
67927 +
67928 + schedule();
67929 + } while (1);
67930 +
67931 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67932 + learn_buffer_user_len = learn_buffer_len;
67933 + retval = learn_buffer_len;
67934 + learn_buffer_len = 0;
67935 +
67936 + spin_unlock(&gr_learn_lock);
67937 +
67938 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67939 + retval = -EFAULT;
67940 +
67941 + mutex_unlock(&gr_learn_user_mutex);
67942 +out:
67943 + set_current_state(TASK_RUNNING);
67944 + remove_wait_queue(&learn_wait, &wait);
67945 + return retval;
67946 +}
67947 +
67948 +static unsigned int
67949 +poll_learn(struct file * file, poll_table * wait)
67950 +{
67951 + poll_wait(file, &learn_wait, wait);
67952 +
67953 + if (learn_buffer_len)
67954 + return (POLLIN | POLLRDNORM);
67955 +
67956 + return 0;
67957 +}
67958 +
67959 +void
67960 +gr_clear_learn_entries(void)
67961 +{
67962 + char *tmp;
67963 +
67964 + mutex_lock(&gr_learn_user_mutex);
67965 + spin_lock(&gr_learn_lock);
67966 + tmp = learn_buffer;
67967 + learn_buffer = NULL;
67968 + spin_unlock(&gr_learn_lock);
67969 + if (tmp)
67970 + vfree(tmp);
67971 + if (learn_buffer_user != NULL) {
67972 + vfree(learn_buffer_user);
67973 + learn_buffer_user = NULL;
67974 + }
67975 + learn_buffer_len = 0;
67976 + mutex_unlock(&gr_learn_user_mutex);
67977 +
67978 + return;
67979 +}
67980 +
67981 +void
67982 +gr_add_learn_entry(const char *fmt, ...)
67983 +{
67984 + va_list args;
67985 + unsigned int len;
67986 +
67987 + if (!gr_learn_attached)
67988 + return;
67989 +
67990 + spin_lock(&gr_learn_lock);
67991 +
67992 + /* leave a gap at the end so we know when it's "full" but don't have to
67993 + compute the exact length of the string we're trying to append
67994 + */
67995 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67996 + spin_unlock(&gr_learn_lock);
67997 + wake_up_interruptible(&learn_wait);
67998 + return;
67999 + }
68000 + if (learn_buffer == NULL) {
68001 + spin_unlock(&gr_learn_lock);
68002 + return;
68003 + }
68004 +
68005 + va_start(args, fmt);
68006 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
68007 + va_end(args);
68008 +
68009 + learn_buffer_len += len + 1;
68010 +
68011 + spin_unlock(&gr_learn_lock);
68012 + wake_up_interruptible(&learn_wait);
68013 +
68014 + return;
68015 +}
68016 +
68017 +static int
68018 +open_learn(struct inode *inode, struct file *file)
68019 +{
68020 + if (file->f_mode & FMODE_READ && gr_learn_attached)
68021 + return -EBUSY;
68022 + if (file->f_mode & FMODE_READ) {
68023 + int retval = 0;
68024 + mutex_lock(&gr_learn_user_mutex);
68025 + if (learn_buffer == NULL)
68026 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
68027 + if (learn_buffer_user == NULL)
68028 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
68029 + if (learn_buffer == NULL) {
68030 + retval = -ENOMEM;
68031 + goto out_error;
68032 + }
68033 + if (learn_buffer_user == NULL) {
68034 + retval = -ENOMEM;
68035 + goto out_error;
68036 + }
68037 + learn_buffer_len = 0;
68038 + learn_buffer_user_len = 0;
68039 + gr_learn_attached = 1;
68040 +out_error:
68041 + mutex_unlock(&gr_learn_user_mutex);
68042 + return retval;
68043 + }
68044 + return 0;
68045 +}
68046 +
68047 +static int
68048 +close_learn(struct inode *inode, struct file *file)
68049 +{
68050 + if (file->f_mode & FMODE_READ) {
68051 + char *tmp = NULL;
68052 + mutex_lock(&gr_learn_user_mutex);
68053 + spin_lock(&gr_learn_lock);
68054 + tmp = learn_buffer;
68055 + learn_buffer = NULL;
68056 + spin_unlock(&gr_learn_lock);
68057 + if (tmp)
68058 + vfree(tmp);
68059 + if (learn_buffer_user != NULL) {
68060 + vfree(learn_buffer_user);
68061 + learn_buffer_user = NULL;
68062 + }
68063 + learn_buffer_len = 0;
68064 + learn_buffer_user_len = 0;
68065 + gr_learn_attached = 0;
68066 + mutex_unlock(&gr_learn_user_mutex);
68067 + }
68068 +
68069 + return 0;
68070 +}
68071 +
68072 +const struct file_operations grsec_fops = {
68073 + .read = read_learn,
68074 + .write = write_grsec_handler,
68075 + .open = open_learn,
68076 + .release = close_learn,
68077 + .poll = poll_learn,
68078 +};
68079 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
68080 new file mode 100644
68081 index 0000000..39645c9
68082 --- /dev/null
68083 +++ b/grsecurity/gracl_res.c
68084 @@ -0,0 +1,68 @@
68085 +#include <linux/kernel.h>
68086 +#include <linux/sched.h>
68087 +#include <linux/gracl.h>
68088 +#include <linux/grinternal.h>
68089 +
68090 +static const char *restab_log[] = {
68091 + [RLIMIT_CPU] = "RLIMIT_CPU",
68092 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
68093 + [RLIMIT_DATA] = "RLIMIT_DATA",
68094 + [RLIMIT_STACK] = "RLIMIT_STACK",
68095 + [RLIMIT_CORE] = "RLIMIT_CORE",
68096 + [RLIMIT_RSS] = "RLIMIT_RSS",
68097 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
68098 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
68099 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
68100 + [RLIMIT_AS] = "RLIMIT_AS",
68101 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
68102 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
68103 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
68104 + [RLIMIT_NICE] = "RLIMIT_NICE",
68105 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
68106 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
68107 + [GR_CRASH_RES] = "RLIMIT_CRASH"
68108 +};
68109 +
68110 +void
68111 +gr_log_resource(const struct task_struct *task,
68112 + const int res, const unsigned long wanted, const int gt)
68113 +{
68114 + const struct cred *cred;
68115 + unsigned long rlim;
68116 +
68117 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
68118 + return;
68119 +
68120 + // not yet supported resource
68121 + if (unlikely(!restab_log[res]))
68122 + return;
68123 +
68124 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
68125 + rlim = task_rlimit_max(task, res);
68126 + else
68127 + rlim = task_rlimit(task, res);
68128 +
68129 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
68130 + return;
68131 +
68132 + rcu_read_lock();
68133 + cred = __task_cred(task);
68134 +
68135 + if (res == RLIMIT_NPROC &&
68136 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
68137 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
68138 + goto out_rcu_unlock;
68139 + else if (res == RLIMIT_MEMLOCK &&
68140 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
68141 + goto out_rcu_unlock;
68142 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
68143 + goto out_rcu_unlock;
68144 + rcu_read_unlock();
68145 +
68146 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
68147 +
68148 + return;
68149 +out_rcu_unlock:
68150 + rcu_read_unlock();
68151 + return;
68152 +}
68153 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
68154 new file mode 100644
68155 index 0000000..3c38bfe
68156 --- /dev/null
68157 +++ b/grsecurity/gracl_segv.c
68158 @@ -0,0 +1,305 @@
68159 +#include <linux/kernel.h>
68160 +#include <linux/mm.h>
68161 +#include <asm/uaccess.h>
68162 +#include <asm/errno.h>
68163 +#include <asm/mman.h>
68164 +#include <net/sock.h>
68165 +#include <linux/file.h>
68166 +#include <linux/fs.h>
68167 +#include <linux/net.h>
68168 +#include <linux/in.h>
68169 +#include <linux/slab.h>
68170 +#include <linux/types.h>
68171 +#include <linux/sched.h>
68172 +#include <linux/timer.h>
68173 +#include <linux/gracl.h>
68174 +#include <linux/grsecurity.h>
68175 +#include <linux/grinternal.h>
68176 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68177 +#include <linux/magic.h>
68178 +#include <linux/pagemap.h>
68179 +#include "../fs/btrfs/async-thread.h"
68180 +#include "../fs/btrfs/ctree.h"
68181 +#include "../fs/btrfs/btrfs_inode.h"
68182 +#endif
68183 +
68184 +static struct crash_uid *uid_set;
68185 +static unsigned short uid_used;
68186 +static DEFINE_SPINLOCK(gr_uid_lock);
68187 +extern rwlock_t gr_inode_lock;
68188 +extern struct acl_subject_label *
68189 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
68190 + struct acl_role_label *role);
68191 +
68192 +static inline dev_t __get_dev(const struct dentry *dentry)
68193 +{
68194 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
68195 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
68196 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
68197 + else
68198 +#endif
68199 + return dentry->d_sb->s_dev;
68200 +}
68201 +
68202 +int
68203 +gr_init_uidset(void)
68204 +{
68205 + uid_set =
68206 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
68207 + uid_used = 0;
68208 +
68209 + return uid_set ? 1 : 0;
68210 +}
68211 +
68212 +void
68213 +gr_free_uidset(void)
68214 +{
68215 + if (uid_set)
68216 + kfree(uid_set);
68217 +
68218 + return;
68219 +}
68220 +
68221 +int
68222 +gr_find_uid(const uid_t uid)
68223 +{
68224 + struct crash_uid *tmp = uid_set;
68225 + uid_t buid;
68226 + int low = 0, high = uid_used - 1, mid;
68227 +
68228 + while (high >= low) {
68229 + mid = (low + high) >> 1;
68230 + buid = tmp[mid].uid;
68231 + if (buid == uid)
68232 + return mid;
68233 + if (buid > uid)
68234 + high = mid - 1;
68235 + if (buid < uid)
68236 + low = mid + 1;
68237 + }
68238 +
68239 + return -1;
68240 +}
68241 +
68242 +static __inline__ void
68243 +gr_insertsort(void)
68244 +{
68245 + unsigned short i, j;
68246 + struct crash_uid index;
68247 +
68248 + for (i = 1; i < uid_used; i++) {
68249 + index = uid_set[i];
68250 + j = i;
68251 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
68252 + uid_set[j] = uid_set[j - 1];
68253 + j--;
68254 + }
68255 + uid_set[j] = index;
68256 + }
68257 +
68258 + return;
68259 +}
68260 +
68261 +static __inline__ void
68262 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
68263 +{
68264 + int loc;
68265 + uid_t uid = GR_GLOBAL_UID(kuid);
68266 +
68267 + if (uid_used == GR_UIDTABLE_MAX)
68268 + return;
68269 +
68270 + loc = gr_find_uid(uid);
68271 +
68272 + if (loc >= 0) {
68273 + uid_set[loc].expires = expires;
68274 + return;
68275 + }
68276 +
68277 + uid_set[uid_used].uid = uid;
68278 + uid_set[uid_used].expires = expires;
68279 + uid_used++;
68280 +
68281 + gr_insertsort();
68282 +
68283 + return;
68284 +}
68285 +
68286 +void
68287 +gr_remove_uid(const unsigned short loc)
68288 +{
68289 + unsigned short i;
68290 +
68291 + for (i = loc + 1; i < uid_used; i++)
68292 + uid_set[i - 1] = uid_set[i];
68293 +
68294 + uid_used--;
68295 +
68296 + return;
68297 +}
68298 +
68299 +int
68300 +gr_check_crash_uid(const kuid_t kuid)
68301 +{
68302 + int loc;
68303 + int ret = 0;
68304 + uid_t uid;
68305 +
68306 + if (unlikely(!gr_acl_is_enabled()))
68307 + return 0;
68308 +
68309 + uid = GR_GLOBAL_UID(kuid);
68310 +
68311 + spin_lock(&gr_uid_lock);
68312 + loc = gr_find_uid(uid);
68313 +
68314 + if (loc < 0)
68315 + goto out_unlock;
68316 +
68317 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
68318 + gr_remove_uid(loc);
68319 + else
68320 + ret = 1;
68321 +
68322 +out_unlock:
68323 + spin_unlock(&gr_uid_lock);
68324 + return ret;
68325 +}
68326 +
68327 +static __inline__ int
68328 +proc_is_setxid(const struct cred *cred)
68329 +{
68330 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
68331 + !uid_eq(cred->uid, cred->fsuid))
68332 + return 1;
68333 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
68334 + !gid_eq(cred->gid, cred->fsgid))
68335 + return 1;
68336 +
68337 + return 0;
68338 +}
68339 +
68340 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
68341 +
68342 +void
68343 +gr_handle_crash(struct task_struct *task, const int sig)
68344 +{
68345 + struct acl_subject_label *curr;
68346 + struct task_struct *tsk, *tsk2;
68347 + const struct cred *cred;
68348 + const struct cred *cred2;
68349 +
68350 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
68351 + return;
68352 +
68353 + if (unlikely(!gr_acl_is_enabled()))
68354 + return;
68355 +
68356 + curr = task->acl;
68357 +
68358 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
68359 + return;
68360 +
68361 + if (time_before_eq(curr->expires, get_seconds())) {
68362 + curr->expires = 0;
68363 + curr->crashes = 0;
68364 + }
68365 +
68366 + curr->crashes++;
68367 +
68368 + if (!curr->expires)
68369 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
68370 +
68371 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68372 + time_after(curr->expires, get_seconds())) {
68373 + rcu_read_lock();
68374 + cred = __task_cred(task);
68375 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
68376 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68377 + spin_lock(&gr_uid_lock);
68378 + gr_insert_uid(cred->uid, curr->expires);
68379 + spin_unlock(&gr_uid_lock);
68380 + curr->expires = 0;
68381 + curr->crashes = 0;
68382 + read_lock(&tasklist_lock);
68383 + do_each_thread(tsk2, tsk) {
68384 + cred2 = __task_cred(tsk);
68385 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
68386 + gr_fake_force_sig(SIGKILL, tsk);
68387 + } while_each_thread(tsk2, tsk);
68388 + read_unlock(&tasklist_lock);
68389 + } else {
68390 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
68391 + read_lock(&tasklist_lock);
68392 + read_lock(&grsec_exec_file_lock);
68393 + do_each_thread(tsk2, tsk) {
68394 + if (likely(tsk != task)) {
68395 + // if this thread has the same subject as the one that triggered
68396 + // RES_CRASH and it's the same binary, kill it
68397 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
68398 + gr_fake_force_sig(SIGKILL, tsk);
68399 + }
68400 + } while_each_thread(tsk2, tsk);
68401 + read_unlock(&grsec_exec_file_lock);
68402 + read_unlock(&tasklist_lock);
68403 + }
68404 + rcu_read_unlock();
68405 + }
68406 +
68407 + return;
68408 +}
68409 +
68410 +int
68411 +gr_check_crash_exec(const struct file *filp)
68412 +{
68413 + struct acl_subject_label *curr;
68414 +
68415 + if (unlikely(!gr_acl_is_enabled()))
68416 + return 0;
68417 +
68418 + read_lock(&gr_inode_lock);
68419 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
68420 + __get_dev(filp->f_path.dentry),
68421 + current->role);
68422 + read_unlock(&gr_inode_lock);
68423 +
68424 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
68425 + (!curr->crashes && !curr->expires))
68426 + return 0;
68427 +
68428 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
68429 + time_after(curr->expires, get_seconds()))
68430 + return 1;
68431 + else if (time_before_eq(curr->expires, get_seconds())) {
68432 + curr->crashes = 0;
68433 + curr->expires = 0;
68434 + }
68435 +
68436 + return 0;
68437 +}
68438 +
68439 +void
68440 +gr_handle_alertkill(struct task_struct *task)
68441 +{
68442 + struct acl_subject_label *curracl;
68443 + __u32 curr_ip;
68444 + struct task_struct *p, *p2;
68445 +
68446 + if (unlikely(!gr_acl_is_enabled()))
68447 + return;
68448 +
68449 + curracl = task->acl;
68450 + curr_ip = task->signal->curr_ip;
68451 +
68452 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
68453 + read_lock(&tasklist_lock);
68454 + do_each_thread(p2, p) {
68455 + if (p->signal->curr_ip == curr_ip)
68456 + gr_fake_force_sig(SIGKILL, p);
68457 + } while_each_thread(p2, p);
68458 + read_unlock(&tasklist_lock);
68459 + } else if (curracl->mode & GR_KILLPROC)
68460 + gr_fake_force_sig(SIGKILL, task);
68461 +
68462 + return;
68463 +}
68464 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
68465 new file mode 100644
68466 index 0000000..98011b0
68467 --- /dev/null
68468 +++ b/grsecurity/gracl_shm.c
68469 @@ -0,0 +1,40 @@
68470 +#include <linux/kernel.h>
68471 +#include <linux/mm.h>
68472 +#include <linux/sched.h>
68473 +#include <linux/file.h>
68474 +#include <linux/ipc.h>
68475 +#include <linux/gracl.h>
68476 +#include <linux/grsecurity.h>
68477 +#include <linux/grinternal.h>
68478 +
68479 +int
68480 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68481 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
68482 +{
68483 + struct task_struct *task;
68484 +
68485 + if (!gr_acl_is_enabled())
68486 + return 1;
68487 +
68488 + rcu_read_lock();
68489 + read_lock(&tasklist_lock);
68490 +
68491 + task = find_task_by_vpid(shm_cprid);
68492 +
68493 + if (unlikely(!task))
68494 + task = find_task_by_vpid(shm_lapid);
68495 +
68496 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
68497 + (task_pid_nr(task) == shm_lapid)) &&
68498 + (task->acl->mode & GR_PROTSHM) &&
68499 + (task->acl != current->acl))) {
68500 + read_unlock(&tasklist_lock);
68501 + rcu_read_unlock();
68502 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
68503 + return 0;
68504 + }
68505 + read_unlock(&tasklist_lock);
68506 + rcu_read_unlock();
68507 +
68508 + return 1;
68509 +}
68510 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
68511 new file mode 100644
68512 index 0000000..bc0be01
68513 --- /dev/null
68514 +++ b/grsecurity/grsec_chdir.c
68515 @@ -0,0 +1,19 @@
68516 +#include <linux/kernel.h>
68517 +#include <linux/sched.h>
68518 +#include <linux/fs.h>
68519 +#include <linux/file.h>
68520 +#include <linux/grsecurity.h>
68521 +#include <linux/grinternal.h>
68522 +
68523 +void
68524 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
68525 +{
68526 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
68527 + if ((grsec_enable_chdir && grsec_enable_group &&
68528 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
68529 + !grsec_enable_group)) {
68530 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
68531 + }
68532 +#endif
68533 + return;
68534 +}
68535 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
68536 new file mode 100644
68537 index 0000000..bd6e105
68538 --- /dev/null
68539 +++ b/grsecurity/grsec_chroot.c
68540 @@ -0,0 +1,370 @@
68541 +#include <linux/kernel.h>
68542 +#include <linux/module.h>
68543 +#include <linux/sched.h>
68544 +#include <linux/file.h>
68545 +#include <linux/fs.h>
68546 +#include <linux/mount.h>
68547 +#include <linux/types.h>
68548 +#include "../fs/mount.h"
68549 +#include <linux/grsecurity.h>
68550 +#include <linux/grinternal.h>
68551 +
68552 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68553 +static int gr_init_ran;
68554 +#endif
68555 +
68556 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
68557 +{
68558 +#ifdef CONFIG_GRKERNSEC
68559 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
68560 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
68561 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68562 + && gr_init_ran
68563 +#endif
68564 + )
68565 + task->gr_is_chrooted = 1;
68566 + else {
68567 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
68568 + if (task_pid_nr(task) == 1 && !gr_init_ran)
68569 + gr_init_ran = 1;
68570 +#endif
68571 + task->gr_is_chrooted = 0;
68572 + }
68573 +
68574 + task->gr_chroot_dentry = path->dentry;
68575 +#endif
68576 + return;
68577 +}
68578 +
68579 +void gr_clear_chroot_entries(struct task_struct *task)
68580 +{
68581 +#ifdef CONFIG_GRKERNSEC
68582 + task->gr_is_chrooted = 0;
68583 + task->gr_chroot_dentry = NULL;
68584 +#endif
68585 + return;
68586 +}
68587 +
68588 +int
68589 +gr_handle_chroot_unix(const pid_t pid)
68590 +{
68591 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68592 + struct task_struct *p;
68593 +
68594 + if (unlikely(!grsec_enable_chroot_unix))
68595 + return 1;
68596 +
68597 + if (likely(!proc_is_chrooted(current)))
68598 + return 1;
68599 +
68600 + rcu_read_lock();
68601 + read_lock(&tasklist_lock);
68602 + p = find_task_by_vpid_unrestricted(pid);
68603 + if (unlikely(p && !have_same_root(current, p))) {
68604 + read_unlock(&tasklist_lock);
68605 + rcu_read_unlock();
68606 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
68607 + return 0;
68608 + }
68609 + read_unlock(&tasklist_lock);
68610 + rcu_read_unlock();
68611 +#endif
68612 + return 1;
68613 +}
68614 +
68615 +int
68616 +gr_handle_chroot_nice(void)
68617 +{
68618 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68619 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
68620 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
68621 + return -EPERM;
68622 + }
68623 +#endif
68624 + return 0;
68625 +}
68626 +
68627 +int
68628 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
68629 +{
68630 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68631 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
68632 + && proc_is_chrooted(current)) {
68633 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
68634 + return -EACCES;
68635 + }
68636 +#endif
68637 + return 0;
68638 +}
68639 +
68640 +int
68641 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
68642 +{
68643 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68644 + struct task_struct *p;
68645 + int ret = 0;
68646 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
68647 + return ret;
68648 +
68649 + read_lock(&tasklist_lock);
68650 + do_each_pid_task(pid, type, p) {
68651 + if (!have_same_root(current, p)) {
68652 + ret = 1;
68653 + goto out;
68654 + }
68655 + } while_each_pid_task(pid, type, p);
68656 +out:
68657 + read_unlock(&tasklist_lock);
68658 + return ret;
68659 +#endif
68660 + return 0;
68661 +}
68662 +
68663 +int
68664 +gr_pid_is_chrooted(struct task_struct *p)
68665 +{
68666 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68667 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
68668 + return 0;
68669 +
68670 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
68671 + !have_same_root(current, p)) {
68672 + return 1;
68673 + }
68674 +#endif
68675 + return 0;
68676 +}
68677 +
68678 +EXPORT_SYMBOL(gr_pid_is_chrooted);
68679 +
68680 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
68681 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
68682 +{
68683 + struct path path, currentroot;
68684 + int ret = 0;
68685 +
68686 + path.dentry = (struct dentry *)u_dentry;
68687 + path.mnt = (struct vfsmount *)u_mnt;
68688 + get_fs_root(current->fs, &currentroot);
68689 + if (path_is_under(&path, &currentroot))
68690 + ret = 1;
68691 + path_put(&currentroot);
68692 +
68693 + return ret;
68694 +}
68695 +#endif
68696 +
68697 +int
68698 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
68699 +{
68700 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68701 + if (!grsec_enable_chroot_fchdir)
68702 + return 1;
68703 +
68704 + if (!proc_is_chrooted(current))
68705 + return 1;
68706 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
68707 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
68708 + return 0;
68709 + }
68710 +#endif
68711 + return 1;
68712 +}
68713 +
68714 +int
68715 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
68716 + const time_t shm_createtime)
68717 +{
68718 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68719 + struct task_struct *p;
68720 + time_t starttime;
68721 +
68722 + if (unlikely(!grsec_enable_chroot_shmat))
68723 + return 1;
68724 +
68725 + if (likely(!proc_is_chrooted(current)))
68726 + return 1;
68727 +
68728 + rcu_read_lock();
68729 + read_lock(&tasklist_lock);
68730 +
68731 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
68732 + starttime = p->start_time.tv_sec;
68733 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
68734 + if (have_same_root(current, p)) {
68735 + goto allow;
68736 + } else {
68737 + read_unlock(&tasklist_lock);
68738 + rcu_read_unlock();
68739 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68740 + return 0;
68741 + }
68742 + }
68743 + /* creator exited, pid reuse, fall through to next check */
68744 + }
68745 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
68746 + if (unlikely(!have_same_root(current, p))) {
68747 + read_unlock(&tasklist_lock);
68748 + rcu_read_unlock();
68749 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
68750 + return 0;
68751 + }
68752 + }
68753 +
68754 +allow:
68755 + read_unlock(&tasklist_lock);
68756 + rcu_read_unlock();
68757 +#endif
68758 + return 1;
68759 +}
68760 +
68761 +void
68762 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
68763 +{
68764 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68765 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
68766 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
68767 +#endif
68768 + return;
68769 +}
68770 +
68771 +int
68772 +gr_handle_chroot_mknod(const struct dentry *dentry,
68773 + const struct vfsmount *mnt, const int mode)
68774 +{
68775 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68776 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
68777 + proc_is_chrooted(current)) {
68778 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
68779 + return -EPERM;
68780 + }
68781 +#endif
68782 + return 0;
68783 +}
68784 +
68785 +int
68786 +gr_handle_chroot_mount(const struct dentry *dentry,
68787 + const struct vfsmount *mnt, const char *dev_name)
68788 +{
68789 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68790 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
68791 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
68792 + return -EPERM;
68793 + }
68794 +#endif
68795 + return 0;
68796 +}
68797 +
68798 +int
68799 +gr_handle_chroot_pivot(void)
68800 +{
68801 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68802 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
68803 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
68804 + return -EPERM;
68805 + }
68806 +#endif
68807 + return 0;
68808 +}
68809 +
68810 +int
68811 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
68812 +{
68813 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68814 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
68815 + !gr_is_outside_chroot(dentry, mnt)) {
68816 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
68817 + return -EPERM;
68818 + }
68819 +#endif
68820 + return 0;
68821 +}
68822 +
68823 +extern const char *captab_log[];
68824 +extern int captab_log_entries;
68825 +
68826 +int
68827 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
68828 +{
68829 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68830 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68831 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68832 + if (cap_raised(chroot_caps, cap)) {
68833 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
68834 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
68835 + }
68836 + return 0;
68837 + }
68838 + }
68839 +#endif
68840 + return 1;
68841 +}
68842 +
68843 +int
68844 +gr_chroot_is_capable(const int cap)
68845 +{
68846 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68847 + return gr_task_chroot_is_capable(current, current_cred(), cap);
68848 +#endif
68849 + return 1;
68850 +}
68851 +
68852 +int
68853 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
68854 +{
68855 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68856 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
68857 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
68858 + if (cap_raised(chroot_caps, cap)) {
68859 + return 0;
68860 + }
68861 + }
68862 +#endif
68863 + return 1;
68864 +}
68865 +
68866 +int
68867 +gr_chroot_is_capable_nolog(const int cap)
68868 +{
68869 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68870 + return gr_task_chroot_is_capable_nolog(current, cap);
68871 +#endif
68872 + return 1;
68873 +}
68874 +
68875 +int
68876 +gr_handle_chroot_sysctl(const int op)
68877 +{
68878 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68879 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
68880 + proc_is_chrooted(current))
68881 + return -EACCES;
68882 +#endif
68883 + return 0;
68884 +}
68885 +
68886 +void
68887 +gr_handle_chroot_chdir(const struct path *path)
68888 +{
68889 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68890 + if (grsec_enable_chroot_chdir)
68891 + set_fs_pwd(current->fs, path);
68892 +#endif
68893 + return;
68894 +}
68895 +
68896 +int
68897 +gr_handle_chroot_chmod(const struct dentry *dentry,
68898 + const struct vfsmount *mnt, const int mode)
68899 +{
68900 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68901 + /* allow chmod +s on directories, but not files */
68902 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
68903 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
68904 + proc_is_chrooted(current)) {
68905 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
68906 + return -EPERM;
68907 + }
68908 +#endif
68909 + return 0;
68910 +}
68911 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
68912 new file mode 100644
68913 index 0000000..ce65ceb
68914 --- /dev/null
68915 +++ b/grsecurity/grsec_disabled.c
68916 @@ -0,0 +1,434 @@
68917 +#include <linux/kernel.h>
68918 +#include <linux/module.h>
68919 +#include <linux/sched.h>
68920 +#include <linux/file.h>
68921 +#include <linux/fs.h>
68922 +#include <linux/kdev_t.h>
68923 +#include <linux/net.h>
68924 +#include <linux/in.h>
68925 +#include <linux/ip.h>
68926 +#include <linux/skbuff.h>
68927 +#include <linux/sysctl.h>
68928 +
68929 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
68930 +void
68931 +pax_set_initial_flags(struct linux_binprm *bprm)
68932 +{
68933 + return;
68934 +}
68935 +#endif
68936 +
68937 +#ifdef CONFIG_SYSCTL
68938 +__u32
68939 +gr_handle_sysctl(const struct ctl_table * table, const int op)
68940 +{
68941 + return 0;
68942 +}
68943 +#endif
68944 +
68945 +#ifdef CONFIG_TASKSTATS
68946 +int gr_is_taskstats_denied(int pid)
68947 +{
68948 + return 0;
68949 +}
68950 +#endif
68951 +
68952 +int
68953 +gr_acl_is_enabled(void)
68954 +{
68955 + return 0;
68956 +}
68957 +
68958 +void
68959 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
68960 +{
68961 + return;
68962 +}
68963 +
68964 +int
68965 +gr_handle_rawio(const struct inode *inode)
68966 +{
68967 + return 0;
68968 +}
68969 +
68970 +void
68971 +gr_acl_handle_psacct(struct task_struct *task, const long code)
68972 +{
68973 + return;
68974 +}
68975 +
68976 +int
68977 +gr_handle_ptrace(struct task_struct *task, const long request)
68978 +{
68979 + return 0;
68980 +}
68981 +
68982 +int
68983 +gr_handle_proc_ptrace(struct task_struct *task)
68984 +{
68985 + return 0;
68986 +}
68987 +
68988 +int
68989 +gr_set_acls(const int type)
68990 +{
68991 + return 0;
68992 +}
68993 +
68994 +int
68995 +gr_check_hidden_task(const struct task_struct *tsk)
68996 +{
68997 + return 0;
68998 +}
68999 +
69000 +int
69001 +gr_check_protected_task(const struct task_struct *task)
69002 +{
69003 + return 0;
69004 +}
69005 +
69006 +int
69007 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
69008 +{
69009 + return 0;
69010 +}
69011 +
69012 +void
69013 +gr_copy_label(struct task_struct *tsk)
69014 +{
69015 + return;
69016 +}
69017 +
69018 +void
69019 +gr_set_pax_flags(struct task_struct *task)
69020 +{
69021 + return;
69022 +}
69023 +
69024 +int
69025 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
69026 + const int unsafe_share)
69027 +{
69028 + return 0;
69029 +}
69030 +
69031 +void
69032 +gr_handle_delete(const ino_t ino, const dev_t dev)
69033 +{
69034 + return;
69035 +}
69036 +
69037 +void
69038 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
69039 +{
69040 + return;
69041 +}
69042 +
69043 +void
69044 +gr_handle_crash(struct task_struct *task, const int sig)
69045 +{
69046 + return;
69047 +}
69048 +
69049 +int
69050 +gr_check_crash_exec(const struct file *filp)
69051 +{
69052 + return 0;
69053 +}
69054 +
69055 +int
69056 +gr_check_crash_uid(const kuid_t uid)
69057 +{
69058 + return 0;
69059 +}
69060 +
69061 +void
69062 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69063 + struct dentry *old_dentry,
69064 + struct dentry *new_dentry,
69065 + struct vfsmount *mnt, const __u8 replace)
69066 +{
69067 + return;
69068 +}
69069 +
69070 +int
69071 +gr_search_socket(const int family, const int type, const int protocol)
69072 +{
69073 + return 1;
69074 +}
69075 +
69076 +int
69077 +gr_search_connectbind(const int mode, const struct socket *sock,
69078 + const struct sockaddr_in *addr)
69079 +{
69080 + return 0;
69081 +}
69082 +
69083 +void
69084 +gr_handle_alertkill(struct task_struct *task)
69085 +{
69086 + return;
69087 +}
69088 +
69089 +__u32
69090 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
69091 +{
69092 + return 1;
69093 +}
69094 +
69095 +__u32
69096 +gr_acl_handle_hidden_file(const struct dentry * dentry,
69097 + const struct vfsmount * mnt)
69098 +{
69099 + return 1;
69100 +}
69101 +
69102 +__u32
69103 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
69104 + int acc_mode)
69105 +{
69106 + return 1;
69107 +}
69108 +
69109 +__u32
69110 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
69111 +{
69112 + return 1;
69113 +}
69114 +
69115 +__u32
69116 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
69117 +{
69118 + return 1;
69119 +}
69120 +
69121 +int
69122 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
69123 + unsigned int *vm_flags)
69124 +{
69125 + return 1;
69126 +}
69127 +
69128 +__u32
69129 +gr_acl_handle_truncate(const struct dentry * dentry,
69130 + const struct vfsmount * mnt)
69131 +{
69132 + return 1;
69133 +}
69134 +
69135 +__u32
69136 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
69137 +{
69138 + return 1;
69139 +}
69140 +
69141 +__u32
69142 +gr_acl_handle_access(const struct dentry * dentry,
69143 + const struct vfsmount * mnt, const int fmode)
69144 +{
69145 + return 1;
69146 +}
69147 +
69148 +__u32
69149 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
69150 + umode_t *mode)
69151 +{
69152 + return 1;
69153 +}
69154 +
69155 +__u32
69156 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
69157 +{
69158 + return 1;
69159 +}
69160 +
69161 +__u32
69162 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
69163 +{
69164 + return 1;
69165 +}
69166 +
69167 +void
69168 +grsecurity_init(void)
69169 +{
69170 + return;
69171 +}
69172 +
69173 +umode_t gr_acl_umask(void)
69174 +{
69175 + return 0;
69176 +}
69177 +
69178 +__u32
69179 +gr_acl_handle_mknod(const struct dentry * new_dentry,
69180 + const struct dentry * parent_dentry,
69181 + const struct vfsmount * parent_mnt,
69182 + const int mode)
69183 +{
69184 + return 1;
69185 +}
69186 +
69187 +__u32
69188 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
69189 + const struct dentry * parent_dentry,
69190 + const struct vfsmount * parent_mnt)
69191 +{
69192 + return 1;
69193 +}
69194 +
69195 +__u32
69196 +gr_acl_handle_symlink(const struct dentry * new_dentry,
69197 + const struct dentry * parent_dentry,
69198 + const struct vfsmount * parent_mnt, const struct filename *from)
69199 +{
69200 + return 1;
69201 +}
69202 +
69203 +__u32
69204 +gr_acl_handle_link(const struct dentry * new_dentry,
69205 + const struct dentry * parent_dentry,
69206 + const struct vfsmount * parent_mnt,
69207 + const struct dentry * old_dentry,
69208 + const struct vfsmount * old_mnt, const struct filename *to)
69209 +{
69210 + return 1;
69211 +}
69212 +
69213 +int
69214 +gr_acl_handle_rename(const struct dentry *new_dentry,
69215 + const struct dentry *parent_dentry,
69216 + const struct vfsmount *parent_mnt,
69217 + const struct dentry *old_dentry,
69218 + const struct inode *old_parent_inode,
69219 + const struct vfsmount *old_mnt, const struct filename *newname)
69220 +{
69221 + return 0;
69222 +}
69223 +
69224 +int
69225 +gr_acl_handle_filldir(const struct file *file, const char *name,
69226 + const int namelen, const ino_t ino)
69227 +{
69228 + return 1;
69229 +}
69230 +
69231 +int
69232 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
69233 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
69234 +{
69235 + return 1;
69236 +}
69237 +
69238 +int
69239 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
69240 +{
69241 + return 0;
69242 +}
69243 +
69244 +int
69245 +gr_search_accept(const struct socket *sock)
69246 +{
69247 + return 0;
69248 +}
69249 +
69250 +int
69251 +gr_search_listen(const struct socket *sock)
69252 +{
69253 + return 0;
69254 +}
69255 +
69256 +int
69257 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
69258 +{
69259 + return 0;
69260 +}
69261 +
69262 +__u32
69263 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
69264 +{
69265 + return 1;
69266 +}
69267 +
69268 +__u32
69269 +gr_acl_handle_creat(const struct dentry * dentry,
69270 + const struct dentry * p_dentry,
69271 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
69272 + const int imode)
69273 +{
69274 + return 1;
69275 +}
69276 +
69277 +void
69278 +gr_acl_handle_exit(void)
69279 +{
69280 + return;
69281 +}
69282 +
69283 +int
69284 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
69285 +{
69286 + return 1;
69287 +}
69288 +
69289 +void
69290 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
69291 +{
69292 + return;
69293 +}
69294 +
69295 +int
69296 +gr_acl_handle_procpidmem(const struct task_struct *task)
69297 +{
69298 + return 0;
69299 +}
69300 +
69301 +int
69302 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
69303 +{
69304 + return 0;
69305 +}
69306 +
69307 +int
69308 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
69309 +{
69310 + return 0;
69311 +}
69312 +
69313 +void
69314 +gr_set_kernel_label(struct task_struct *task)
69315 +{
69316 + return;
69317 +}
69318 +
69319 +int
69320 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
69321 +{
69322 + return 0;
69323 +}
69324 +
69325 +int
69326 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
69327 +{
69328 + return 0;
69329 +}
69330 +
69331 +int gr_acl_enable_at_secure(void)
69332 +{
69333 + return 0;
69334 +}
69335 +
69336 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
69337 +{
69338 + return dentry->d_sb->s_dev;
69339 +}
69340 +
69341 +void gr_put_exec_file(struct task_struct *task)
69342 +{
69343 + return;
69344 +}
69345 +
69346 +EXPORT_SYMBOL(gr_set_kernel_label);
69347 +#ifdef CONFIG_SECURITY
69348 +EXPORT_SYMBOL(gr_check_user_change);
69349 +EXPORT_SYMBOL(gr_check_group_change);
69350 +#endif
69351 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
69352 new file mode 100644
69353 index 0000000..387032b
69354 --- /dev/null
69355 +++ b/grsecurity/grsec_exec.c
69356 @@ -0,0 +1,187 @@
69357 +#include <linux/kernel.h>
69358 +#include <linux/sched.h>
69359 +#include <linux/file.h>
69360 +#include <linux/binfmts.h>
69361 +#include <linux/fs.h>
69362 +#include <linux/types.h>
69363 +#include <linux/grdefs.h>
69364 +#include <linux/grsecurity.h>
69365 +#include <linux/grinternal.h>
69366 +#include <linux/capability.h>
69367 +#include <linux/module.h>
69368 +#include <linux/compat.h>
69369 +
69370 +#include <asm/uaccess.h>
69371 +
69372 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69373 +static char gr_exec_arg_buf[132];
69374 +static DEFINE_MUTEX(gr_exec_arg_mutex);
69375 +#endif
69376 +
69377 +struct user_arg_ptr {
69378 +#ifdef CONFIG_COMPAT
69379 + bool is_compat;
69380 +#endif
69381 + union {
69382 + const char __user *const __user *native;
69383 +#ifdef CONFIG_COMPAT
69384 + const compat_uptr_t __user *compat;
69385 +#endif
69386 + } ptr;
69387 +};
69388 +
69389 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
69390 +
69391 +void
69392 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
69393 +{
69394 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69395 + char *grarg = gr_exec_arg_buf;
69396 + unsigned int i, x, execlen = 0;
69397 + char c;
69398 +
69399 + if (!((grsec_enable_execlog && grsec_enable_group &&
69400 + in_group_p(grsec_audit_gid))
69401 + || (grsec_enable_execlog && !grsec_enable_group)))
69402 + return;
69403 +
69404 + mutex_lock(&gr_exec_arg_mutex);
69405 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
69406 +
69407 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
69408 + const char __user *p;
69409 + unsigned int len;
69410 +
69411 + p = get_user_arg_ptr(argv, i);
69412 + if (IS_ERR(p))
69413 + goto log;
69414 +
69415 + len = strnlen_user(p, 128 - execlen);
69416 + if (len > 128 - execlen)
69417 + len = 128 - execlen;
69418 + else if (len > 0)
69419 + len--;
69420 + if (copy_from_user(grarg + execlen, p, len))
69421 + goto log;
69422 +
69423 + /* rewrite unprintable characters */
69424 + for (x = 0; x < len; x++) {
69425 + c = *(grarg + execlen + x);
69426 + if (c < 32 || c > 126)
69427 + *(grarg + execlen + x) = ' ';
69428 + }
69429 +
69430 + execlen += len;
69431 + *(grarg + execlen) = ' ';
69432 + *(grarg + execlen + 1) = '\0';
69433 + execlen++;
69434 + }
69435 +
69436 + log:
69437 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
69438 + bprm->file->f_path.mnt, grarg);
69439 + mutex_unlock(&gr_exec_arg_mutex);
69440 +#endif
69441 + return;
69442 +}
69443 +
69444 +#ifdef CONFIG_GRKERNSEC
69445 +extern int gr_acl_is_capable(const int cap);
69446 +extern int gr_acl_is_capable_nolog(const int cap);
69447 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69448 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
69449 +extern int gr_chroot_is_capable(const int cap);
69450 +extern int gr_chroot_is_capable_nolog(const int cap);
69451 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69452 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
69453 +#endif
69454 +
69455 +const char *captab_log[] = {
69456 + "CAP_CHOWN",
69457 + "CAP_DAC_OVERRIDE",
69458 + "CAP_DAC_READ_SEARCH",
69459 + "CAP_FOWNER",
69460 + "CAP_FSETID",
69461 + "CAP_KILL",
69462 + "CAP_SETGID",
69463 + "CAP_SETUID",
69464 + "CAP_SETPCAP",
69465 + "CAP_LINUX_IMMUTABLE",
69466 + "CAP_NET_BIND_SERVICE",
69467 + "CAP_NET_BROADCAST",
69468 + "CAP_NET_ADMIN",
69469 + "CAP_NET_RAW",
69470 + "CAP_IPC_LOCK",
69471 + "CAP_IPC_OWNER",
69472 + "CAP_SYS_MODULE",
69473 + "CAP_SYS_RAWIO",
69474 + "CAP_SYS_CHROOT",
69475 + "CAP_SYS_PTRACE",
69476 + "CAP_SYS_PACCT",
69477 + "CAP_SYS_ADMIN",
69478 + "CAP_SYS_BOOT",
69479 + "CAP_SYS_NICE",
69480 + "CAP_SYS_RESOURCE",
69481 + "CAP_SYS_TIME",
69482 + "CAP_SYS_TTY_CONFIG",
69483 + "CAP_MKNOD",
69484 + "CAP_LEASE",
69485 + "CAP_AUDIT_WRITE",
69486 + "CAP_AUDIT_CONTROL",
69487 + "CAP_SETFCAP",
69488 + "CAP_MAC_OVERRIDE",
69489 + "CAP_MAC_ADMIN",
69490 + "CAP_SYSLOG",
69491 + "CAP_WAKE_ALARM"
69492 +};
69493 +
69494 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
69495 +
69496 +int gr_is_capable(const int cap)
69497 +{
69498 +#ifdef CONFIG_GRKERNSEC
69499 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
69500 + return 1;
69501 + return 0;
69502 +#else
69503 + return 1;
69504 +#endif
69505 +}
69506 +
69507 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
69508 +{
69509 +#ifdef CONFIG_GRKERNSEC
69510 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
69511 + return 1;
69512 + return 0;
69513 +#else
69514 + return 1;
69515 +#endif
69516 +}
69517 +
69518 +int gr_is_capable_nolog(const int cap)
69519 +{
69520 +#ifdef CONFIG_GRKERNSEC
69521 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
69522 + return 1;
69523 + return 0;
69524 +#else
69525 + return 1;
69526 +#endif
69527 +}
69528 +
69529 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
69530 +{
69531 +#ifdef CONFIG_GRKERNSEC
69532 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
69533 + return 1;
69534 + return 0;
69535 +#else
69536 + return 1;
69537 +#endif
69538 +}
69539 +
69540 +EXPORT_SYMBOL(gr_is_capable);
69541 +EXPORT_SYMBOL(gr_is_capable_nolog);
69542 +EXPORT_SYMBOL(gr_task_is_capable);
69543 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
69544 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
69545 new file mode 100644
69546 index 0000000..06cc6ea
69547 --- /dev/null
69548 +++ b/grsecurity/grsec_fifo.c
69549 @@ -0,0 +1,24 @@
69550 +#include <linux/kernel.h>
69551 +#include <linux/sched.h>
69552 +#include <linux/fs.h>
69553 +#include <linux/file.h>
69554 +#include <linux/grinternal.h>
69555 +
69556 +int
69557 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
69558 + const struct dentry *dir, const int flag, const int acc_mode)
69559 +{
69560 +#ifdef CONFIG_GRKERNSEC_FIFO
69561 + const struct cred *cred = current_cred();
69562 +
69563 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
69564 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
69565 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
69566 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
69567 + if (!inode_permission(dentry->d_inode, acc_mode))
69568 + 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));
69569 + return -EACCES;
69570 + }
69571 +#endif
69572 + return 0;
69573 +}
69574 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
69575 new file mode 100644
69576 index 0000000..8ca18bf
69577 --- /dev/null
69578 +++ b/grsecurity/grsec_fork.c
69579 @@ -0,0 +1,23 @@
69580 +#include <linux/kernel.h>
69581 +#include <linux/sched.h>
69582 +#include <linux/grsecurity.h>
69583 +#include <linux/grinternal.h>
69584 +#include <linux/errno.h>
69585 +
69586 +void
69587 +gr_log_forkfail(const int retval)
69588 +{
69589 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69590 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
69591 + switch (retval) {
69592 + case -EAGAIN:
69593 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
69594 + break;
69595 + case -ENOMEM:
69596 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
69597 + break;
69598 + }
69599 + }
69600 +#endif
69601 + return;
69602 +}
69603 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
69604 new file mode 100644
69605 index 0000000..99a0cb9
69606 --- /dev/null
69607 +++ b/grsecurity/grsec_init.c
69608 @@ -0,0 +1,283 @@
69609 +#include <linux/kernel.h>
69610 +#include <linux/sched.h>
69611 +#include <linux/mm.h>
69612 +#include <linux/gracl.h>
69613 +#include <linux/slab.h>
69614 +#include <linux/vmalloc.h>
69615 +#include <linux/percpu.h>
69616 +#include <linux/module.h>
69617 +
69618 +int grsec_enable_ptrace_readexec;
69619 +int grsec_enable_setxid;
69620 +int grsec_enable_symlinkown;
69621 +kgid_t grsec_symlinkown_gid;
69622 +int grsec_enable_brute;
69623 +int grsec_enable_link;
69624 +int grsec_enable_dmesg;
69625 +int grsec_enable_harden_ptrace;
69626 +int grsec_enable_fifo;
69627 +int grsec_enable_execlog;
69628 +int grsec_enable_signal;
69629 +int grsec_enable_forkfail;
69630 +int grsec_enable_audit_ptrace;
69631 +int grsec_enable_time;
69632 +int grsec_enable_group;
69633 +kgid_t grsec_audit_gid;
69634 +int grsec_enable_chdir;
69635 +int grsec_enable_mount;
69636 +int grsec_enable_rofs;
69637 +int grsec_deny_new_usb;
69638 +int grsec_enable_chroot_findtask;
69639 +int grsec_enable_chroot_mount;
69640 +int grsec_enable_chroot_shmat;
69641 +int grsec_enable_chroot_fchdir;
69642 +int grsec_enable_chroot_double;
69643 +int grsec_enable_chroot_pivot;
69644 +int grsec_enable_chroot_chdir;
69645 +int grsec_enable_chroot_chmod;
69646 +int grsec_enable_chroot_mknod;
69647 +int grsec_enable_chroot_nice;
69648 +int grsec_enable_chroot_execlog;
69649 +int grsec_enable_chroot_caps;
69650 +int grsec_enable_chroot_sysctl;
69651 +int grsec_enable_chroot_unix;
69652 +int grsec_enable_tpe;
69653 +kgid_t grsec_tpe_gid;
69654 +int grsec_enable_blackhole;
69655 +#ifdef CONFIG_IPV6_MODULE
69656 +EXPORT_SYMBOL(grsec_enable_blackhole);
69657 +#endif
69658 +int grsec_lastack_retries;
69659 +int grsec_enable_tpe_all;
69660 +int grsec_enable_tpe_invert;
69661 +int grsec_enable_socket_all;
69662 +kgid_t grsec_socket_all_gid;
69663 +int grsec_enable_socket_client;
69664 +kgid_t grsec_socket_client_gid;
69665 +int grsec_enable_socket_server;
69666 +kgid_t grsec_socket_server_gid;
69667 +int grsec_resource_logging;
69668 +int grsec_disable_privio;
69669 +int grsec_enable_log_rwxmaps;
69670 +int grsec_lock;
69671 +
69672 +DEFINE_SPINLOCK(grsec_alert_lock);
69673 +unsigned long grsec_alert_wtime = 0;
69674 +unsigned long grsec_alert_fyet = 0;
69675 +
69676 +DEFINE_SPINLOCK(grsec_audit_lock);
69677 +
69678 +DEFINE_RWLOCK(grsec_exec_file_lock);
69679 +
69680 +char *gr_shared_page[4];
69681 +
69682 +char *gr_alert_log_fmt;
69683 +char *gr_audit_log_fmt;
69684 +char *gr_alert_log_buf;
69685 +char *gr_audit_log_buf;
69686 +
69687 +extern struct gr_arg *gr_usermode;
69688 +extern unsigned char *gr_system_salt;
69689 +extern unsigned char *gr_system_sum;
69690 +
69691 +void __init
69692 +grsecurity_init(void)
69693 +{
69694 + int j;
69695 + /* create the per-cpu shared pages */
69696 +
69697 +#ifdef CONFIG_X86
69698 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
69699 +#endif
69700 +
69701 + for (j = 0; j < 4; j++) {
69702 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
69703 + if (gr_shared_page[j] == NULL) {
69704 + panic("Unable to allocate grsecurity shared page");
69705 + return;
69706 + }
69707 + }
69708 +
69709 + /* allocate log buffers */
69710 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
69711 + if (!gr_alert_log_fmt) {
69712 + panic("Unable to allocate grsecurity alert log format buffer");
69713 + return;
69714 + }
69715 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
69716 + if (!gr_audit_log_fmt) {
69717 + panic("Unable to allocate grsecurity audit log format buffer");
69718 + return;
69719 + }
69720 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69721 + if (!gr_alert_log_buf) {
69722 + panic("Unable to allocate grsecurity alert log buffer");
69723 + return;
69724 + }
69725 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
69726 + if (!gr_audit_log_buf) {
69727 + panic("Unable to allocate grsecurity audit log buffer");
69728 + return;
69729 + }
69730 +
69731 + /* allocate memory for authentication structure */
69732 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
69733 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
69734 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
69735 +
69736 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
69737 + panic("Unable to allocate grsecurity authentication structure");
69738 + return;
69739 + }
69740 +
69741 +
69742 +#ifdef CONFIG_GRKERNSEC_IO
69743 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
69744 + grsec_disable_privio = 1;
69745 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69746 + grsec_disable_privio = 1;
69747 +#else
69748 + grsec_disable_privio = 0;
69749 +#endif
69750 +#endif
69751 +
69752 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69753 + /* for backward compatibility, tpe_invert always defaults to on if
69754 + enabled in the kernel
69755 + */
69756 + grsec_enable_tpe_invert = 1;
69757 +#endif
69758 +
69759 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
69760 +#ifndef CONFIG_GRKERNSEC_SYSCTL
69761 + grsec_lock = 1;
69762 +#endif
69763 +
69764 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69765 + grsec_enable_log_rwxmaps = 1;
69766 +#endif
69767 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69768 + grsec_enable_group = 1;
69769 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
69770 +#endif
69771 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69772 + grsec_enable_ptrace_readexec = 1;
69773 +#endif
69774 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69775 + grsec_enable_chdir = 1;
69776 +#endif
69777 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69778 + grsec_enable_harden_ptrace = 1;
69779 +#endif
69780 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69781 + grsec_enable_mount = 1;
69782 +#endif
69783 +#ifdef CONFIG_GRKERNSEC_LINK
69784 + grsec_enable_link = 1;
69785 +#endif
69786 +#ifdef CONFIG_GRKERNSEC_BRUTE
69787 + grsec_enable_brute = 1;
69788 +#endif
69789 +#ifdef CONFIG_GRKERNSEC_DMESG
69790 + grsec_enable_dmesg = 1;
69791 +#endif
69792 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69793 + grsec_enable_blackhole = 1;
69794 + grsec_lastack_retries = 4;
69795 +#endif
69796 +#ifdef CONFIG_GRKERNSEC_FIFO
69797 + grsec_enable_fifo = 1;
69798 +#endif
69799 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69800 + grsec_enable_execlog = 1;
69801 +#endif
69802 +#ifdef CONFIG_GRKERNSEC_SETXID
69803 + grsec_enable_setxid = 1;
69804 +#endif
69805 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69806 + grsec_enable_signal = 1;
69807 +#endif
69808 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69809 + grsec_enable_forkfail = 1;
69810 +#endif
69811 +#ifdef CONFIG_GRKERNSEC_TIME
69812 + grsec_enable_time = 1;
69813 +#endif
69814 +#ifdef CONFIG_GRKERNSEC_RESLOG
69815 + grsec_resource_logging = 1;
69816 +#endif
69817 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69818 + grsec_enable_chroot_findtask = 1;
69819 +#endif
69820 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69821 + grsec_enable_chroot_unix = 1;
69822 +#endif
69823 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69824 + grsec_enable_chroot_mount = 1;
69825 +#endif
69826 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69827 + grsec_enable_chroot_fchdir = 1;
69828 +#endif
69829 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69830 + grsec_enable_chroot_shmat = 1;
69831 +#endif
69832 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69833 + grsec_enable_audit_ptrace = 1;
69834 +#endif
69835 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69836 + grsec_enable_chroot_double = 1;
69837 +#endif
69838 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69839 + grsec_enable_chroot_pivot = 1;
69840 +#endif
69841 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69842 + grsec_enable_chroot_chdir = 1;
69843 +#endif
69844 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69845 + grsec_enable_chroot_chmod = 1;
69846 +#endif
69847 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69848 + grsec_enable_chroot_mknod = 1;
69849 +#endif
69850 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69851 + grsec_enable_chroot_nice = 1;
69852 +#endif
69853 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69854 + grsec_enable_chroot_execlog = 1;
69855 +#endif
69856 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69857 + grsec_enable_chroot_caps = 1;
69858 +#endif
69859 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69860 + grsec_enable_chroot_sysctl = 1;
69861 +#endif
69862 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69863 + grsec_enable_symlinkown = 1;
69864 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
69865 +#endif
69866 +#ifdef CONFIG_GRKERNSEC_TPE
69867 + grsec_enable_tpe = 1;
69868 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
69869 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69870 + grsec_enable_tpe_all = 1;
69871 +#endif
69872 +#endif
69873 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69874 + grsec_enable_socket_all = 1;
69875 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
69876 +#endif
69877 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69878 + grsec_enable_socket_client = 1;
69879 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
69880 +#endif
69881 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69882 + grsec_enable_socket_server = 1;
69883 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
69884 +#endif
69885 +#endif
69886 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
69887 + grsec_deny_new_usb = 1;
69888 +#endif
69889 +
69890 + return;
69891 +}
69892 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
69893 new file mode 100644
69894 index 0000000..5e05e20
69895 --- /dev/null
69896 +++ b/grsecurity/grsec_link.c
69897 @@ -0,0 +1,58 @@
69898 +#include <linux/kernel.h>
69899 +#include <linux/sched.h>
69900 +#include <linux/fs.h>
69901 +#include <linux/file.h>
69902 +#include <linux/grinternal.h>
69903 +
69904 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
69905 +{
69906 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69907 + const struct inode *link_inode = link->dentry->d_inode;
69908 +
69909 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
69910 + /* ignore root-owned links, e.g. /proc/self */
69911 + gr_is_global_nonroot(link_inode->i_uid) && target &&
69912 + !uid_eq(link_inode->i_uid, target->i_uid)) {
69913 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
69914 + return 1;
69915 + }
69916 +#endif
69917 + return 0;
69918 +}
69919 +
69920 +int
69921 +gr_handle_follow_link(const struct inode *parent,
69922 + const struct inode *inode,
69923 + const struct dentry *dentry, const struct vfsmount *mnt)
69924 +{
69925 +#ifdef CONFIG_GRKERNSEC_LINK
69926 + const struct cred *cred = current_cred();
69927 +
69928 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
69929 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
69930 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
69931 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
69932 + return -EACCES;
69933 + }
69934 +#endif
69935 + return 0;
69936 +}
69937 +
69938 +int
69939 +gr_handle_hardlink(const struct dentry *dentry,
69940 + const struct vfsmount *mnt,
69941 + struct inode *inode, const int mode, const struct filename *to)
69942 +{
69943 +#ifdef CONFIG_GRKERNSEC_LINK
69944 + const struct cred *cred = current_cred();
69945 +
69946 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
69947 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
69948 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
69949 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
69950 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
69951 + return -EPERM;
69952 + }
69953 +#endif
69954 + return 0;
69955 +}
69956 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
69957 new file mode 100644
69958 index 0000000..dbe0a6b
69959 --- /dev/null
69960 +++ b/grsecurity/grsec_log.c
69961 @@ -0,0 +1,341 @@
69962 +#include <linux/kernel.h>
69963 +#include <linux/sched.h>
69964 +#include <linux/file.h>
69965 +#include <linux/tty.h>
69966 +#include <linux/fs.h>
69967 +#include <linux/mm.h>
69968 +#include <linux/grinternal.h>
69969 +
69970 +#ifdef CONFIG_TREE_PREEMPT_RCU
69971 +#define DISABLE_PREEMPT() preempt_disable()
69972 +#define ENABLE_PREEMPT() preempt_enable()
69973 +#else
69974 +#define DISABLE_PREEMPT()
69975 +#define ENABLE_PREEMPT()
69976 +#endif
69977 +
69978 +#define BEGIN_LOCKS(x) \
69979 + DISABLE_PREEMPT(); \
69980 + rcu_read_lock(); \
69981 + read_lock(&tasklist_lock); \
69982 + read_lock(&grsec_exec_file_lock); \
69983 + if (x != GR_DO_AUDIT) \
69984 + spin_lock(&grsec_alert_lock); \
69985 + else \
69986 + spin_lock(&grsec_audit_lock)
69987 +
69988 +#define END_LOCKS(x) \
69989 + if (x != GR_DO_AUDIT) \
69990 + spin_unlock(&grsec_alert_lock); \
69991 + else \
69992 + spin_unlock(&grsec_audit_lock); \
69993 + read_unlock(&grsec_exec_file_lock); \
69994 + read_unlock(&tasklist_lock); \
69995 + rcu_read_unlock(); \
69996 + ENABLE_PREEMPT(); \
69997 + if (x == GR_DONT_AUDIT) \
69998 + gr_handle_alertkill(current)
69999 +
70000 +enum {
70001 + FLOODING,
70002 + NO_FLOODING
70003 +};
70004 +
70005 +extern char *gr_alert_log_fmt;
70006 +extern char *gr_audit_log_fmt;
70007 +extern char *gr_alert_log_buf;
70008 +extern char *gr_audit_log_buf;
70009 +
70010 +static int gr_log_start(int audit)
70011 +{
70012 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
70013 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
70014 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70015 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
70016 + unsigned long curr_secs = get_seconds();
70017 +
70018 + if (audit == GR_DO_AUDIT)
70019 + goto set_fmt;
70020 +
70021 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
70022 + grsec_alert_wtime = curr_secs;
70023 + grsec_alert_fyet = 0;
70024 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
70025 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
70026 + grsec_alert_fyet++;
70027 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
70028 + grsec_alert_wtime = curr_secs;
70029 + grsec_alert_fyet++;
70030 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
70031 + return FLOODING;
70032 + }
70033 + else return FLOODING;
70034 +
70035 +set_fmt:
70036 +#endif
70037 + memset(buf, 0, PAGE_SIZE);
70038 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
70039 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
70040 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70041 + } else if (current->signal->curr_ip) {
70042 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
70043 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
70044 + } else if (gr_acl_is_enabled()) {
70045 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
70046 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
70047 + } else {
70048 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
70049 + strcpy(buf, fmt);
70050 + }
70051 +
70052 + return NO_FLOODING;
70053 +}
70054 +
70055 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70056 + __attribute__ ((format (printf, 2, 0)));
70057 +
70058 +static void gr_log_middle(int audit, const char *msg, va_list ap)
70059 +{
70060 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70061 + unsigned int len = strlen(buf);
70062 +
70063 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70064 +
70065 + return;
70066 +}
70067 +
70068 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70069 + __attribute__ ((format (printf, 2, 3)));
70070 +
70071 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
70072 +{
70073 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70074 + unsigned int len = strlen(buf);
70075 + va_list ap;
70076 +
70077 + va_start(ap, msg);
70078 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
70079 + va_end(ap);
70080 +
70081 + return;
70082 +}
70083 +
70084 +static void gr_log_end(int audit, int append_default)
70085 +{
70086 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
70087 + if (append_default) {
70088 + struct task_struct *task = current;
70089 + struct task_struct *parent = task->real_parent;
70090 + const struct cred *cred = __task_cred(task);
70091 + const struct cred *pcred = __task_cred(parent);
70092 + unsigned int len = strlen(buf);
70093 +
70094 + 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));
70095 + }
70096 +
70097 + printk("%s\n", buf);
70098 +
70099 + return;
70100 +}
70101 +
70102 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
70103 +{
70104 + int logtype;
70105 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
70106 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
70107 + void *voidptr = NULL;
70108 + int num1 = 0, num2 = 0;
70109 + unsigned long ulong1 = 0, ulong2 = 0;
70110 + struct dentry *dentry = NULL;
70111 + struct vfsmount *mnt = NULL;
70112 + struct file *file = NULL;
70113 + struct task_struct *task = NULL;
70114 + struct vm_area_struct *vma = NULL;
70115 + const struct cred *cred, *pcred;
70116 + va_list ap;
70117 +
70118 + BEGIN_LOCKS(audit);
70119 + logtype = gr_log_start(audit);
70120 + if (logtype == FLOODING) {
70121 + END_LOCKS(audit);
70122 + return;
70123 + }
70124 + va_start(ap, argtypes);
70125 + switch (argtypes) {
70126 + case GR_TTYSNIFF:
70127 + task = va_arg(ap, struct task_struct *);
70128 + 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));
70129 + break;
70130 + case GR_SYSCTL_HIDDEN:
70131 + str1 = va_arg(ap, char *);
70132 + gr_log_middle_varargs(audit, msg, result, str1);
70133 + break;
70134 + case GR_RBAC:
70135 + dentry = va_arg(ap, struct dentry *);
70136 + mnt = va_arg(ap, struct vfsmount *);
70137 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
70138 + break;
70139 + case GR_RBAC_STR:
70140 + dentry = va_arg(ap, struct dentry *);
70141 + mnt = va_arg(ap, struct vfsmount *);
70142 + str1 = va_arg(ap, char *);
70143 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
70144 + break;
70145 + case GR_STR_RBAC:
70146 + str1 = va_arg(ap, char *);
70147 + dentry = va_arg(ap, struct dentry *);
70148 + mnt = va_arg(ap, struct vfsmount *);
70149 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
70150 + break;
70151 + case GR_RBAC_MODE2:
70152 + dentry = va_arg(ap, struct dentry *);
70153 + mnt = va_arg(ap, struct vfsmount *);
70154 + str1 = va_arg(ap, char *);
70155 + str2 = va_arg(ap, char *);
70156 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
70157 + break;
70158 + case GR_RBAC_MODE3:
70159 + dentry = va_arg(ap, struct dentry *);
70160 + mnt = va_arg(ap, struct vfsmount *);
70161 + str1 = va_arg(ap, char *);
70162 + str2 = va_arg(ap, char *);
70163 + str3 = va_arg(ap, char *);
70164 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
70165 + break;
70166 + case GR_FILENAME:
70167 + dentry = va_arg(ap, struct dentry *);
70168 + mnt = va_arg(ap, struct vfsmount *);
70169 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
70170 + break;
70171 + case GR_STR_FILENAME:
70172 + str1 = va_arg(ap, char *);
70173 + dentry = va_arg(ap, struct dentry *);
70174 + mnt = va_arg(ap, struct vfsmount *);
70175 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
70176 + break;
70177 + case GR_FILENAME_STR:
70178 + dentry = va_arg(ap, struct dentry *);
70179 + mnt = va_arg(ap, struct vfsmount *);
70180 + str1 = va_arg(ap, char *);
70181 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
70182 + break;
70183 + case GR_FILENAME_TWO_INT:
70184 + dentry = va_arg(ap, struct dentry *);
70185 + mnt = va_arg(ap, struct vfsmount *);
70186 + num1 = va_arg(ap, int);
70187 + num2 = va_arg(ap, int);
70188 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
70189 + break;
70190 + case GR_FILENAME_TWO_INT_STR:
70191 + dentry = va_arg(ap, struct dentry *);
70192 + mnt = va_arg(ap, struct vfsmount *);
70193 + num1 = va_arg(ap, int);
70194 + num2 = va_arg(ap, int);
70195 + str1 = va_arg(ap, char *);
70196 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
70197 + break;
70198 + case GR_TEXTREL:
70199 + file = va_arg(ap, struct file *);
70200 + ulong1 = va_arg(ap, unsigned long);
70201 + ulong2 = va_arg(ap, unsigned long);
70202 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
70203 + break;
70204 + case GR_PTRACE:
70205 + task = va_arg(ap, struct task_struct *);
70206 + 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));
70207 + break;
70208 + case GR_RESOURCE:
70209 + task = va_arg(ap, struct task_struct *);
70210 + cred = __task_cred(task);
70211 + pcred = __task_cred(task->real_parent);
70212 + ulong1 = va_arg(ap, unsigned long);
70213 + str1 = va_arg(ap, char *);
70214 + ulong2 = va_arg(ap, unsigned long);
70215 + 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));
70216 + break;
70217 + case GR_CAP:
70218 + task = va_arg(ap, struct task_struct *);
70219 + cred = __task_cred(task);
70220 + pcred = __task_cred(task->real_parent);
70221 + str1 = va_arg(ap, char *);
70222 + 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));
70223 + break;
70224 + case GR_SIG:
70225 + str1 = va_arg(ap, char *);
70226 + voidptr = va_arg(ap, void *);
70227 + gr_log_middle_varargs(audit, msg, str1, voidptr);
70228 + break;
70229 + case GR_SIG2:
70230 + task = va_arg(ap, struct task_struct *);
70231 + cred = __task_cred(task);
70232 + pcred = __task_cred(task->real_parent);
70233 + num1 = va_arg(ap, int);
70234 + 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));
70235 + break;
70236 + case GR_CRASH1:
70237 + task = va_arg(ap, struct task_struct *);
70238 + cred = __task_cred(task);
70239 + pcred = __task_cred(task->real_parent);
70240 + ulong1 = va_arg(ap, unsigned long);
70241 + 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);
70242 + break;
70243 + case GR_CRASH2:
70244 + task = va_arg(ap, struct task_struct *);
70245 + cred = __task_cred(task);
70246 + pcred = __task_cred(task->real_parent);
70247 + ulong1 = va_arg(ap, unsigned long);
70248 + 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);
70249 + break;
70250 + case GR_RWXMAP:
70251 + file = va_arg(ap, struct file *);
70252 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
70253 + break;
70254 + case GR_RWXMAPVMA:
70255 + vma = va_arg(ap, struct vm_area_struct *);
70256 + if (vma->vm_file)
70257 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
70258 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
70259 + str1 = "<stack>";
70260 + else if (vma->vm_start <= current->mm->brk &&
70261 + vma->vm_end >= current->mm->start_brk)
70262 + str1 = "<heap>";
70263 + else
70264 + str1 = "<anonymous mapping>";
70265 + gr_log_middle_varargs(audit, msg, str1);
70266 + break;
70267 + case GR_PSACCT:
70268 + {
70269 + unsigned int wday, cday;
70270 + __u8 whr, chr;
70271 + __u8 wmin, cmin;
70272 + __u8 wsec, csec;
70273 + char cur_tty[64] = { 0 };
70274 + char parent_tty[64] = { 0 };
70275 +
70276 + task = va_arg(ap, struct task_struct *);
70277 + wday = va_arg(ap, unsigned int);
70278 + cday = va_arg(ap, unsigned int);
70279 + whr = va_arg(ap, int);
70280 + chr = va_arg(ap, int);
70281 + wmin = va_arg(ap, int);
70282 + cmin = va_arg(ap, int);
70283 + wsec = va_arg(ap, int);
70284 + csec = va_arg(ap, int);
70285 + ulong1 = va_arg(ap, unsigned long);
70286 + cred = __task_cred(task);
70287 + pcred = __task_cred(task->real_parent);
70288 +
70289 + 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));
70290 + }
70291 + break;
70292 + default:
70293 + gr_log_middle(audit, msg, ap);
70294 + }
70295 + va_end(ap);
70296 + // these don't need DEFAULTSECARGS printed on the end
70297 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
70298 + gr_log_end(audit, 0);
70299 + else
70300 + gr_log_end(audit, 1);
70301 + END_LOCKS(audit);
70302 +}
70303 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
70304 new file mode 100644
70305 index 0000000..f536303
70306 --- /dev/null
70307 +++ b/grsecurity/grsec_mem.c
70308 @@ -0,0 +1,40 @@
70309 +#include <linux/kernel.h>
70310 +#include <linux/sched.h>
70311 +#include <linux/mm.h>
70312 +#include <linux/mman.h>
70313 +#include <linux/grinternal.h>
70314 +
70315 +void
70316 +gr_handle_ioperm(void)
70317 +{
70318 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
70319 + return;
70320 +}
70321 +
70322 +void
70323 +gr_handle_iopl(void)
70324 +{
70325 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
70326 + return;
70327 +}
70328 +
70329 +void
70330 +gr_handle_mem_readwrite(u64 from, u64 to)
70331 +{
70332 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
70333 + return;
70334 +}
70335 +
70336 +void
70337 +gr_handle_vm86(void)
70338 +{
70339 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
70340 + return;
70341 +}
70342 +
70343 +void
70344 +gr_log_badprocpid(const char *entry)
70345 +{
70346 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
70347 + return;
70348 +}
70349 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
70350 new file mode 100644
70351 index 0000000..2131422
70352 --- /dev/null
70353 +++ b/grsecurity/grsec_mount.c
70354 @@ -0,0 +1,62 @@
70355 +#include <linux/kernel.h>
70356 +#include <linux/sched.h>
70357 +#include <linux/mount.h>
70358 +#include <linux/grsecurity.h>
70359 +#include <linux/grinternal.h>
70360 +
70361 +void
70362 +gr_log_remount(const char *devname, const int retval)
70363 +{
70364 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70365 + if (grsec_enable_mount && (retval >= 0))
70366 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
70367 +#endif
70368 + return;
70369 +}
70370 +
70371 +void
70372 +gr_log_unmount(const char *devname, const int retval)
70373 +{
70374 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70375 + if (grsec_enable_mount && (retval >= 0))
70376 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
70377 +#endif
70378 + return;
70379 +}
70380 +
70381 +void
70382 +gr_log_mount(const char *from, const char *to, const int retval)
70383 +{
70384 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
70385 + if (grsec_enable_mount && (retval >= 0))
70386 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
70387 +#endif
70388 + return;
70389 +}
70390 +
70391 +int
70392 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
70393 +{
70394 +#ifdef CONFIG_GRKERNSEC_ROFS
70395 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
70396 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
70397 + return -EPERM;
70398 + } else
70399 + return 0;
70400 +#endif
70401 + return 0;
70402 +}
70403 +
70404 +int
70405 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
70406 +{
70407 +#ifdef CONFIG_GRKERNSEC_ROFS
70408 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
70409 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
70410 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
70411 + return -EPERM;
70412 + } else
70413 + return 0;
70414 +#endif
70415 + return 0;
70416 +}
70417 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
70418 new file mode 100644
70419 index 0000000..6ee9d50
70420 --- /dev/null
70421 +++ b/grsecurity/grsec_pax.c
70422 @@ -0,0 +1,45 @@
70423 +#include <linux/kernel.h>
70424 +#include <linux/sched.h>
70425 +#include <linux/mm.h>
70426 +#include <linux/file.h>
70427 +#include <linux/grinternal.h>
70428 +#include <linux/grsecurity.h>
70429 +
70430 +void
70431 +gr_log_textrel(struct vm_area_struct * vma)
70432 +{
70433 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70434 + if (grsec_enable_log_rwxmaps)
70435 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
70436 +#endif
70437 + return;
70438 +}
70439 +
70440 +void gr_log_ptgnustack(struct file *file)
70441 +{
70442 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70443 + if (grsec_enable_log_rwxmaps)
70444 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
70445 +#endif
70446 + return;
70447 +}
70448 +
70449 +void
70450 +gr_log_rwxmmap(struct file *file)
70451 +{
70452 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70453 + if (grsec_enable_log_rwxmaps)
70454 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
70455 +#endif
70456 + return;
70457 +}
70458 +
70459 +void
70460 +gr_log_rwxmprotect(struct vm_area_struct *vma)
70461 +{
70462 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
70463 + if (grsec_enable_log_rwxmaps)
70464 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
70465 +#endif
70466 + return;
70467 +}
70468 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
70469 new file mode 100644
70470 index 0000000..f7f29aa
70471 --- /dev/null
70472 +++ b/grsecurity/grsec_ptrace.c
70473 @@ -0,0 +1,30 @@
70474 +#include <linux/kernel.h>
70475 +#include <linux/sched.h>
70476 +#include <linux/grinternal.h>
70477 +#include <linux/security.h>
70478 +
70479 +void
70480 +gr_audit_ptrace(struct task_struct *task)
70481 +{
70482 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
70483 + if (grsec_enable_audit_ptrace)
70484 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
70485 +#endif
70486 + return;
70487 +}
70488 +
70489 +int
70490 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
70491 +{
70492 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
70493 + const struct dentry *dentry = file->f_path.dentry;
70494 + const struct vfsmount *mnt = file->f_path.mnt;
70495 +
70496 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
70497 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
70498 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
70499 + return -EACCES;
70500 + }
70501 +#endif
70502 + return 0;
70503 +}
70504 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
70505 new file mode 100644
70506 index 0000000..4e29cc7
70507 --- /dev/null
70508 +++ b/grsecurity/grsec_sig.c
70509 @@ -0,0 +1,246 @@
70510 +#include <linux/kernel.h>
70511 +#include <linux/sched.h>
70512 +#include <linux/fs.h>
70513 +#include <linux/delay.h>
70514 +#include <linux/grsecurity.h>
70515 +#include <linux/grinternal.h>
70516 +#include <linux/hardirq.h>
70517 +
70518 +char *signames[] = {
70519 + [SIGSEGV] = "Segmentation fault",
70520 + [SIGILL] = "Illegal instruction",
70521 + [SIGABRT] = "Abort",
70522 + [SIGBUS] = "Invalid alignment/Bus error"
70523 +};
70524 +
70525 +void
70526 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
70527 +{
70528 +#ifdef CONFIG_GRKERNSEC_SIGNAL
70529 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
70530 + (sig == SIGABRT) || (sig == SIGBUS))) {
70531 + if (task_pid_nr(t) == task_pid_nr(current)) {
70532 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
70533 + } else {
70534 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
70535 + }
70536 + }
70537 +#endif
70538 + return;
70539 +}
70540 +
70541 +int
70542 +gr_handle_signal(const struct task_struct *p, const int sig)
70543 +{
70544 +#ifdef CONFIG_GRKERNSEC
70545 + /* ignore the 0 signal for protected task checks */
70546 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
70547 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
70548 + return -EPERM;
70549 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
70550 + return -EPERM;
70551 + }
70552 +#endif
70553 + return 0;
70554 +}
70555 +
70556 +#ifdef CONFIG_GRKERNSEC
70557 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
70558 +
70559 +int gr_fake_force_sig(int sig, struct task_struct *t)
70560 +{
70561 + unsigned long int flags;
70562 + int ret, blocked, ignored;
70563 + struct k_sigaction *action;
70564 +
70565 + spin_lock_irqsave(&t->sighand->siglock, flags);
70566 + action = &t->sighand->action[sig-1];
70567 + ignored = action->sa.sa_handler == SIG_IGN;
70568 + blocked = sigismember(&t->blocked, sig);
70569 + if (blocked || ignored) {
70570 + action->sa.sa_handler = SIG_DFL;
70571 + if (blocked) {
70572 + sigdelset(&t->blocked, sig);
70573 + recalc_sigpending_and_wake(t);
70574 + }
70575 + }
70576 + if (action->sa.sa_handler == SIG_DFL)
70577 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
70578 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
70579 +
70580 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
70581 +
70582 + return ret;
70583 +}
70584 +#endif
70585 +
70586 +#ifdef CONFIG_GRKERNSEC_BRUTE
70587 +#define GR_USER_BAN_TIME (15 * 60)
70588 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
70589 +
70590 +static int __get_dumpable(unsigned long mm_flags)
70591 +{
70592 + int ret;
70593 +
70594 + ret = mm_flags & MMF_DUMPABLE_MASK;
70595 + return (ret >= 2) ? 2 : ret;
70596 +}
70597 +#endif
70598 +
70599 +void gr_handle_brute_attach(unsigned long mm_flags)
70600 +{
70601 +#ifdef CONFIG_GRKERNSEC_BRUTE
70602 + struct task_struct *p = current;
70603 + kuid_t uid = GLOBAL_ROOT_UID;
70604 + int daemon = 0;
70605 +
70606 + if (!grsec_enable_brute)
70607 + return;
70608 +
70609 + rcu_read_lock();
70610 + read_lock(&tasklist_lock);
70611 + read_lock(&grsec_exec_file_lock);
70612 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
70613 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
70614 + p->real_parent->brute = 1;
70615 + daemon = 1;
70616 + } else {
70617 + const struct cred *cred = __task_cred(p), *cred2;
70618 + struct task_struct *tsk, *tsk2;
70619 +
70620 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
70621 + struct user_struct *user;
70622 +
70623 + uid = cred->uid;
70624 +
70625 + /* this is put upon execution past expiration */
70626 + user = find_user(uid);
70627 + if (user == NULL)
70628 + goto unlock;
70629 + user->suid_banned = 1;
70630 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
70631 + if (user->suid_ban_expires == ~0UL)
70632 + user->suid_ban_expires--;
70633 +
70634 + /* only kill other threads of the same binary, from the same user */
70635 + do_each_thread(tsk2, tsk) {
70636 + cred2 = __task_cred(tsk);
70637 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
70638 + gr_fake_force_sig(SIGKILL, tsk);
70639 + } while_each_thread(tsk2, tsk);
70640 + }
70641 + }
70642 +unlock:
70643 + read_unlock(&grsec_exec_file_lock);
70644 + read_unlock(&tasklist_lock);
70645 + rcu_read_unlock();
70646 +
70647 + if (gr_is_global_nonroot(uid))
70648 + 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);
70649 + else if (daemon)
70650 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
70651 +
70652 +#endif
70653 + return;
70654 +}
70655 +
70656 +void gr_handle_brute_check(void)
70657 +{
70658 +#ifdef CONFIG_GRKERNSEC_BRUTE
70659 + struct task_struct *p = current;
70660 +
70661 + if (unlikely(p->brute)) {
70662 + if (!grsec_enable_brute)
70663 + p->brute = 0;
70664 + else if (time_before(get_seconds(), p->brute_expires))
70665 + msleep(30 * 1000);
70666 + }
70667 +#endif
70668 + return;
70669 +}
70670 +
70671 +void gr_handle_kernel_exploit(void)
70672 +{
70673 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70674 + const struct cred *cred;
70675 + struct task_struct *tsk, *tsk2;
70676 + struct user_struct *user;
70677 + kuid_t uid;
70678 +
70679 + if (in_irq() || in_serving_softirq() || in_nmi())
70680 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
70681 +
70682 + uid = current_uid();
70683 +
70684 + if (gr_is_global_root(uid))
70685 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
70686 + else {
70687 + /* kill all the processes of this user, hold a reference
70688 + to their creds struct, and prevent them from creating
70689 + another process until system reset
70690 + */
70691 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
70692 + GR_GLOBAL_UID(uid));
70693 + /* we intentionally leak this ref */
70694 + user = get_uid(current->cred->user);
70695 + if (user)
70696 + user->kernel_banned = 1;
70697 +
70698 + /* kill all processes of this user */
70699 + read_lock(&tasklist_lock);
70700 + do_each_thread(tsk2, tsk) {
70701 + cred = __task_cred(tsk);
70702 + if (uid_eq(cred->uid, uid))
70703 + gr_fake_force_sig(SIGKILL, tsk);
70704 + } while_each_thread(tsk2, tsk);
70705 + read_unlock(&tasklist_lock);
70706 + }
70707 +#endif
70708 +}
70709 +
70710 +#ifdef CONFIG_GRKERNSEC_BRUTE
70711 +static bool suid_ban_expired(struct user_struct *user)
70712 +{
70713 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
70714 + user->suid_banned = 0;
70715 + user->suid_ban_expires = 0;
70716 + free_uid(user);
70717 + return true;
70718 + }
70719 +
70720 + return false;
70721 +}
70722 +#endif
70723 +
70724 +int gr_process_kernel_exec_ban(void)
70725 +{
70726 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70727 + if (unlikely(current->cred->user->kernel_banned))
70728 + return -EPERM;
70729 +#endif
70730 + return 0;
70731 +}
70732 +
70733 +int gr_process_kernel_setuid_ban(struct user_struct *user)
70734 +{
70735 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
70736 + if (unlikely(user->kernel_banned))
70737 + gr_fake_force_sig(SIGKILL, current);
70738 +#endif
70739 + return 0;
70740 +}
70741 +
70742 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
70743 +{
70744 +#ifdef CONFIG_GRKERNSEC_BRUTE
70745 + struct user_struct *user = current->cred->user;
70746 + if (unlikely(user->suid_banned)) {
70747 + if (suid_ban_expired(user))
70748 + return 0;
70749 + /* disallow execution of suid binaries only */
70750 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
70751 + return -EPERM;
70752 + }
70753 +#endif
70754 + return 0;
70755 +}
70756 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
70757 new file mode 100644
70758 index 0000000..4030d57
70759 --- /dev/null
70760 +++ b/grsecurity/grsec_sock.c
70761 @@ -0,0 +1,244 @@
70762 +#include <linux/kernel.h>
70763 +#include <linux/module.h>
70764 +#include <linux/sched.h>
70765 +#include <linux/file.h>
70766 +#include <linux/net.h>
70767 +#include <linux/in.h>
70768 +#include <linux/ip.h>
70769 +#include <net/sock.h>
70770 +#include <net/inet_sock.h>
70771 +#include <linux/grsecurity.h>
70772 +#include <linux/grinternal.h>
70773 +#include <linux/gracl.h>
70774 +
70775 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
70776 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
70777 +
70778 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
70779 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
70780 +
70781 +#ifdef CONFIG_UNIX_MODULE
70782 +EXPORT_SYMBOL(gr_acl_handle_unix);
70783 +EXPORT_SYMBOL(gr_acl_handle_mknod);
70784 +EXPORT_SYMBOL(gr_handle_chroot_unix);
70785 +EXPORT_SYMBOL(gr_handle_create);
70786 +#endif
70787 +
70788 +#ifdef CONFIG_GRKERNSEC
70789 +#define gr_conn_table_size 32749
70790 +struct conn_table_entry {
70791 + struct conn_table_entry *next;
70792 + struct signal_struct *sig;
70793 +};
70794 +
70795 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
70796 +DEFINE_SPINLOCK(gr_conn_table_lock);
70797 +
70798 +extern const char * gr_socktype_to_name(unsigned char type);
70799 +extern const char * gr_proto_to_name(unsigned char proto);
70800 +extern const char * gr_sockfamily_to_name(unsigned char family);
70801 +
70802 +static __inline__ int
70803 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
70804 +{
70805 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
70806 +}
70807 +
70808 +static __inline__ int
70809 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
70810 + __u16 sport, __u16 dport)
70811 +{
70812 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
70813 + sig->gr_sport == sport && sig->gr_dport == dport))
70814 + return 1;
70815 + else
70816 + return 0;
70817 +}
70818 +
70819 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
70820 +{
70821 + struct conn_table_entry **match;
70822 + unsigned int index;
70823 +
70824 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70825 + sig->gr_sport, sig->gr_dport,
70826 + gr_conn_table_size);
70827 +
70828 + newent->sig = sig;
70829 +
70830 + match = &gr_conn_table[index];
70831 + newent->next = *match;
70832 + *match = newent;
70833 +
70834 + return;
70835 +}
70836 +
70837 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
70838 +{
70839 + struct conn_table_entry *match, *last = NULL;
70840 + unsigned int index;
70841 +
70842 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
70843 + sig->gr_sport, sig->gr_dport,
70844 + gr_conn_table_size);
70845 +
70846 + match = gr_conn_table[index];
70847 + while (match && !conn_match(match->sig,
70848 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
70849 + sig->gr_dport)) {
70850 + last = match;
70851 + match = match->next;
70852 + }
70853 +
70854 + if (match) {
70855 + if (last)
70856 + last->next = match->next;
70857 + else
70858 + gr_conn_table[index] = NULL;
70859 + kfree(match);
70860 + }
70861 +
70862 + return;
70863 +}
70864 +
70865 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
70866 + __u16 sport, __u16 dport)
70867 +{
70868 + struct conn_table_entry *match;
70869 + unsigned int index;
70870 +
70871 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
70872 +
70873 + match = gr_conn_table[index];
70874 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
70875 + match = match->next;
70876 +
70877 + if (match)
70878 + return match->sig;
70879 + else
70880 + return NULL;
70881 +}
70882 +
70883 +#endif
70884 +
70885 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
70886 +{
70887 +#ifdef CONFIG_GRKERNSEC
70888 + struct signal_struct *sig = task->signal;
70889 + struct conn_table_entry *newent;
70890 +
70891 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
70892 + if (newent == NULL)
70893 + return;
70894 + /* no bh lock needed since we are called with bh disabled */
70895 + spin_lock(&gr_conn_table_lock);
70896 + gr_del_task_from_ip_table_nolock(sig);
70897 + sig->gr_saddr = inet->inet_rcv_saddr;
70898 + sig->gr_daddr = inet->inet_daddr;
70899 + sig->gr_sport = inet->inet_sport;
70900 + sig->gr_dport = inet->inet_dport;
70901 + gr_add_to_task_ip_table_nolock(sig, newent);
70902 + spin_unlock(&gr_conn_table_lock);
70903 +#endif
70904 + return;
70905 +}
70906 +
70907 +void gr_del_task_from_ip_table(struct task_struct *task)
70908 +{
70909 +#ifdef CONFIG_GRKERNSEC
70910 + spin_lock_bh(&gr_conn_table_lock);
70911 + gr_del_task_from_ip_table_nolock(task->signal);
70912 + spin_unlock_bh(&gr_conn_table_lock);
70913 +#endif
70914 + return;
70915 +}
70916 +
70917 +void
70918 +gr_attach_curr_ip(const struct sock *sk)
70919 +{
70920 +#ifdef CONFIG_GRKERNSEC
70921 + struct signal_struct *p, *set;
70922 + const struct inet_sock *inet = inet_sk(sk);
70923 +
70924 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
70925 + return;
70926 +
70927 + set = current->signal;
70928 +
70929 + spin_lock_bh(&gr_conn_table_lock);
70930 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
70931 + inet->inet_dport, inet->inet_sport);
70932 + if (unlikely(p != NULL)) {
70933 + set->curr_ip = p->curr_ip;
70934 + set->used_accept = 1;
70935 + gr_del_task_from_ip_table_nolock(p);
70936 + spin_unlock_bh(&gr_conn_table_lock);
70937 + return;
70938 + }
70939 + spin_unlock_bh(&gr_conn_table_lock);
70940 +
70941 + set->curr_ip = inet->inet_daddr;
70942 + set->used_accept = 1;
70943 +#endif
70944 + return;
70945 +}
70946 +
70947 +int
70948 +gr_handle_sock_all(const int family, const int type, const int protocol)
70949 +{
70950 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
70951 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
70952 + (family != AF_UNIX)) {
70953 + if (family == AF_INET)
70954 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
70955 + else
70956 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
70957 + return -EACCES;
70958 + }
70959 +#endif
70960 + return 0;
70961 +}
70962 +
70963 +int
70964 +gr_handle_sock_server(const struct sockaddr *sck)
70965 +{
70966 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70967 + if (grsec_enable_socket_server &&
70968 + in_group_p(grsec_socket_server_gid) &&
70969 + sck && (sck->sa_family != AF_UNIX) &&
70970 + (sck->sa_family != AF_LOCAL)) {
70971 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70972 + return -EACCES;
70973 + }
70974 +#endif
70975 + return 0;
70976 +}
70977 +
70978 +int
70979 +gr_handle_sock_server_other(const struct sock *sck)
70980 +{
70981 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
70982 + if (grsec_enable_socket_server &&
70983 + in_group_p(grsec_socket_server_gid) &&
70984 + sck && (sck->sk_family != AF_UNIX) &&
70985 + (sck->sk_family != AF_LOCAL)) {
70986 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
70987 + return -EACCES;
70988 + }
70989 +#endif
70990 + return 0;
70991 +}
70992 +
70993 +int
70994 +gr_handle_sock_client(const struct sockaddr *sck)
70995 +{
70996 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
70997 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
70998 + sck && (sck->sa_family != AF_UNIX) &&
70999 + (sck->sa_family != AF_LOCAL)) {
71000 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
71001 + return -EACCES;
71002 + }
71003 +#endif
71004 + return 0;
71005 +}
71006 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
71007 new file mode 100644
71008 index 0000000..a147ae7
71009 --- /dev/null
71010 +++ b/grsecurity/grsec_sysctl.c
71011 @@ -0,0 +1,470 @@
71012 +#include <linux/kernel.h>
71013 +#include <linux/sched.h>
71014 +#include <linux/sysctl.h>
71015 +#include <linux/grsecurity.h>
71016 +#include <linux/grinternal.h>
71017 +
71018 +int
71019 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
71020 +{
71021 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71022 + if (dirname == NULL || name == NULL)
71023 + return 0;
71024 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
71025 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
71026 + return -EACCES;
71027 + }
71028 +#endif
71029 + return 0;
71030 +}
71031 +
71032 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
71033 +static int __maybe_unused __read_only one = 1;
71034 +#endif
71035 +
71036 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
71037 + defined(CONFIG_GRKERNSEC_DENYUSB)
71038 +struct ctl_table grsecurity_table[] = {
71039 +#ifdef CONFIG_GRKERNSEC_SYSCTL
71040 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
71041 +#ifdef CONFIG_GRKERNSEC_IO
71042 + {
71043 + .procname = "disable_priv_io",
71044 + .data = &grsec_disable_privio,
71045 + .maxlen = sizeof(int),
71046 + .mode = 0600,
71047 + .proc_handler = &proc_dointvec,
71048 + },
71049 +#endif
71050 +#endif
71051 +#ifdef CONFIG_GRKERNSEC_LINK
71052 + {
71053 + .procname = "linking_restrictions",
71054 + .data = &grsec_enable_link,
71055 + .maxlen = sizeof(int),
71056 + .mode = 0600,
71057 + .proc_handler = &proc_dointvec,
71058 + },
71059 +#endif
71060 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71061 + {
71062 + .procname = "enforce_symlinksifowner",
71063 + .data = &grsec_enable_symlinkown,
71064 + .maxlen = sizeof(int),
71065 + .mode = 0600,
71066 + .proc_handler = &proc_dointvec,
71067 + },
71068 + {
71069 + .procname = "symlinkown_gid",
71070 + .data = &grsec_symlinkown_gid,
71071 + .maxlen = sizeof(int),
71072 + .mode = 0600,
71073 + .proc_handler = &proc_dointvec,
71074 + },
71075 +#endif
71076 +#ifdef CONFIG_GRKERNSEC_BRUTE
71077 + {
71078 + .procname = "deter_bruteforce",
71079 + .data = &grsec_enable_brute,
71080 + .maxlen = sizeof(int),
71081 + .mode = 0600,
71082 + .proc_handler = &proc_dointvec,
71083 + },
71084 +#endif
71085 +#ifdef CONFIG_GRKERNSEC_FIFO
71086 + {
71087 + .procname = "fifo_restrictions",
71088 + .data = &grsec_enable_fifo,
71089 + .maxlen = sizeof(int),
71090 + .mode = 0600,
71091 + .proc_handler = &proc_dointvec,
71092 + },
71093 +#endif
71094 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71095 + {
71096 + .procname = "ptrace_readexec",
71097 + .data = &grsec_enable_ptrace_readexec,
71098 + .maxlen = sizeof(int),
71099 + .mode = 0600,
71100 + .proc_handler = &proc_dointvec,
71101 + },
71102 +#endif
71103 +#ifdef CONFIG_GRKERNSEC_SETXID
71104 + {
71105 + .procname = "consistent_setxid",
71106 + .data = &grsec_enable_setxid,
71107 + .maxlen = sizeof(int),
71108 + .mode = 0600,
71109 + .proc_handler = &proc_dointvec,
71110 + },
71111 +#endif
71112 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71113 + {
71114 + .procname = "ip_blackhole",
71115 + .data = &grsec_enable_blackhole,
71116 + .maxlen = sizeof(int),
71117 + .mode = 0600,
71118 + .proc_handler = &proc_dointvec,
71119 + },
71120 + {
71121 + .procname = "lastack_retries",
71122 + .data = &grsec_lastack_retries,
71123 + .maxlen = sizeof(int),
71124 + .mode = 0600,
71125 + .proc_handler = &proc_dointvec,
71126 + },
71127 +#endif
71128 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71129 + {
71130 + .procname = "exec_logging",
71131 + .data = &grsec_enable_execlog,
71132 + .maxlen = sizeof(int),
71133 + .mode = 0600,
71134 + .proc_handler = &proc_dointvec,
71135 + },
71136 +#endif
71137 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71138 + {
71139 + .procname = "rwxmap_logging",
71140 + .data = &grsec_enable_log_rwxmaps,
71141 + .maxlen = sizeof(int),
71142 + .mode = 0600,
71143 + .proc_handler = &proc_dointvec,
71144 + },
71145 +#endif
71146 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71147 + {
71148 + .procname = "signal_logging",
71149 + .data = &grsec_enable_signal,
71150 + .maxlen = sizeof(int),
71151 + .mode = 0600,
71152 + .proc_handler = &proc_dointvec,
71153 + },
71154 +#endif
71155 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71156 + {
71157 + .procname = "forkfail_logging",
71158 + .data = &grsec_enable_forkfail,
71159 + .maxlen = sizeof(int),
71160 + .mode = 0600,
71161 + .proc_handler = &proc_dointvec,
71162 + },
71163 +#endif
71164 +#ifdef CONFIG_GRKERNSEC_TIME
71165 + {
71166 + .procname = "timechange_logging",
71167 + .data = &grsec_enable_time,
71168 + .maxlen = sizeof(int),
71169 + .mode = 0600,
71170 + .proc_handler = &proc_dointvec,
71171 + },
71172 +#endif
71173 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71174 + {
71175 + .procname = "chroot_deny_shmat",
71176 + .data = &grsec_enable_chroot_shmat,
71177 + .maxlen = sizeof(int),
71178 + .mode = 0600,
71179 + .proc_handler = &proc_dointvec,
71180 + },
71181 +#endif
71182 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71183 + {
71184 + .procname = "chroot_deny_unix",
71185 + .data = &grsec_enable_chroot_unix,
71186 + .maxlen = sizeof(int),
71187 + .mode = 0600,
71188 + .proc_handler = &proc_dointvec,
71189 + },
71190 +#endif
71191 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71192 + {
71193 + .procname = "chroot_deny_mount",
71194 + .data = &grsec_enable_chroot_mount,
71195 + .maxlen = sizeof(int),
71196 + .mode = 0600,
71197 + .proc_handler = &proc_dointvec,
71198 + },
71199 +#endif
71200 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71201 + {
71202 + .procname = "chroot_deny_fchdir",
71203 + .data = &grsec_enable_chroot_fchdir,
71204 + .maxlen = sizeof(int),
71205 + .mode = 0600,
71206 + .proc_handler = &proc_dointvec,
71207 + },
71208 +#endif
71209 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71210 + {
71211 + .procname = "chroot_deny_chroot",
71212 + .data = &grsec_enable_chroot_double,
71213 + .maxlen = sizeof(int),
71214 + .mode = 0600,
71215 + .proc_handler = &proc_dointvec,
71216 + },
71217 +#endif
71218 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71219 + {
71220 + .procname = "chroot_deny_pivot",
71221 + .data = &grsec_enable_chroot_pivot,
71222 + .maxlen = sizeof(int),
71223 + .mode = 0600,
71224 + .proc_handler = &proc_dointvec,
71225 + },
71226 +#endif
71227 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71228 + {
71229 + .procname = "chroot_enforce_chdir",
71230 + .data = &grsec_enable_chroot_chdir,
71231 + .maxlen = sizeof(int),
71232 + .mode = 0600,
71233 + .proc_handler = &proc_dointvec,
71234 + },
71235 +#endif
71236 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71237 + {
71238 + .procname = "chroot_deny_chmod",
71239 + .data = &grsec_enable_chroot_chmod,
71240 + .maxlen = sizeof(int),
71241 + .mode = 0600,
71242 + .proc_handler = &proc_dointvec,
71243 + },
71244 +#endif
71245 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71246 + {
71247 + .procname = "chroot_deny_mknod",
71248 + .data = &grsec_enable_chroot_mknod,
71249 + .maxlen = sizeof(int),
71250 + .mode = 0600,
71251 + .proc_handler = &proc_dointvec,
71252 + },
71253 +#endif
71254 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71255 + {
71256 + .procname = "chroot_restrict_nice",
71257 + .data = &grsec_enable_chroot_nice,
71258 + .maxlen = sizeof(int),
71259 + .mode = 0600,
71260 + .proc_handler = &proc_dointvec,
71261 + },
71262 +#endif
71263 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71264 + {
71265 + .procname = "chroot_execlog",
71266 + .data = &grsec_enable_chroot_execlog,
71267 + .maxlen = sizeof(int),
71268 + .mode = 0600,
71269 + .proc_handler = &proc_dointvec,
71270 + },
71271 +#endif
71272 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71273 + {
71274 + .procname = "chroot_caps",
71275 + .data = &grsec_enable_chroot_caps,
71276 + .maxlen = sizeof(int),
71277 + .mode = 0600,
71278 + .proc_handler = &proc_dointvec,
71279 + },
71280 +#endif
71281 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71282 + {
71283 + .procname = "chroot_deny_sysctl",
71284 + .data = &grsec_enable_chroot_sysctl,
71285 + .maxlen = sizeof(int),
71286 + .mode = 0600,
71287 + .proc_handler = &proc_dointvec,
71288 + },
71289 +#endif
71290 +#ifdef CONFIG_GRKERNSEC_TPE
71291 + {
71292 + .procname = "tpe",
71293 + .data = &grsec_enable_tpe,
71294 + .maxlen = sizeof(int),
71295 + .mode = 0600,
71296 + .proc_handler = &proc_dointvec,
71297 + },
71298 + {
71299 + .procname = "tpe_gid",
71300 + .data = &grsec_tpe_gid,
71301 + .maxlen = sizeof(int),
71302 + .mode = 0600,
71303 + .proc_handler = &proc_dointvec,
71304 + },
71305 +#endif
71306 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71307 + {
71308 + .procname = "tpe_invert",
71309 + .data = &grsec_enable_tpe_invert,
71310 + .maxlen = sizeof(int),
71311 + .mode = 0600,
71312 + .proc_handler = &proc_dointvec,
71313 + },
71314 +#endif
71315 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71316 + {
71317 + .procname = "tpe_restrict_all",
71318 + .data = &grsec_enable_tpe_all,
71319 + .maxlen = sizeof(int),
71320 + .mode = 0600,
71321 + .proc_handler = &proc_dointvec,
71322 + },
71323 +#endif
71324 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71325 + {
71326 + .procname = "socket_all",
71327 + .data = &grsec_enable_socket_all,
71328 + .maxlen = sizeof(int),
71329 + .mode = 0600,
71330 + .proc_handler = &proc_dointvec,
71331 + },
71332 + {
71333 + .procname = "socket_all_gid",
71334 + .data = &grsec_socket_all_gid,
71335 + .maxlen = sizeof(int),
71336 + .mode = 0600,
71337 + .proc_handler = &proc_dointvec,
71338 + },
71339 +#endif
71340 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71341 + {
71342 + .procname = "socket_client",
71343 + .data = &grsec_enable_socket_client,
71344 + .maxlen = sizeof(int),
71345 + .mode = 0600,
71346 + .proc_handler = &proc_dointvec,
71347 + },
71348 + {
71349 + .procname = "socket_client_gid",
71350 + .data = &grsec_socket_client_gid,
71351 + .maxlen = sizeof(int),
71352 + .mode = 0600,
71353 + .proc_handler = &proc_dointvec,
71354 + },
71355 +#endif
71356 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71357 + {
71358 + .procname = "socket_server",
71359 + .data = &grsec_enable_socket_server,
71360 + .maxlen = sizeof(int),
71361 + .mode = 0600,
71362 + .proc_handler = &proc_dointvec,
71363 + },
71364 + {
71365 + .procname = "socket_server_gid",
71366 + .data = &grsec_socket_server_gid,
71367 + .maxlen = sizeof(int),
71368 + .mode = 0600,
71369 + .proc_handler = &proc_dointvec,
71370 + },
71371 +#endif
71372 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71373 + {
71374 + .procname = "audit_group",
71375 + .data = &grsec_enable_group,
71376 + .maxlen = sizeof(int),
71377 + .mode = 0600,
71378 + .proc_handler = &proc_dointvec,
71379 + },
71380 + {
71381 + .procname = "audit_gid",
71382 + .data = &grsec_audit_gid,
71383 + .maxlen = sizeof(int),
71384 + .mode = 0600,
71385 + .proc_handler = &proc_dointvec,
71386 + },
71387 +#endif
71388 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71389 + {
71390 + .procname = "audit_chdir",
71391 + .data = &grsec_enable_chdir,
71392 + .maxlen = sizeof(int),
71393 + .mode = 0600,
71394 + .proc_handler = &proc_dointvec,
71395 + },
71396 +#endif
71397 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71398 + {
71399 + .procname = "audit_mount",
71400 + .data = &grsec_enable_mount,
71401 + .maxlen = sizeof(int),
71402 + .mode = 0600,
71403 + .proc_handler = &proc_dointvec,
71404 + },
71405 +#endif
71406 +#ifdef CONFIG_GRKERNSEC_DMESG
71407 + {
71408 + .procname = "dmesg",
71409 + .data = &grsec_enable_dmesg,
71410 + .maxlen = sizeof(int),
71411 + .mode = 0600,
71412 + .proc_handler = &proc_dointvec,
71413 + },
71414 +#endif
71415 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71416 + {
71417 + .procname = "chroot_findtask",
71418 + .data = &grsec_enable_chroot_findtask,
71419 + .maxlen = sizeof(int),
71420 + .mode = 0600,
71421 + .proc_handler = &proc_dointvec,
71422 + },
71423 +#endif
71424 +#ifdef CONFIG_GRKERNSEC_RESLOG
71425 + {
71426 + .procname = "resource_logging",
71427 + .data = &grsec_resource_logging,
71428 + .maxlen = sizeof(int),
71429 + .mode = 0600,
71430 + .proc_handler = &proc_dointvec,
71431 + },
71432 +#endif
71433 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71434 + {
71435 + .procname = "audit_ptrace",
71436 + .data = &grsec_enable_audit_ptrace,
71437 + .maxlen = sizeof(int),
71438 + .mode = 0600,
71439 + .proc_handler = &proc_dointvec,
71440 + },
71441 +#endif
71442 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71443 + {
71444 + .procname = "harden_ptrace",
71445 + .data = &grsec_enable_harden_ptrace,
71446 + .maxlen = sizeof(int),
71447 + .mode = 0600,
71448 + .proc_handler = &proc_dointvec,
71449 + },
71450 +#endif
71451 + {
71452 + .procname = "grsec_lock",
71453 + .data = &grsec_lock,
71454 + .maxlen = sizeof(int),
71455 + .mode = 0600,
71456 + .proc_handler = &proc_dointvec,
71457 + },
71458 +#endif
71459 +#ifdef CONFIG_GRKERNSEC_ROFS
71460 + {
71461 + .procname = "romount_protect",
71462 + .data = &grsec_enable_rofs,
71463 + .maxlen = sizeof(int),
71464 + .mode = 0600,
71465 + .proc_handler = &proc_dointvec_minmax,
71466 + .extra1 = &one,
71467 + .extra2 = &one,
71468 + },
71469 +#endif
71470 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
71471 + {
71472 + .procname = "deny_new_usb",
71473 + .data = &grsec_deny_new_usb,
71474 + .maxlen = sizeof(int),
71475 + .mode = 0600,
71476 + .proc_handler = &proc_dointvec,
71477 + },
71478 +#endif
71479 + { }
71480 +};
71481 +#endif
71482 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
71483 new file mode 100644
71484 index 0000000..0dc13c3
71485 --- /dev/null
71486 +++ b/grsecurity/grsec_time.c
71487 @@ -0,0 +1,16 @@
71488 +#include <linux/kernel.h>
71489 +#include <linux/sched.h>
71490 +#include <linux/grinternal.h>
71491 +#include <linux/module.h>
71492 +
71493 +void
71494 +gr_log_timechange(void)
71495 +{
71496 +#ifdef CONFIG_GRKERNSEC_TIME
71497 + if (grsec_enable_time)
71498 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
71499 +#endif
71500 + return;
71501 +}
71502 +
71503 +EXPORT_SYMBOL(gr_log_timechange);
71504 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
71505 new file mode 100644
71506 index 0000000..ee57dcf
71507 --- /dev/null
71508 +++ b/grsecurity/grsec_tpe.c
71509 @@ -0,0 +1,73 @@
71510 +#include <linux/kernel.h>
71511 +#include <linux/sched.h>
71512 +#include <linux/file.h>
71513 +#include <linux/fs.h>
71514 +#include <linux/grinternal.h>
71515 +
71516 +extern int gr_acl_tpe_check(void);
71517 +
71518 +int
71519 +gr_tpe_allow(const struct file *file)
71520 +{
71521 +#ifdef CONFIG_GRKERNSEC
71522 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
71523 + const struct cred *cred = current_cred();
71524 + char *msg = NULL;
71525 + char *msg2 = NULL;
71526 +
71527 + // never restrict root
71528 + if (gr_is_global_root(cred->uid))
71529 + return 1;
71530 +
71531 + if (grsec_enable_tpe) {
71532 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71533 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
71534 + msg = "not being in trusted group";
71535 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
71536 + msg = "being in untrusted group";
71537 +#else
71538 + if (in_group_p(grsec_tpe_gid))
71539 + msg = "being in untrusted group";
71540 +#endif
71541 + }
71542 + if (!msg && gr_acl_tpe_check())
71543 + msg = "being in untrusted role";
71544 +
71545 + // not in any affected group/role
71546 + if (!msg)
71547 + goto next_check;
71548 +
71549 + if (gr_is_global_nonroot(inode->i_uid))
71550 + msg2 = "file in non-root-owned directory";
71551 + else if (inode->i_mode & S_IWOTH)
71552 + msg2 = "file in world-writable directory";
71553 + else if (inode->i_mode & S_IWGRP)
71554 + msg2 = "file in group-writable directory";
71555 +
71556 + if (msg && msg2) {
71557 + char fullmsg[70] = {0};
71558 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
71559 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
71560 + return 0;
71561 + }
71562 + msg = NULL;
71563 +next_check:
71564 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71565 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
71566 + return 1;
71567 +
71568 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
71569 + msg = "directory not owned by user";
71570 + else if (inode->i_mode & S_IWOTH)
71571 + msg = "file in world-writable directory";
71572 + else if (inode->i_mode & S_IWGRP)
71573 + msg = "file in group-writable directory";
71574 +
71575 + if (msg) {
71576 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
71577 + return 0;
71578 + }
71579 +#endif
71580 +#endif
71581 + return 1;
71582 +}
71583 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
71584 new file mode 100644
71585 index 0000000..ae02d8e
71586 --- /dev/null
71587 +++ b/grsecurity/grsec_usb.c
71588 @@ -0,0 +1,15 @@
71589 +#include <linux/kernel.h>
71590 +#include <linux/grinternal.h>
71591 +#include <linux/module.h>
71592 +
71593 +int gr_handle_new_usb(void)
71594 +{
71595 +#ifdef CONFIG_GRKERNSEC_DENYUSB
71596 + if (grsec_deny_new_usb) {
71597 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
71598 + return 1;
71599 + }
71600 +#endif
71601 + return 0;
71602 +}
71603 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
71604 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
71605 new file mode 100644
71606 index 0000000..9f7b1ac
71607 --- /dev/null
71608 +++ b/grsecurity/grsum.c
71609 @@ -0,0 +1,61 @@
71610 +#include <linux/err.h>
71611 +#include <linux/kernel.h>
71612 +#include <linux/sched.h>
71613 +#include <linux/mm.h>
71614 +#include <linux/scatterlist.h>
71615 +#include <linux/crypto.h>
71616 +#include <linux/gracl.h>
71617 +
71618 +
71619 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
71620 +#error "crypto and sha256 must be built into the kernel"
71621 +#endif
71622 +
71623 +int
71624 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
71625 +{
71626 + char *p;
71627 + struct crypto_hash *tfm;
71628 + struct hash_desc desc;
71629 + struct scatterlist sg;
71630 + unsigned char temp_sum[GR_SHA_LEN];
71631 + volatile int retval = 0;
71632 + volatile int dummy = 0;
71633 + unsigned int i;
71634 +
71635 + sg_init_table(&sg, 1);
71636 +
71637 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
71638 + if (IS_ERR(tfm)) {
71639 + /* should never happen, since sha256 should be built in */
71640 + return 1;
71641 + }
71642 +
71643 + desc.tfm = tfm;
71644 + desc.flags = 0;
71645 +
71646 + crypto_hash_init(&desc);
71647 +
71648 + p = salt;
71649 + sg_set_buf(&sg, p, GR_SALT_LEN);
71650 + crypto_hash_update(&desc, &sg, sg.length);
71651 +
71652 + p = entry->pw;
71653 + sg_set_buf(&sg, p, strlen(p));
71654 +
71655 + crypto_hash_update(&desc, &sg, sg.length);
71656 +
71657 + crypto_hash_final(&desc, temp_sum);
71658 +
71659 + memset(entry->pw, 0, GR_PW_LEN);
71660 +
71661 + for (i = 0; i < GR_SHA_LEN; i++)
71662 + if (sum[i] != temp_sum[i])
71663 + retval = 1;
71664 + else
71665 + dummy = 1; // waste a cycle
71666 +
71667 + crypto_free_hash(tfm);
71668 +
71669 + return retval;
71670 +}
71671 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
71672 index 77ff547..181834f 100644
71673 --- a/include/asm-generic/4level-fixup.h
71674 +++ b/include/asm-generic/4level-fixup.h
71675 @@ -13,8 +13,10 @@
71676 #define pmd_alloc(mm, pud, address) \
71677 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
71678 NULL: pmd_offset(pud, address))
71679 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
71680
71681 #define pud_alloc(mm, pgd, address) (pgd)
71682 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
71683 #define pud_offset(pgd, start) (pgd)
71684 #define pud_none(pud) 0
71685 #define pud_bad(pud) 0
71686 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
71687 index b7babf0..04ad282 100644
71688 --- a/include/asm-generic/atomic-long.h
71689 +++ b/include/asm-generic/atomic-long.h
71690 @@ -22,6 +22,12 @@
71691
71692 typedef atomic64_t atomic_long_t;
71693
71694 +#ifdef CONFIG_PAX_REFCOUNT
71695 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
71696 +#else
71697 +typedef atomic64_t atomic_long_unchecked_t;
71698 +#endif
71699 +
71700 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
71701
71702 static inline long atomic_long_read(atomic_long_t *l)
71703 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71704 return (long)atomic64_read(v);
71705 }
71706
71707 +#ifdef CONFIG_PAX_REFCOUNT
71708 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71709 +{
71710 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71711 +
71712 + return (long)atomic64_read_unchecked(v);
71713 +}
71714 +#endif
71715 +
71716 static inline void atomic_long_set(atomic_long_t *l, long i)
71717 {
71718 atomic64_t *v = (atomic64_t *)l;
71719 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71720 atomic64_set(v, i);
71721 }
71722
71723 +#ifdef CONFIG_PAX_REFCOUNT
71724 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71725 +{
71726 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71727 +
71728 + atomic64_set_unchecked(v, i);
71729 +}
71730 +#endif
71731 +
71732 static inline void atomic_long_inc(atomic_long_t *l)
71733 {
71734 atomic64_t *v = (atomic64_t *)l;
71735 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71736 atomic64_inc(v);
71737 }
71738
71739 +#ifdef CONFIG_PAX_REFCOUNT
71740 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71741 +{
71742 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71743 +
71744 + atomic64_inc_unchecked(v);
71745 +}
71746 +#endif
71747 +
71748 static inline void atomic_long_dec(atomic_long_t *l)
71749 {
71750 atomic64_t *v = (atomic64_t *)l;
71751 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71752 atomic64_dec(v);
71753 }
71754
71755 +#ifdef CONFIG_PAX_REFCOUNT
71756 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71757 +{
71758 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71759 +
71760 + atomic64_dec_unchecked(v);
71761 +}
71762 +#endif
71763 +
71764 static inline void atomic_long_add(long i, atomic_long_t *l)
71765 {
71766 atomic64_t *v = (atomic64_t *)l;
71767 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71768 atomic64_add(i, v);
71769 }
71770
71771 +#ifdef CONFIG_PAX_REFCOUNT
71772 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71773 +{
71774 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71775 +
71776 + atomic64_add_unchecked(i, v);
71777 +}
71778 +#endif
71779 +
71780 static inline void atomic_long_sub(long i, atomic_long_t *l)
71781 {
71782 atomic64_t *v = (atomic64_t *)l;
71783 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71784 atomic64_sub(i, v);
71785 }
71786
71787 +#ifdef CONFIG_PAX_REFCOUNT
71788 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71789 +{
71790 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71791 +
71792 + atomic64_sub_unchecked(i, v);
71793 +}
71794 +#endif
71795 +
71796 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71797 {
71798 atomic64_t *v = (atomic64_t *)l;
71799 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71800 return (long)atomic64_add_return(i, v);
71801 }
71802
71803 +#ifdef CONFIG_PAX_REFCOUNT
71804 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71805 +{
71806 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71807 +
71808 + return (long)atomic64_add_return_unchecked(i, v);
71809 +}
71810 +#endif
71811 +
71812 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71813 {
71814 atomic64_t *v = (atomic64_t *)l;
71815 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71816 return (long)atomic64_inc_return(v);
71817 }
71818
71819 +#ifdef CONFIG_PAX_REFCOUNT
71820 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71821 +{
71822 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
71823 +
71824 + return (long)atomic64_inc_return_unchecked(v);
71825 +}
71826 +#endif
71827 +
71828 static inline long atomic_long_dec_return(atomic_long_t *l)
71829 {
71830 atomic64_t *v = (atomic64_t *)l;
71831 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71832
71833 typedef atomic_t atomic_long_t;
71834
71835 +#ifdef CONFIG_PAX_REFCOUNT
71836 +typedef atomic_unchecked_t atomic_long_unchecked_t;
71837 +#else
71838 +typedef atomic_t atomic_long_unchecked_t;
71839 +#endif
71840 +
71841 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
71842 static inline long atomic_long_read(atomic_long_t *l)
71843 {
71844 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
71845 return (long)atomic_read(v);
71846 }
71847
71848 +#ifdef CONFIG_PAX_REFCOUNT
71849 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
71850 +{
71851 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71852 +
71853 + return (long)atomic_read_unchecked(v);
71854 +}
71855 +#endif
71856 +
71857 static inline void atomic_long_set(atomic_long_t *l, long i)
71858 {
71859 atomic_t *v = (atomic_t *)l;
71860 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
71861 atomic_set(v, i);
71862 }
71863
71864 +#ifdef CONFIG_PAX_REFCOUNT
71865 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
71866 +{
71867 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71868 +
71869 + atomic_set_unchecked(v, i);
71870 +}
71871 +#endif
71872 +
71873 static inline void atomic_long_inc(atomic_long_t *l)
71874 {
71875 atomic_t *v = (atomic_t *)l;
71876 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
71877 atomic_inc(v);
71878 }
71879
71880 +#ifdef CONFIG_PAX_REFCOUNT
71881 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
71882 +{
71883 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71884 +
71885 + atomic_inc_unchecked(v);
71886 +}
71887 +#endif
71888 +
71889 static inline void atomic_long_dec(atomic_long_t *l)
71890 {
71891 atomic_t *v = (atomic_t *)l;
71892 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
71893 atomic_dec(v);
71894 }
71895
71896 +#ifdef CONFIG_PAX_REFCOUNT
71897 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
71898 +{
71899 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71900 +
71901 + atomic_dec_unchecked(v);
71902 +}
71903 +#endif
71904 +
71905 static inline void atomic_long_add(long i, atomic_long_t *l)
71906 {
71907 atomic_t *v = (atomic_t *)l;
71908 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
71909 atomic_add(i, v);
71910 }
71911
71912 +#ifdef CONFIG_PAX_REFCOUNT
71913 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
71914 +{
71915 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71916 +
71917 + atomic_add_unchecked(i, v);
71918 +}
71919 +#endif
71920 +
71921 static inline void atomic_long_sub(long i, atomic_long_t *l)
71922 {
71923 atomic_t *v = (atomic_t *)l;
71924 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
71925 atomic_sub(i, v);
71926 }
71927
71928 +#ifdef CONFIG_PAX_REFCOUNT
71929 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
71930 +{
71931 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71932 +
71933 + atomic_sub_unchecked(i, v);
71934 +}
71935 +#endif
71936 +
71937 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
71938 {
71939 atomic_t *v = (atomic_t *)l;
71940 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
71941 return (long)atomic_add_return(i, v);
71942 }
71943
71944 +#ifdef CONFIG_PAX_REFCOUNT
71945 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
71946 +{
71947 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71948 +
71949 + return (long)atomic_add_return_unchecked(i, v);
71950 +}
71951 +
71952 +#endif
71953 +
71954 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
71955 {
71956 atomic_t *v = (atomic_t *)l;
71957 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
71958 return (long)atomic_inc_return(v);
71959 }
71960
71961 +#ifdef CONFIG_PAX_REFCOUNT
71962 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
71963 +{
71964 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
71965 +
71966 + return (long)atomic_inc_return_unchecked(v);
71967 +}
71968 +#endif
71969 +
71970 static inline long atomic_long_dec_return(atomic_long_t *l)
71971 {
71972 atomic_t *v = (atomic_t *)l;
71973 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
71974
71975 #endif /* BITS_PER_LONG == 64 */
71976
71977 +#ifdef CONFIG_PAX_REFCOUNT
71978 +static inline void pax_refcount_needs_these_functions(void)
71979 +{
71980 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
71981 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
71982 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
71983 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
71984 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
71985 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
71986 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
71987 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
71988 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
71989 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
71990 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
71991 +#ifdef CONFIG_X86
71992 + atomic_clear_mask_unchecked(0, NULL);
71993 + atomic_set_mask_unchecked(0, NULL);
71994 +#endif
71995 +
71996 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
71997 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
71998 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
71999 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
72000 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
72001 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
72002 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
72003 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
72004 +}
72005 +#else
72006 +#define atomic_read_unchecked(v) atomic_read(v)
72007 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
72008 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
72009 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
72010 +#define atomic_inc_unchecked(v) atomic_inc(v)
72011 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
72012 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
72013 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
72014 +#define atomic_dec_unchecked(v) atomic_dec(v)
72015 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
72016 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
72017 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
72018 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
72019 +
72020 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
72021 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
72022 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
72023 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
72024 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
72025 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
72026 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
72027 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
72028 +#endif
72029 +
72030 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
72031 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
72032 index 33bd2de..f31bff97 100644
72033 --- a/include/asm-generic/atomic.h
72034 +++ b/include/asm-generic/atomic.h
72035 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
72036 * Atomically clears the bits set in @mask from @v
72037 */
72038 #ifndef atomic_clear_mask
72039 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
72040 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
72041 {
72042 unsigned long flags;
72043
72044 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
72045 index b18ce4f..2ee2843 100644
72046 --- a/include/asm-generic/atomic64.h
72047 +++ b/include/asm-generic/atomic64.h
72048 @@ -16,6 +16,8 @@ typedef struct {
72049 long long counter;
72050 } atomic64_t;
72051
72052 +typedef atomic64_t atomic64_unchecked_t;
72053 +
72054 #define ATOMIC64_INIT(i) { (i) }
72055
72056 extern long long atomic64_read(const atomic64_t *v);
72057 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
72058 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
72059 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
72060
72061 +#define atomic64_read_unchecked(v) atomic64_read(v)
72062 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
72063 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
72064 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
72065 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
72066 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
72067 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
72068 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
72069 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
72070 +
72071 #endif /* _ASM_GENERIC_ATOMIC64_H */
72072 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
72073 index 1bfcfe5..e04c5c9 100644
72074 --- a/include/asm-generic/cache.h
72075 +++ b/include/asm-generic/cache.h
72076 @@ -6,7 +6,7 @@
72077 * cache lines need to provide their own cache.h.
72078 */
72079
72080 -#define L1_CACHE_SHIFT 5
72081 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
72082 +#define L1_CACHE_SHIFT 5UL
72083 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
72084
72085 #endif /* __ASM_GENERIC_CACHE_H */
72086 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
72087 index 0d68a1e..b74a761 100644
72088 --- a/include/asm-generic/emergency-restart.h
72089 +++ b/include/asm-generic/emergency-restart.h
72090 @@ -1,7 +1,7 @@
72091 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
72092 #define _ASM_GENERIC_EMERGENCY_RESTART_H
72093
72094 -static inline void machine_emergency_restart(void)
72095 +static inline __noreturn void machine_emergency_restart(void)
72096 {
72097 machine_restart(NULL);
72098 }
72099 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
72100 index 90f99c7..00ce236 100644
72101 --- a/include/asm-generic/kmap_types.h
72102 +++ b/include/asm-generic/kmap_types.h
72103 @@ -2,9 +2,9 @@
72104 #define _ASM_GENERIC_KMAP_TYPES_H
72105
72106 #ifdef __WITH_KM_FENCE
72107 -# define KM_TYPE_NR 41
72108 +# define KM_TYPE_NR 42
72109 #else
72110 -# define KM_TYPE_NR 20
72111 +# define KM_TYPE_NR 21
72112 #endif
72113
72114 #endif
72115 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
72116 index 9ceb03b..62b0b8f 100644
72117 --- a/include/asm-generic/local.h
72118 +++ b/include/asm-generic/local.h
72119 @@ -23,24 +23,37 @@ typedef struct
72120 atomic_long_t a;
72121 } local_t;
72122
72123 +typedef struct {
72124 + atomic_long_unchecked_t a;
72125 +} local_unchecked_t;
72126 +
72127 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
72128
72129 #define local_read(l) atomic_long_read(&(l)->a)
72130 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
72131 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
72132 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
72133 #define local_inc(l) atomic_long_inc(&(l)->a)
72134 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
72135 #define local_dec(l) atomic_long_dec(&(l)->a)
72136 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
72137 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
72138 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
72139 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
72140 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
72141
72142 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
72143 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
72144 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
72145 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
72146 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
72147 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
72148 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
72149 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
72150 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
72151
72152 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72153 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
72154 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
72155 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
72156 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
72157 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
72158 index 725612b..9cc513a 100644
72159 --- a/include/asm-generic/pgtable-nopmd.h
72160 +++ b/include/asm-generic/pgtable-nopmd.h
72161 @@ -1,14 +1,19 @@
72162 #ifndef _PGTABLE_NOPMD_H
72163 #define _PGTABLE_NOPMD_H
72164
72165 -#ifndef __ASSEMBLY__
72166 -
72167 #include <asm-generic/pgtable-nopud.h>
72168
72169 -struct mm_struct;
72170 -
72171 #define __PAGETABLE_PMD_FOLDED
72172
72173 +#define PMD_SHIFT PUD_SHIFT
72174 +#define PTRS_PER_PMD 1
72175 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
72176 +#define PMD_MASK (~(PMD_SIZE-1))
72177 +
72178 +#ifndef __ASSEMBLY__
72179 +
72180 +struct mm_struct;
72181 +
72182 /*
72183 * Having the pmd type consist of a pud gets the size right, and allows
72184 * us to conceptually access the pud entry that this pmd is folded into
72185 @@ -16,11 +21,6 @@ struct mm_struct;
72186 */
72187 typedef struct { pud_t pud; } pmd_t;
72188
72189 -#define PMD_SHIFT PUD_SHIFT
72190 -#define PTRS_PER_PMD 1
72191 -#define PMD_SIZE (1UL << PMD_SHIFT)
72192 -#define PMD_MASK (~(PMD_SIZE-1))
72193 -
72194 /*
72195 * The "pud_xxx()" functions here are trivial for a folded two-level
72196 * setup: the pmd is never bad, and a pmd always exists (as it's folded
72197 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
72198 index 810431d..0ec4804f 100644
72199 --- a/include/asm-generic/pgtable-nopud.h
72200 +++ b/include/asm-generic/pgtable-nopud.h
72201 @@ -1,10 +1,15 @@
72202 #ifndef _PGTABLE_NOPUD_H
72203 #define _PGTABLE_NOPUD_H
72204
72205 -#ifndef __ASSEMBLY__
72206 -
72207 #define __PAGETABLE_PUD_FOLDED
72208
72209 +#define PUD_SHIFT PGDIR_SHIFT
72210 +#define PTRS_PER_PUD 1
72211 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
72212 +#define PUD_MASK (~(PUD_SIZE-1))
72213 +
72214 +#ifndef __ASSEMBLY__
72215 +
72216 /*
72217 * Having the pud type consist of a pgd gets the size right, and allows
72218 * us to conceptually access the pgd entry that this pud is folded into
72219 @@ -12,11 +17,6 @@
72220 */
72221 typedef struct { pgd_t pgd; } pud_t;
72222
72223 -#define PUD_SHIFT PGDIR_SHIFT
72224 -#define PTRS_PER_PUD 1
72225 -#define PUD_SIZE (1UL << PUD_SHIFT)
72226 -#define PUD_MASK (~(PUD_SIZE-1))
72227 -
72228 /*
72229 * The "pgd_xxx()" functions here are trivial for a folded two-level
72230 * setup: the pud is never bad, and a pud always exists (as it's folded
72231 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
72232 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
72233
72234 #define pgd_populate(mm, pgd, pud) do { } while (0)
72235 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
72236 /*
72237 * (puds are folded into pgds so this doesn't get actually called,
72238 * but the define is needed for a generic inline function.)
72239 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
72240 index 0807ddf..cd67747 100644
72241 --- a/include/asm-generic/pgtable.h
72242 +++ b/include/asm-generic/pgtable.h
72243 @@ -741,6 +741,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
72244 }
72245 #endif /* CONFIG_NUMA_BALANCING */
72246
72247 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
72248 +#ifdef CONFIG_PAX_KERNEXEC
72249 +#error KERNEXEC requires pax_open_kernel
72250 +#else
72251 +static inline unsigned long pax_open_kernel(void) { return 0; }
72252 +#endif
72253 +#endif
72254 +
72255 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
72256 +#ifdef CONFIG_PAX_KERNEXEC
72257 +#error KERNEXEC requires pax_close_kernel
72258 +#else
72259 +static inline unsigned long pax_close_kernel(void) { return 0; }
72260 +#endif
72261 +#endif
72262 +
72263 #endif /* CONFIG_MMU */
72264
72265 #endif /* !__ASSEMBLY__ */
72266 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
72267 index dc1269c..48a4f51 100644
72268 --- a/include/asm-generic/uaccess.h
72269 +++ b/include/asm-generic/uaccess.h
72270 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
72271 return __clear_user(to, n);
72272 }
72273
72274 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
72275 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72276 +#error UDEREF requires pax_open_userland
72277 +#else
72278 +static inline unsigned long pax_open_userland(void) { return 0; }
72279 +#endif
72280 +#endif
72281 +
72282 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
72283 +#ifdef CONFIG_PAX_MEMORY_UDEREF
72284 +#error UDEREF requires pax_close_userland
72285 +#else
72286 +static inline unsigned long pax_close_userland(void) { return 0; }
72287 +#endif
72288 +#endif
72289 +
72290 #endif /* __ASM_GENERIC_UACCESS_H */
72291 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
72292 index 69732d2..cbe16d9 100644
72293 --- a/include/asm-generic/vmlinux.lds.h
72294 +++ b/include/asm-generic/vmlinux.lds.h
72295 @@ -227,6 +227,7 @@
72296 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
72297 VMLINUX_SYMBOL(__start_rodata) = .; \
72298 *(.rodata) *(.rodata.*) \
72299 + *(.data..read_only) \
72300 *(__vermagic) /* Kernel version magic */ \
72301 . = ALIGN(8); \
72302 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
72303 @@ -710,17 +711,18 @@
72304 * section in the linker script will go there too. @phdr should have
72305 * a leading colon.
72306 *
72307 - * Note that this macros defines __per_cpu_load as an absolute symbol.
72308 + * Note that this macros defines per_cpu_load as an absolute symbol.
72309 * If there is no need to put the percpu section at a predetermined
72310 * address, use PERCPU_SECTION.
72311 */
72312 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
72313 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
72314 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
72315 + per_cpu_load = .; \
72316 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
72317 - LOAD_OFFSET) { \
72318 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
72319 PERCPU_INPUT(cacheline) \
72320 } phdr \
72321 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
72322 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
72323
72324 /**
72325 * PERCPU_SECTION - define output section for percpu area, simple version
72326 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
72327 index 418d270..bfd2794 100644
72328 --- a/include/crypto/algapi.h
72329 +++ b/include/crypto/algapi.h
72330 @@ -34,7 +34,7 @@ struct crypto_type {
72331 unsigned int maskclear;
72332 unsigned int maskset;
72333 unsigned int tfmsize;
72334 -};
72335 +} __do_const;
72336
72337 struct crypto_instance {
72338 struct crypto_alg alg;
72339 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
72340 index 12083dc..39740ec 100644
72341 --- a/include/drm/drmP.h
72342 +++ b/include/drm/drmP.h
72343 @@ -69,6 +69,7 @@
72344 #include <linux/workqueue.h>
72345 #include <linux/poll.h>
72346 #include <asm/pgalloc.h>
72347 +#include <asm/local.h>
72348 #include <drm/drm.h>
72349 #include <drm/drm_sarea.h>
72350
72351 @@ -293,10 +294,12 @@ do { \
72352 * \param cmd command.
72353 * \param arg argument.
72354 */
72355 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
72356 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
72357 + struct drm_file *file_priv);
72358 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
72359 struct drm_file *file_priv);
72360
72361 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72362 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
72363 unsigned long arg);
72364
72365 #define DRM_IOCTL_NR(n) _IOC_NR(n)
72366 @@ -311,10 +314,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
72367 struct drm_ioctl_desc {
72368 unsigned int cmd;
72369 int flags;
72370 - drm_ioctl_t *func;
72371 + drm_ioctl_t func;
72372 unsigned int cmd_drv;
72373 const char *name;
72374 -};
72375 +} __do_const;
72376
72377 /**
72378 * Creates a driver or general drm_ioctl_desc array entry for the given
72379 @@ -1015,7 +1018,7 @@ struct drm_info_list {
72380 int (*show)(struct seq_file*, void*); /** show callback */
72381 u32 driver_features; /**< Required driver features for this entry */
72382 void *data;
72383 -};
72384 +} __do_const;
72385
72386 /**
72387 * debugfs node structure. This structure represents a debugfs file.
72388 @@ -1088,7 +1091,7 @@ struct drm_device {
72389
72390 /** \name Usage Counters */
72391 /*@{ */
72392 - int open_count; /**< Outstanding files open */
72393 + local_t open_count; /**< Outstanding files open */
72394 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
72395 atomic_t vma_count; /**< Outstanding vma areas open */
72396 int buf_use; /**< Buffers in use -- cannot alloc */
72397 @@ -1099,7 +1102,7 @@ struct drm_device {
72398 /*@{ */
72399 unsigned long counters;
72400 enum drm_stat_type types[15];
72401 - atomic_t counts[15];
72402 + atomic_unchecked_t counts[15];
72403 /*@} */
72404
72405 struct list_head filelist;
72406 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
72407 index f43d556..94d9343 100644
72408 --- a/include/drm/drm_crtc_helper.h
72409 +++ b/include/drm/drm_crtc_helper.h
72410 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
72411 struct drm_connector *connector);
72412 /* disable encoder when not in use - more explicit than dpms off */
72413 void (*disable)(struct drm_encoder *encoder);
72414 -};
72415 +} __no_const;
72416
72417 /**
72418 * drm_connector_helper_funcs - helper operations for connectors
72419 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
72420 index 72dcbe8..8db58d7 100644
72421 --- a/include/drm/ttm/ttm_memory.h
72422 +++ b/include/drm/ttm/ttm_memory.h
72423 @@ -48,7 +48,7 @@
72424
72425 struct ttm_mem_shrink {
72426 int (*do_shrink) (struct ttm_mem_shrink *);
72427 -};
72428 +} __no_const;
72429
72430 /**
72431 * struct ttm_mem_global - Global memory accounting structure.
72432 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
72433 index 4b840e8..155d235 100644
72434 --- a/include/keys/asymmetric-subtype.h
72435 +++ b/include/keys/asymmetric-subtype.h
72436 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
72437 /* Verify the signature on a key of this subtype (optional) */
72438 int (*verify_signature)(const struct key *key,
72439 const struct public_key_signature *sig);
72440 -};
72441 +} __do_const;
72442
72443 /**
72444 * asymmetric_key_subtype - Get the subtype from an asymmetric key
72445 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
72446 index c1da539..1dcec55 100644
72447 --- a/include/linux/atmdev.h
72448 +++ b/include/linux/atmdev.h
72449 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
72450 #endif
72451
72452 struct k_atm_aal_stats {
72453 -#define __HANDLE_ITEM(i) atomic_t i
72454 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72455 __AAL_STAT_ITEMS
72456 #undef __HANDLE_ITEM
72457 };
72458 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
72459 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
72460 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
72461 struct module *owner;
72462 -};
72463 +} __do_const ;
72464
72465 struct atmphy_ops {
72466 int (*start)(struct atm_dev *dev);
72467 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
72468 index 70cf138..0418ee2 100644
72469 --- a/include/linux/binfmts.h
72470 +++ b/include/linux/binfmts.h
72471 @@ -73,8 +73,10 @@ struct linux_binfmt {
72472 int (*load_binary)(struct linux_binprm *);
72473 int (*load_shlib)(struct file *);
72474 int (*core_dump)(struct coredump_params *cprm);
72475 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
72476 + void (*handle_mmap)(struct file *);
72477 unsigned long min_coredump; /* minimal dump size */
72478 -};
72479 +} __do_const;
72480
72481 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
72482
72483 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
72484 index 2fdb4a4..54aad7e 100644
72485 --- a/include/linux/blkdev.h
72486 +++ b/include/linux/blkdev.h
72487 @@ -1526,7 +1526,7 @@ struct block_device_operations {
72488 /* this callback is with swap_lock and sometimes page table lock held */
72489 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
72490 struct module *owner;
72491 -};
72492 +} __do_const;
72493
72494 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
72495 unsigned long);
72496 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
72497 index 7c2e030..b72475d 100644
72498 --- a/include/linux/blktrace_api.h
72499 +++ b/include/linux/blktrace_api.h
72500 @@ -23,7 +23,7 @@ struct blk_trace {
72501 struct dentry *dir;
72502 struct dentry *dropped_file;
72503 struct dentry *msg_file;
72504 - atomic_t dropped;
72505 + atomic_unchecked_t dropped;
72506 };
72507
72508 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
72509 diff --git a/include/linux/cache.h b/include/linux/cache.h
72510 index 4c57065..40346da 100644
72511 --- a/include/linux/cache.h
72512 +++ b/include/linux/cache.h
72513 @@ -16,6 +16,14 @@
72514 #define __read_mostly
72515 #endif
72516
72517 +#ifndef __read_only
72518 +#ifdef CONFIG_PAX_KERNEXEC
72519 +#error KERNEXEC requires __read_only
72520 +#else
72521 +#define __read_only __read_mostly
72522 +#endif
72523 +#endif
72524 +
72525 #ifndef ____cacheline_aligned
72526 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
72527 #endif
72528 diff --git a/include/linux/capability.h b/include/linux/capability.h
72529 index d9a4f7f4..19f77d6 100644
72530 --- a/include/linux/capability.h
72531 +++ b/include/linux/capability.h
72532 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
72533 extern bool nsown_capable(int cap);
72534 extern bool inode_capable(const struct inode *inode, int cap);
72535 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
72536 +extern bool capable_nolog(int cap);
72537 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
72538 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
72539
72540 /* audit system wants to get cap info from files as well */
72541 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
72542
72543 +extern int is_privileged_binary(const struct dentry *dentry);
72544 +
72545 #endif /* !_LINUX_CAPABILITY_H */
72546 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
72547 index 8609d57..86e4d79 100644
72548 --- a/include/linux/cdrom.h
72549 +++ b/include/linux/cdrom.h
72550 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
72551
72552 /* driver specifications */
72553 const int capability; /* capability flags */
72554 - int n_minors; /* number of active minor devices */
72555 /* handle uniform packets for scsi type devices (scsi,atapi) */
72556 int (*generic_packet) (struct cdrom_device_info *,
72557 struct packet_command *);
72558 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
72559 index 4ce9056..86caac6 100644
72560 --- a/include/linux/cleancache.h
72561 +++ b/include/linux/cleancache.h
72562 @@ -31,7 +31,7 @@ struct cleancache_ops {
72563 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
72564 void (*invalidate_inode)(int, struct cleancache_filekey);
72565 void (*invalidate_fs)(int);
72566 -};
72567 +} __no_const;
72568
72569 extern struct cleancache_ops *
72570 cleancache_register_ops(struct cleancache_ops *ops);
72571 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
72572 index 1ec14a7..d0654a2 100644
72573 --- a/include/linux/clk-provider.h
72574 +++ b/include/linux/clk-provider.h
72575 @@ -132,6 +132,7 @@ struct clk_ops {
72576 unsigned long);
72577 void (*init)(struct clk_hw *hw);
72578 };
72579 +typedef struct clk_ops __no_const clk_ops_no_const;
72580
72581 /**
72582 * struct clk_init_data - holds init data that's common to all clocks and is
72583 diff --git a/include/linux/compat.h b/include/linux/compat.h
72584 index ec1aee4..1077986 100644
72585 --- a/include/linux/compat.h
72586 +++ b/include/linux/compat.h
72587 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
72588 compat_size_t __user *len_ptr);
72589
72590 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
72591 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
72592 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
72593 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
72594 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
72595 compat_ssize_t msgsz, int msgflg);
72596 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
72597 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
72598 compat_ulong_t addr, compat_ulong_t data);
72599 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
72600 - compat_long_t addr, compat_long_t data);
72601 + compat_ulong_t addr, compat_ulong_t data);
72602
72603 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
72604 /*
72605 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
72606 index ded4299..da50e3b 100644
72607 --- a/include/linux/compiler-gcc4.h
72608 +++ b/include/linux/compiler-gcc4.h
72609 @@ -39,9 +39,29 @@
72610 # define __compiletime_warning(message) __attribute__((warning(message)))
72611 # define __compiletime_error(message) __attribute__((error(message)))
72612 #endif /* __CHECKER__ */
72613 +
72614 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
72615 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
72616 +#define __bos0(ptr) __bos((ptr), 0)
72617 +#define __bos1(ptr) __bos((ptr), 1)
72618 #endif /* GCC_VERSION >= 40300 */
72619
72620 #if GCC_VERSION >= 40500
72621 +
72622 +#ifdef CONSTIFY_PLUGIN
72623 +#define __no_const __attribute__((no_const))
72624 +#define __do_const __attribute__((do_const))
72625 +#endif
72626 +
72627 +#ifdef SIZE_OVERFLOW_PLUGIN
72628 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
72629 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
72630 +#endif
72631 +
72632 +#ifdef LATENT_ENTROPY_PLUGIN
72633 +#define __latent_entropy __attribute__((latent_entropy))
72634 +#endif
72635 +
72636 /*
72637 * Mark a position in code as unreachable. This can be used to
72638 * suppress control flow warnings after asm blocks that transfer
72639 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
72640 index 92669cd..1771a15 100644
72641 --- a/include/linux/compiler.h
72642 +++ b/include/linux/compiler.h
72643 @@ -5,11 +5,14 @@
72644
72645 #ifdef __CHECKER__
72646 # define __user __attribute__((noderef, address_space(1)))
72647 +# define __force_user __force __user
72648 # define __kernel __attribute__((address_space(0)))
72649 +# define __force_kernel __force __kernel
72650 # define __safe __attribute__((safe))
72651 # define __force __attribute__((force))
72652 # define __nocast __attribute__((nocast))
72653 # define __iomem __attribute__((noderef, address_space(2)))
72654 +# define __force_iomem __force __iomem
72655 # define __must_hold(x) __attribute__((context(x,1,1)))
72656 # define __acquires(x) __attribute__((context(x,0,1)))
72657 # define __releases(x) __attribute__((context(x,1,0)))
72658 @@ -17,20 +20,37 @@
72659 # define __release(x) __context__(x,-1)
72660 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
72661 # define __percpu __attribute__((noderef, address_space(3)))
72662 +# define __force_percpu __force __percpu
72663 #ifdef CONFIG_SPARSE_RCU_POINTER
72664 # define __rcu __attribute__((noderef, address_space(4)))
72665 +# define __force_rcu __force __rcu
72666 #else
72667 # define __rcu
72668 +# define __force_rcu
72669 #endif
72670 extern void __chk_user_ptr(const volatile void __user *);
72671 extern void __chk_io_ptr(const volatile void __iomem *);
72672 #else
72673 -# define __user
72674 -# define __kernel
72675 +# ifdef CHECKER_PLUGIN
72676 +//# define __user
72677 +//# define __force_user
72678 +//# define __kernel
72679 +//# define __force_kernel
72680 +# else
72681 +# ifdef STRUCTLEAK_PLUGIN
72682 +# define __user __attribute__((user))
72683 +# else
72684 +# define __user
72685 +# endif
72686 +# define __force_user
72687 +# define __kernel
72688 +# define __force_kernel
72689 +# endif
72690 # define __safe
72691 # define __force
72692 # define __nocast
72693 # define __iomem
72694 +# define __force_iomem
72695 # define __chk_user_ptr(x) (void)0
72696 # define __chk_io_ptr(x) (void)0
72697 # define __builtin_warning(x, y...) (1)
72698 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
72699 # define __release(x) (void)0
72700 # define __cond_lock(x,c) (c)
72701 # define __percpu
72702 +# define __force_percpu
72703 # define __rcu
72704 +# define __force_rcu
72705 #endif
72706
72707 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
72708 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72709 # define __attribute_const__ /* unimplemented */
72710 #endif
72711
72712 +#ifndef __no_const
72713 +# define __no_const
72714 +#endif
72715 +
72716 +#ifndef __do_const
72717 +# define __do_const
72718 +#endif
72719 +
72720 +#ifndef __size_overflow
72721 +# define __size_overflow(...)
72722 +#endif
72723 +
72724 +#ifndef __intentional_overflow
72725 +# define __intentional_overflow(...)
72726 +#endif
72727 +
72728 +#ifndef __latent_entropy
72729 +# define __latent_entropy
72730 +#endif
72731 +
72732 /*
72733 * Tell gcc if a function is cold. The compiler will assume any path
72734 * directly leading to the call is unlikely.
72735 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72736 #define __cold
72737 #endif
72738
72739 +#ifndef __alloc_size
72740 +#define __alloc_size(...)
72741 +#endif
72742 +
72743 +#ifndef __bos
72744 +#define __bos(ptr, arg)
72745 +#endif
72746 +
72747 +#ifndef __bos0
72748 +#define __bos0(ptr)
72749 +#endif
72750 +
72751 +#ifndef __bos1
72752 +#define __bos1(ptr)
72753 +#endif
72754 +
72755 /* Simple shorthand for a section definition */
72756 #ifndef __section
72757 # define __section(S) __attribute__ ((__section__(#S)))
72758 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
72759 * use is to mediate communication between process-level code and irq/NMI
72760 * handlers, all running on the same CPU.
72761 */
72762 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
72763 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
72764 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
72765
72766 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
72767 #ifdef CONFIG_KPROBES
72768 diff --git a/include/linux/completion.h b/include/linux/completion.h
72769 index 3cd574d..adce5fa 100644
72770 --- a/include/linux/completion.h
72771 +++ b/include/linux/completion.h
72772 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
72773 extern void wait_for_completion(struct completion *);
72774 extern void wait_for_completion_io(struct completion *);
72775 extern int wait_for_completion_interruptible(struct completion *x);
72776 -extern int wait_for_completion_killable(struct completion *x);
72777 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
72778 extern unsigned long wait_for_completion_timeout(struct completion *x,
72779 unsigned long timeout);
72780 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
72781 unsigned long timeout);
72782 extern long wait_for_completion_interruptible_timeout(
72783 - struct completion *x, unsigned long timeout);
72784 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72785 extern long wait_for_completion_killable_timeout(
72786 - struct completion *x, unsigned long timeout);
72787 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
72788 extern bool try_wait_for_completion(struct completion *x);
72789 extern bool completion_done(struct completion *x);
72790
72791 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
72792 index 34025df..d94bbbc 100644
72793 --- a/include/linux/configfs.h
72794 +++ b/include/linux/configfs.h
72795 @@ -125,7 +125,7 @@ struct configfs_attribute {
72796 const char *ca_name;
72797 struct module *ca_owner;
72798 umode_t ca_mode;
72799 -};
72800 +} __do_const;
72801
72802 /*
72803 * Users often need to create attribute structures for their configurable
72804 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
72805 index 90d5a15..950cb80 100644
72806 --- a/include/linux/cpufreq.h
72807 +++ b/include/linux/cpufreq.h
72808 @@ -266,7 +266,7 @@ struct cpufreq_driver {
72809 int (*suspend) (struct cpufreq_policy *policy);
72810 int (*resume) (struct cpufreq_policy *policy);
72811 struct freq_attr **attr;
72812 -};
72813 +} __do_const;
72814
72815 /* flags */
72816
72817 @@ -325,6 +325,7 @@ struct global_attr {
72818 ssize_t (*store)(struct kobject *a, struct attribute *b,
72819 const char *c, size_t count);
72820 };
72821 +typedef struct global_attr __no_const global_attr_no_const;
72822
72823 #define define_one_global_ro(_name) \
72824 static struct global_attr _name = \
72825 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
72826 index 0bc4b74..973b368 100644
72827 --- a/include/linux/cpuidle.h
72828 +++ b/include/linux/cpuidle.h
72829 @@ -52,7 +52,8 @@ struct cpuidle_state {
72830 int index);
72831
72832 int (*enter_dead) (struct cpuidle_device *dev, int index);
72833 -};
72834 +} __do_const;
72835 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
72836
72837 /* Idle State Flags */
72838 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
72839 @@ -191,7 +192,7 @@ struct cpuidle_governor {
72840 void (*reflect) (struct cpuidle_device *dev, int index);
72841
72842 struct module *owner;
72843 -};
72844 +} __do_const;
72845
72846 #ifdef CONFIG_CPU_IDLE
72847
72848 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
72849 index d08e4d2..95fad61 100644
72850 --- a/include/linux/cpumask.h
72851 +++ b/include/linux/cpumask.h
72852 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72853 }
72854
72855 /* Valid inputs for n are -1 and 0. */
72856 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72857 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72858 {
72859 return n+1;
72860 }
72861
72862 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72863 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72864 {
72865 return n+1;
72866 }
72867
72868 -static inline unsigned int cpumask_next_and(int n,
72869 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
72870 const struct cpumask *srcp,
72871 const struct cpumask *andp)
72872 {
72873 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
72874 *
72875 * Returns >= nr_cpu_ids if no further cpus set.
72876 */
72877 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72878 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
72879 {
72880 /* -1 is a legal arg here. */
72881 if (n != -1)
72882 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
72883 *
72884 * Returns >= nr_cpu_ids if no further cpus unset.
72885 */
72886 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72887 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
72888 {
72889 /* -1 is a legal arg here. */
72890 if (n != -1)
72891 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
72892 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
72893 }
72894
72895 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
72896 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
72897 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
72898
72899 /**
72900 diff --git a/include/linux/cred.h b/include/linux/cred.h
72901 index 04421e8..6bce4ef 100644
72902 --- a/include/linux/cred.h
72903 +++ b/include/linux/cred.h
72904 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
72905 static inline void validate_process_creds(void)
72906 {
72907 }
72908 +static inline void validate_task_creds(struct task_struct *task)
72909 +{
72910 +}
72911 #endif
72912
72913 /**
72914 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
72915 index b92eadf..b4ecdc1 100644
72916 --- a/include/linux/crypto.h
72917 +++ b/include/linux/crypto.h
72918 @@ -373,7 +373,7 @@ struct cipher_tfm {
72919 const u8 *key, unsigned int keylen);
72920 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72921 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
72922 -};
72923 +} __no_const;
72924
72925 struct hash_tfm {
72926 int (*init)(struct hash_desc *desc);
72927 @@ -394,13 +394,13 @@ struct compress_tfm {
72928 int (*cot_decompress)(struct crypto_tfm *tfm,
72929 const u8 *src, unsigned int slen,
72930 u8 *dst, unsigned int *dlen);
72931 -};
72932 +} __no_const;
72933
72934 struct rng_tfm {
72935 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
72936 unsigned int dlen);
72937 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
72938 -};
72939 +} __no_const;
72940
72941 #define crt_ablkcipher crt_u.ablkcipher
72942 #define crt_aead crt_u.aead
72943 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
72944 index 653589e..4ef254a 100644
72945 --- a/include/linux/ctype.h
72946 +++ b/include/linux/ctype.h
72947 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
72948 * Fast implementation of tolower() for internal usage. Do not use in your
72949 * code.
72950 */
72951 -static inline char _tolower(const char c)
72952 +static inline unsigned char _tolower(const unsigned char c)
72953 {
72954 return c | 0x20;
72955 }
72956 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
72957 index 7925bf0..d5143d2 100644
72958 --- a/include/linux/decompress/mm.h
72959 +++ b/include/linux/decompress/mm.h
72960 @@ -77,7 +77,7 @@ static void free(void *where)
72961 * warnings when not needed (indeed large_malloc / large_free are not
72962 * needed by inflate */
72963
72964 -#define malloc(a) kmalloc(a, GFP_KERNEL)
72965 +#define malloc(a) kmalloc((a), GFP_KERNEL)
72966 #define free(a) kfree(a)
72967
72968 #define large_malloc(a) vmalloc(a)
72969 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
72970 index 5f1ab92..39c35ae 100644
72971 --- a/include/linux/devfreq.h
72972 +++ b/include/linux/devfreq.h
72973 @@ -114,7 +114,7 @@ struct devfreq_governor {
72974 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
72975 int (*event_handler)(struct devfreq *devfreq,
72976 unsigned int event, void *data);
72977 -};
72978 +} __do_const;
72979
72980 /**
72981 * struct devfreq - Device devfreq structure
72982 diff --git a/include/linux/device.h b/include/linux/device.h
72983 index 22b546a..a573dc9 100644
72984 --- a/include/linux/device.h
72985 +++ b/include/linux/device.h
72986 @@ -305,7 +305,7 @@ struct subsys_interface {
72987 struct list_head node;
72988 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
72989 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
72990 -};
72991 +} __do_const;
72992
72993 int subsys_interface_register(struct subsys_interface *sif);
72994 void subsys_interface_unregister(struct subsys_interface *sif);
72995 @@ -493,7 +493,7 @@ struct device_type {
72996 void (*release)(struct device *dev);
72997
72998 const struct dev_pm_ops *pm;
72999 -};
73000 +} __do_const;
73001
73002 /* interface for exporting device attributes */
73003 struct device_attribute {
73004 @@ -503,11 +503,12 @@ struct device_attribute {
73005 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
73006 const char *buf, size_t count);
73007 };
73008 +typedef struct device_attribute __no_const device_attribute_no_const;
73009
73010 struct dev_ext_attribute {
73011 struct device_attribute attr;
73012 void *var;
73013 -};
73014 +} __do_const;
73015
73016 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
73017 char *buf);
73018 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
73019 index 94af418..b1ca7a2 100644
73020 --- a/include/linux/dma-mapping.h
73021 +++ b/include/linux/dma-mapping.h
73022 @@ -54,7 +54,7 @@ struct dma_map_ops {
73023 u64 (*get_required_mask)(struct device *dev);
73024 #endif
73025 int is_phys;
73026 -};
73027 +} __do_const;
73028
73029 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
73030
73031 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
73032 index cb286b1..923d066 100644
73033 --- a/include/linux/dmaengine.h
73034 +++ b/include/linux/dmaengine.h
73035 @@ -1030,9 +1030,9 @@ struct dma_pinned_list {
73036 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
73037 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
73038
73039 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73040 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
73041 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
73042 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73043 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
73044 struct dma_pinned_list *pinned_list, struct page *page,
73045 unsigned int offset, size_t len);
73046
73047 diff --git a/include/linux/efi.h b/include/linux/efi.h
73048 index 5f8f176..62a0556 100644
73049 --- a/include/linux/efi.h
73050 +++ b/include/linux/efi.h
73051 @@ -745,6 +745,7 @@ struct efivar_operations {
73052 efi_set_variable_t *set_variable;
73053 efi_query_variable_store_t *query_variable_store;
73054 };
73055 +typedef struct efivar_operations __no_const efivar_operations_no_const;
73056
73057 struct efivars {
73058 /*
73059 diff --git a/include/linux/elf.h b/include/linux/elf.h
73060 index 40a3c0e..4c45a38 100644
73061 --- a/include/linux/elf.h
73062 +++ b/include/linux/elf.h
73063 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
73064 #define elf_note elf32_note
73065 #define elf_addr_t Elf32_Off
73066 #define Elf_Half Elf32_Half
73067 +#define elf_dyn Elf32_Dyn
73068
73069 #else
73070
73071 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
73072 #define elf_note elf64_note
73073 #define elf_addr_t Elf64_Off
73074 #define Elf_Half Elf64_Half
73075 +#define elf_dyn Elf64_Dyn
73076
73077 #endif
73078
73079 diff --git a/include/linux/err.h b/include/linux/err.h
73080 index 221fcfb..f29e5e2 100644
73081 --- a/include/linux/err.h
73082 +++ b/include/linux/err.h
73083 @@ -19,12 +19,12 @@
73084
73085 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
73086
73087 -static inline void * __must_check ERR_PTR(long error)
73088 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
73089 {
73090 return (void *) error;
73091 }
73092
73093 -static inline long __must_check PTR_ERR(__force const void *ptr)
73094 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
73095 {
73096 return (long) ptr;
73097 }
73098 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
73099 index fcb51c8..bdafcf6 100644
73100 --- a/include/linux/extcon.h
73101 +++ b/include/linux/extcon.h
73102 @@ -134,7 +134,7 @@ struct extcon_dev {
73103 /* /sys/class/extcon/.../mutually_exclusive/... */
73104 struct attribute_group attr_g_muex;
73105 struct attribute **attrs_muex;
73106 - struct device_attribute *d_attrs_muex;
73107 + device_attribute_no_const *d_attrs_muex;
73108 };
73109
73110 /**
73111 diff --git a/include/linux/fb.h b/include/linux/fb.h
73112 index ffac70a..ca3e711 100644
73113 --- a/include/linux/fb.h
73114 +++ b/include/linux/fb.h
73115 @@ -304,7 +304,7 @@ struct fb_ops {
73116 /* called at KDB enter and leave time to prepare the console */
73117 int (*fb_debug_enter)(struct fb_info *info);
73118 int (*fb_debug_leave)(struct fb_info *info);
73119 -};
73120 +} __do_const;
73121
73122 #ifdef CONFIG_FB_TILEBLITTING
73123 #define FB_TILE_CURSOR_NONE 0
73124 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
73125 index 085197b..0fa6f0b 100644
73126 --- a/include/linux/fdtable.h
73127 +++ b/include/linux/fdtable.h
73128 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
73129 void put_files_struct(struct files_struct *fs);
73130 void reset_files_struct(struct files_struct *);
73131 int unshare_files(struct files_struct **);
73132 -struct files_struct *dup_fd(struct files_struct *, int *);
73133 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
73134 void do_close_on_exec(struct files_struct *);
73135 int iterate_fd(struct files_struct *, unsigned,
73136 int (*)(const void *, struct file *, unsigned),
73137 diff --git a/include/linux/filter.h b/include/linux/filter.h
73138 index a6ac848..a104a76 100644
73139 --- a/include/linux/filter.h
73140 +++ b/include/linux/filter.h
73141 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
73142
73143 struct sk_buff;
73144 struct sock;
73145 +struct bpf_jit_work;
73146
73147 struct sk_filter
73148 {
73149 @@ -27,6 +28,9 @@ struct sk_filter
73150 unsigned int len; /* Number of filter blocks */
73151 unsigned int (*bpf_func)(const struct sk_buff *skb,
73152 const struct sock_filter *filter);
73153 +#ifdef CONFIG_BPF_JIT
73154 + struct bpf_jit_work *work;
73155 +#endif
73156 struct rcu_head rcu;
73157 struct sock_filter insns[0];
73158 };
73159 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
73160 index 8293262..2b3b8bd 100644
73161 --- a/include/linux/frontswap.h
73162 +++ b/include/linux/frontswap.h
73163 @@ -11,7 +11,7 @@ struct frontswap_ops {
73164 int (*load)(unsigned, pgoff_t, struct page *);
73165 void (*invalidate_page)(unsigned, pgoff_t);
73166 void (*invalidate_area)(unsigned);
73167 -};
73168 +} __no_const;
73169
73170 extern bool frontswap_enabled;
73171 extern struct frontswap_ops *
73172 diff --git a/include/linux/fs.h b/include/linux/fs.h
73173 index 9818747..788bfbd 100644
73174 --- a/include/linux/fs.h
73175 +++ b/include/linux/fs.h
73176 @@ -1554,7 +1554,8 @@ struct file_operations {
73177 long (*fallocate)(struct file *file, int mode, loff_t offset,
73178 loff_t len);
73179 int (*show_fdinfo)(struct seq_file *m, struct file *f);
73180 -};
73181 +} __do_const;
73182 +typedef struct file_operations __no_const file_operations_no_const;
73183
73184 struct inode_operations {
73185 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
73186 @@ -2740,4 +2741,14 @@ static inline bool dir_relax(struct inode *inode)
73187 return !IS_DEADDIR(inode);
73188 }
73189
73190 +static inline bool is_sidechannel_device(const struct inode *inode)
73191 +{
73192 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
73193 + umode_t mode = inode->i_mode;
73194 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
73195 +#else
73196 + return false;
73197 +#endif
73198 +}
73199 +
73200 #endif /* _LINUX_FS_H */
73201 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
73202 index 2b93a9a..855d94a 100644
73203 --- a/include/linux/fs_struct.h
73204 +++ b/include/linux/fs_struct.h
73205 @@ -6,7 +6,7 @@
73206 #include <linux/seqlock.h>
73207
73208 struct fs_struct {
73209 - int users;
73210 + atomic_t users;
73211 spinlock_t lock;
73212 seqcount_t seq;
73213 int umask;
73214 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
73215 index a9ff9a3..1ba1788 100644
73216 --- a/include/linux/fscache-cache.h
73217 +++ b/include/linux/fscache-cache.h
73218 @@ -113,7 +113,7 @@ struct fscache_operation {
73219 fscache_operation_release_t release;
73220 };
73221
73222 -extern atomic_t fscache_op_debug_id;
73223 +extern atomic_unchecked_t fscache_op_debug_id;
73224 extern void fscache_op_work_func(struct work_struct *work);
73225
73226 extern void fscache_enqueue_operation(struct fscache_operation *);
73227 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
73228 INIT_WORK(&op->work, fscache_op_work_func);
73229 atomic_set(&op->usage, 1);
73230 op->state = FSCACHE_OP_ST_INITIALISED;
73231 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
73232 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
73233 op->processor = processor;
73234 op->release = release;
73235 INIT_LIST_HEAD(&op->pend_link);
73236 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
73237 index 7a08623..4c07b0f 100644
73238 --- a/include/linux/fscache.h
73239 +++ b/include/linux/fscache.h
73240 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
73241 * - this is mandatory for any object that may have data
73242 */
73243 void (*now_uncached)(void *cookie_netfs_data);
73244 -};
73245 +} __do_const;
73246
73247 /*
73248 * fscache cached network filesystem type
73249 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
73250 index 1c804b0..1432c2b 100644
73251 --- a/include/linux/fsnotify.h
73252 +++ b/include/linux/fsnotify.h
73253 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
73254 struct inode *inode = file_inode(file);
73255 __u32 mask = FS_ACCESS;
73256
73257 + if (is_sidechannel_device(inode))
73258 + return;
73259 +
73260 if (S_ISDIR(inode->i_mode))
73261 mask |= FS_ISDIR;
73262
73263 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
73264 struct inode *inode = file_inode(file);
73265 __u32 mask = FS_MODIFY;
73266
73267 + if (is_sidechannel_device(inode))
73268 + return;
73269 +
73270 if (S_ISDIR(inode->i_mode))
73271 mask |= FS_ISDIR;
73272
73273 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
73274 */
73275 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
73276 {
73277 - return kstrdup(name, GFP_KERNEL);
73278 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
73279 }
73280
73281 /*
73282 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
73283 index 9f3c275..8bdff5d 100644
73284 --- a/include/linux/genhd.h
73285 +++ b/include/linux/genhd.h
73286 @@ -194,7 +194,7 @@ struct gendisk {
73287 struct kobject *slave_dir;
73288
73289 struct timer_rand_state *random;
73290 - atomic_t sync_io; /* RAID */
73291 + atomic_unchecked_t sync_io; /* RAID */
73292 struct disk_events *ev;
73293 #ifdef CONFIG_BLK_DEV_INTEGRITY
73294 struct blk_integrity *integrity;
73295 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
73296 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
73297
73298 /* drivers/char/random.c */
73299 -extern void add_disk_randomness(struct gendisk *disk);
73300 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
73301 extern void rand_initialize_disk(struct gendisk *disk);
73302
73303 static inline sector_t get_start_sect(struct block_device *bdev)
73304 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
73305 index 023bc34..b02b46a 100644
73306 --- a/include/linux/genl_magic_func.h
73307 +++ b/include/linux/genl_magic_func.h
73308 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
73309 },
73310
73311 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
73312 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
73313 +static struct genl_ops ZZZ_genl_ops[] = {
73314 #include GENL_MAGIC_INCLUDE_FILE
73315 };
73316
73317 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
73318 index 9b4dd49..61fd41d 100644
73319 --- a/include/linux/gfp.h
73320 +++ b/include/linux/gfp.h
73321 @@ -35,6 +35,13 @@ struct vm_area_struct;
73322 #define ___GFP_NO_KSWAPD 0x400000u
73323 #define ___GFP_OTHER_NODE 0x800000u
73324 #define ___GFP_WRITE 0x1000000u
73325 +
73326 +#ifdef CONFIG_PAX_USERCOPY_SLABS
73327 +#define ___GFP_USERCOPY 0x2000000u
73328 +#else
73329 +#define ___GFP_USERCOPY 0
73330 +#endif
73331 +
73332 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
73333
73334 /*
73335 @@ -92,6 +99,7 @@ struct vm_area_struct;
73336 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
73337 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
73338 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
73339 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
73340
73341 /*
73342 * This may seem redundant, but it's a way of annotating false positives vs.
73343 @@ -99,7 +107,7 @@ struct vm_area_struct;
73344 */
73345 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
73346
73347 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
73348 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
73349 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
73350
73351 /* This equals 0, but use constants in case they ever change */
73352 @@ -153,6 +161,8 @@ struct vm_area_struct;
73353 /* 4GB DMA on some platforms */
73354 #define GFP_DMA32 __GFP_DMA32
73355
73356 +#define GFP_USERCOPY __GFP_USERCOPY
73357 +
73358 /* Convert GFP flags to their corresponding migrate type */
73359 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
73360 {
73361 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
73362 new file mode 100644
73363 index 0000000..ebe6d72
73364 --- /dev/null
73365 +++ b/include/linux/gracl.h
73366 @@ -0,0 +1,319 @@
73367 +#ifndef GR_ACL_H
73368 +#define GR_ACL_H
73369 +
73370 +#include <linux/grdefs.h>
73371 +#include <linux/resource.h>
73372 +#include <linux/capability.h>
73373 +#include <linux/dcache.h>
73374 +#include <asm/resource.h>
73375 +
73376 +/* Major status information */
73377 +
73378 +#define GR_VERSION "grsecurity 2.9.1"
73379 +#define GRSECURITY_VERSION 0x2901
73380 +
73381 +enum {
73382 + GR_SHUTDOWN = 0,
73383 + GR_ENABLE = 1,
73384 + GR_SPROLE = 2,
73385 + GR_RELOAD = 3,
73386 + GR_SEGVMOD = 4,
73387 + GR_STATUS = 5,
73388 + GR_UNSPROLE = 6,
73389 + GR_PASSSET = 7,
73390 + GR_SPROLEPAM = 8,
73391 +};
73392 +
73393 +/* Password setup definitions
73394 + * kernel/grhash.c */
73395 +enum {
73396 + GR_PW_LEN = 128,
73397 + GR_SALT_LEN = 16,
73398 + GR_SHA_LEN = 32,
73399 +};
73400 +
73401 +enum {
73402 + GR_SPROLE_LEN = 64,
73403 +};
73404 +
73405 +enum {
73406 + GR_NO_GLOB = 0,
73407 + GR_REG_GLOB,
73408 + GR_CREATE_GLOB
73409 +};
73410 +
73411 +#define GR_NLIMITS 32
73412 +
73413 +/* Begin Data Structures */
73414 +
73415 +struct sprole_pw {
73416 + unsigned char *rolename;
73417 + unsigned char salt[GR_SALT_LEN];
73418 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
73419 +};
73420 +
73421 +struct name_entry {
73422 + __u32 key;
73423 + ino_t inode;
73424 + dev_t device;
73425 + char *name;
73426 + __u16 len;
73427 + __u8 deleted;
73428 + struct name_entry *prev;
73429 + struct name_entry *next;
73430 +};
73431 +
73432 +struct inodev_entry {
73433 + struct name_entry *nentry;
73434 + struct inodev_entry *prev;
73435 + struct inodev_entry *next;
73436 +};
73437 +
73438 +struct acl_role_db {
73439 + struct acl_role_label **r_hash;
73440 + __u32 r_size;
73441 +};
73442 +
73443 +struct inodev_db {
73444 + struct inodev_entry **i_hash;
73445 + __u32 i_size;
73446 +};
73447 +
73448 +struct name_db {
73449 + struct name_entry **n_hash;
73450 + __u32 n_size;
73451 +};
73452 +
73453 +struct crash_uid {
73454 + uid_t uid;
73455 + unsigned long expires;
73456 +};
73457 +
73458 +struct gr_hash_struct {
73459 + void **table;
73460 + void **nametable;
73461 + void *first;
73462 + __u32 table_size;
73463 + __u32 used_size;
73464 + int type;
73465 +};
73466 +
73467 +/* Userspace Grsecurity ACL data structures */
73468 +
73469 +struct acl_subject_label {
73470 + char *filename;
73471 + ino_t inode;
73472 + dev_t device;
73473 + __u32 mode;
73474 + kernel_cap_t cap_mask;
73475 + kernel_cap_t cap_lower;
73476 + kernel_cap_t cap_invert_audit;
73477 +
73478 + struct rlimit res[GR_NLIMITS];
73479 + __u32 resmask;
73480 +
73481 + __u8 user_trans_type;
73482 + __u8 group_trans_type;
73483 + uid_t *user_transitions;
73484 + gid_t *group_transitions;
73485 + __u16 user_trans_num;
73486 + __u16 group_trans_num;
73487 +
73488 + __u32 sock_families[2];
73489 + __u32 ip_proto[8];
73490 + __u32 ip_type;
73491 + struct acl_ip_label **ips;
73492 + __u32 ip_num;
73493 + __u32 inaddr_any_override;
73494 +
73495 + __u32 crashes;
73496 + unsigned long expires;
73497 +
73498 + struct acl_subject_label *parent_subject;
73499 + struct gr_hash_struct *hash;
73500 + struct acl_subject_label *prev;
73501 + struct acl_subject_label *next;
73502 +
73503 + struct acl_object_label **obj_hash;
73504 + __u32 obj_hash_size;
73505 + __u16 pax_flags;
73506 +};
73507 +
73508 +struct role_allowed_ip {
73509 + __u32 addr;
73510 + __u32 netmask;
73511 +
73512 + struct role_allowed_ip *prev;
73513 + struct role_allowed_ip *next;
73514 +};
73515 +
73516 +struct role_transition {
73517 + char *rolename;
73518 +
73519 + struct role_transition *prev;
73520 + struct role_transition *next;
73521 +};
73522 +
73523 +struct acl_role_label {
73524 + char *rolename;
73525 + uid_t uidgid;
73526 + __u16 roletype;
73527 +
73528 + __u16 auth_attempts;
73529 + unsigned long expires;
73530 +
73531 + struct acl_subject_label *root_label;
73532 + struct gr_hash_struct *hash;
73533 +
73534 + struct acl_role_label *prev;
73535 + struct acl_role_label *next;
73536 +
73537 + struct role_transition *transitions;
73538 + struct role_allowed_ip *allowed_ips;
73539 + uid_t *domain_children;
73540 + __u16 domain_child_num;
73541 +
73542 + umode_t umask;
73543 +
73544 + struct acl_subject_label **subj_hash;
73545 + __u32 subj_hash_size;
73546 +};
73547 +
73548 +struct user_acl_role_db {
73549 + struct acl_role_label **r_table;
73550 + __u32 num_pointers; /* Number of allocations to track */
73551 + __u32 num_roles; /* Number of roles */
73552 + __u32 num_domain_children; /* Number of domain children */
73553 + __u32 num_subjects; /* Number of subjects */
73554 + __u32 num_objects; /* Number of objects */
73555 +};
73556 +
73557 +struct acl_object_label {
73558 + char *filename;
73559 + ino_t inode;
73560 + dev_t device;
73561 + __u32 mode;
73562 +
73563 + struct acl_subject_label *nested;
73564 + struct acl_object_label *globbed;
73565 +
73566 + /* next two structures not used */
73567 +
73568 + struct acl_object_label *prev;
73569 + struct acl_object_label *next;
73570 +};
73571 +
73572 +struct acl_ip_label {
73573 + char *iface;
73574 + __u32 addr;
73575 + __u32 netmask;
73576 + __u16 low, high;
73577 + __u8 mode;
73578 + __u32 type;
73579 + __u32 proto[8];
73580 +
73581 + /* next two structures not used */
73582 +
73583 + struct acl_ip_label *prev;
73584 + struct acl_ip_label *next;
73585 +};
73586 +
73587 +struct gr_arg {
73588 + struct user_acl_role_db role_db;
73589 + unsigned char pw[GR_PW_LEN];
73590 + unsigned char salt[GR_SALT_LEN];
73591 + unsigned char sum[GR_SHA_LEN];
73592 + unsigned char sp_role[GR_SPROLE_LEN];
73593 + struct sprole_pw *sprole_pws;
73594 + dev_t segv_device;
73595 + ino_t segv_inode;
73596 + uid_t segv_uid;
73597 + __u16 num_sprole_pws;
73598 + __u16 mode;
73599 +};
73600 +
73601 +struct gr_arg_wrapper {
73602 + struct gr_arg *arg;
73603 + __u32 version;
73604 + __u32 size;
73605 +};
73606 +
73607 +struct subject_map {
73608 + struct acl_subject_label *user;
73609 + struct acl_subject_label *kernel;
73610 + struct subject_map *prev;
73611 + struct subject_map *next;
73612 +};
73613 +
73614 +struct acl_subj_map_db {
73615 + struct subject_map **s_hash;
73616 + __u32 s_size;
73617 +};
73618 +
73619 +/* End Data Structures Section */
73620 +
73621 +/* Hash functions generated by empirical testing by Brad Spengler
73622 + Makes good use of the low bits of the inode. Generally 0-1 times
73623 + in loop for successful match. 0-3 for unsuccessful match.
73624 + Shift/add algorithm with modulus of table size and an XOR*/
73625 +
73626 +static __inline__ unsigned int
73627 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
73628 +{
73629 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
73630 +}
73631 +
73632 + static __inline__ unsigned int
73633 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
73634 +{
73635 + return ((const unsigned long)userp % sz);
73636 +}
73637 +
73638 +static __inline__ unsigned int
73639 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
73640 +{
73641 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
73642 +}
73643 +
73644 +static __inline__ unsigned int
73645 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
73646 +{
73647 + return full_name_hash((const unsigned char *)name, len) % sz;
73648 +}
73649 +
73650 +#define FOR_EACH_ROLE_START(role) \
73651 + role = role_list; \
73652 + while (role) {
73653 +
73654 +#define FOR_EACH_ROLE_END(role) \
73655 + role = role->prev; \
73656 + }
73657 +
73658 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
73659 + subj = NULL; \
73660 + iter = 0; \
73661 + while (iter < role->subj_hash_size) { \
73662 + if (subj == NULL) \
73663 + subj = role->subj_hash[iter]; \
73664 + if (subj == NULL) { \
73665 + iter++; \
73666 + continue; \
73667 + }
73668 +
73669 +#define FOR_EACH_SUBJECT_END(subj,iter) \
73670 + subj = subj->next; \
73671 + if (subj == NULL) \
73672 + iter++; \
73673 + }
73674 +
73675 +
73676 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
73677 + subj = role->hash->first; \
73678 + while (subj != NULL) {
73679 +
73680 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
73681 + subj = subj->next; \
73682 + }
73683 +
73684 +#endif
73685 +
73686 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
73687 new file mode 100644
73688 index 0000000..33ebd1f
73689 --- /dev/null
73690 +++ b/include/linux/gracl_compat.h
73691 @@ -0,0 +1,156 @@
73692 +#ifndef GR_ACL_COMPAT_H
73693 +#define GR_ACL_COMPAT_H
73694 +
73695 +#include <linux/resource.h>
73696 +#include <asm/resource.h>
73697 +
73698 +struct sprole_pw_compat {
73699 + compat_uptr_t rolename;
73700 + unsigned char salt[GR_SALT_LEN];
73701 + unsigned char sum[GR_SHA_LEN];
73702 +};
73703 +
73704 +struct gr_hash_struct_compat {
73705 + compat_uptr_t table;
73706 + compat_uptr_t nametable;
73707 + compat_uptr_t first;
73708 + __u32 table_size;
73709 + __u32 used_size;
73710 + int type;
73711 +};
73712 +
73713 +struct acl_subject_label_compat {
73714 + compat_uptr_t filename;
73715 + compat_ino_t inode;
73716 + __u32 device;
73717 + __u32 mode;
73718 + kernel_cap_t cap_mask;
73719 + kernel_cap_t cap_lower;
73720 + kernel_cap_t cap_invert_audit;
73721 +
73722 + struct compat_rlimit res[GR_NLIMITS];
73723 + __u32 resmask;
73724 +
73725 + __u8 user_trans_type;
73726 + __u8 group_trans_type;
73727 + compat_uptr_t user_transitions;
73728 + compat_uptr_t group_transitions;
73729 + __u16 user_trans_num;
73730 + __u16 group_trans_num;
73731 +
73732 + __u32 sock_families[2];
73733 + __u32 ip_proto[8];
73734 + __u32 ip_type;
73735 + compat_uptr_t ips;
73736 + __u32 ip_num;
73737 + __u32 inaddr_any_override;
73738 +
73739 + __u32 crashes;
73740 + compat_ulong_t expires;
73741 +
73742 + compat_uptr_t parent_subject;
73743 + compat_uptr_t hash;
73744 + compat_uptr_t prev;
73745 + compat_uptr_t next;
73746 +
73747 + compat_uptr_t obj_hash;
73748 + __u32 obj_hash_size;
73749 + __u16 pax_flags;
73750 +};
73751 +
73752 +struct role_allowed_ip_compat {
73753 + __u32 addr;
73754 + __u32 netmask;
73755 +
73756 + compat_uptr_t prev;
73757 + compat_uptr_t next;
73758 +};
73759 +
73760 +struct role_transition_compat {
73761 + compat_uptr_t rolename;
73762 +
73763 + compat_uptr_t prev;
73764 + compat_uptr_t next;
73765 +};
73766 +
73767 +struct acl_role_label_compat {
73768 + compat_uptr_t rolename;
73769 + uid_t uidgid;
73770 + __u16 roletype;
73771 +
73772 + __u16 auth_attempts;
73773 + compat_ulong_t expires;
73774 +
73775 + compat_uptr_t root_label;
73776 + compat_uptr_t hash;
73777 +
73778 + compat_uptr_t prev;
73779 + compat_uptr_t next;
73780 +
73781 + compat_uptr_t transitions;
73782 + compat_uptr_t allowed_ips;
73783 + compat_uptr_t domain_children;
73784 + __u16 domain_child_num;
73785 +
73786 + umode_t umask;
73787 +
73788 + compat_uptr_t subj_hash;
73789 + __u32 subj_hash_size;
73790 +};
73791 +
73792 +struct user_acl_role_db_compat {
73793 + compat_uptr_t r_table;
73794 + __u32 num_pointers;
73795 + __u32 num_roles;
73796 + __u32 num_domain_children;
73797 + __u32 num_subjects;
73798 + __u32 num_objects;
73799 +};
73800 +
73801 +struct acl_object_label_compat {
73802 + compat_uptr_t filename;
73803 + compat_ino_t inode;
73804 + __u32 device;
73805 + __u32 mode;
73806 +
73807 + compat_uptr_t nested;
73808 + compat_uptr_t globbed;
73809 +
73810 + compat_uptr_t prev;
73811 + compat_uptr_t next;
73812 +};
73813 +
73814 +struct acl_ip_label_compat {
73815 + compat_uptr_t iface;
73816 + __u32 addr;
73817 + __u32 netmask;
73818 + __u16 low, high;
73819 + __u8 mode;
73820 + __u32 type;
73821 + __u32 proto[8];
73822 +
73823 + compat_uptr_t prev;
73824 + compat_uptr_t next;
73825 +};
73826 +
73827 +struct gr_arg_compat {
73828 + struct user_acl_role_db_compat role_db;
73829 + unsigned char pw[GR_PW_LEN];
73830 + unsigned char salt[GR_SALT_LEN];
73831 + unsigned char sum[GR_SHA_LEN];
73832 + unsigned char sp_role[GR_SPROLE_LEN];
73833 + compat_uptr_t sprole_pws;
73834 + __u32 segv_device;
73835 + compat_ino_t segv_inode;
73836 + uid_t segv_uid;
73837 + __u16 num_sprole_pws;
73838 + __u16 mode;
73839 +};
73840 +
73841 +struct gr_arg_wrapper_compat {
73842 + compat_uptr_t arg;
73843 + __u32 version;
73844 + __u32 size;
73845 +};
73846 +
73847 +#endif
73848 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
73849 new file mode 100644
73850 index 0000000..323ecf2
73851 --- /dev/null
73852 +++ b/include/linux/gralloc.h
73853 @@ -0,0 +1,9 @@
73854 +#ifndef __GRALLOC_H
73855 +#define __GRALLOC_H
73856 +
73857 +void acl_free_all(void);
73858 +int acl_alloc_stack_init(unsigned long size);
73859 +void *acl_alloc(unsigned long len);
73860 +void *acl_alloc_num(unsigned long num, unsigned long len);
73861 +
73862 +#endif
73863 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
73864 new file mode 100644
73865 index 0000000..be66033
73866 --- /dev/null
73867 +++ b/include/linux/grdefs.h
73868 @@ -0,0 +1,140 @@
73869 +#ifndef GRDEFS_H
73870 +#define GRDEFS_H
73871 +
73872 +/* Begin grsecurity status declarations */
73873 +
73874 +enum {
73875 + GR_READY = 0x01,
73876 + GR_STATUS_INIT = 0x00 // disabled state
73877 +};
73878 +
73879 +/* Begin ACL declarations */
73880 +
73881 +/* Role flags */
73882 +
73883 +enum {
73884 + GR_ROLE_USER = 0x0001,
73885 + GR_ROLE_GROUP = 0x0002,
73886 + GR_ROLE_DEFAULT = 0x0004,
73887 + GR_ROLE_SPECIAL = 0x0008,
73888 + GR_ROLE_AUTH = 0x0010,
73889 + GR_ROLE_NOPW = 0x0020,
73890 + GR_ROLE_GOD = 0x0040,
73891 + GR_ROLE_LEARN = 0x0080,
73892 + GR_ROLE_TPE = 0x0100,
73893 + GR_ROLE_DOMAIN = 0x0200,
73894 + GR_ROLE_PAM = 0x0400,
73895 + GR_ROLE_PERSIST = 0x0800
73896 +};
73897 +
73898 +/* ACL Subject and Object mode flags */
73899 +enum {
73900 + GR_DELETED = 0x80000000
73901 +};
73902 +
73903 +/* ACL Object-only mode flags */
73904 +enum {
73905 + GR_READ = 0x00000001,
73906 + GR_APPEND = 0x00000002,
73907 + GR_WRITE = 0x00000004,
73908 + GR_EXEC = 0x00000008,
73909 + GR_FIND = 0x00000010,
73910 + GR_INHERIT = 0x00000020,
73911 + GR_SETID = 0x00000040,
73912 + GR_CREATE = 0x00000080,
73913 + GR_DELETE = 0x00000100,
73914 + GR_LINK = 0x00000200,
73915 + GR_AUDIT_READ = 0x00000400,
73916 + GR_AUDIT_APPEND = 0x00000800,
73917 + GR_AUDIT_WRITE = 0x00001000,
73918 + GR_AUDIT_EXEC = 0x00002000,
73919 + GR_AUDIT_FIND = 0x00004000,
73920 + GR_AUDIT_INHERIT= 0x00008000,
73921 + GR_AUDIT_SETID = 0x00010000,
73922 + GR_AUDIT_CREATE = 0x00020000,
73923 + GR_AUDIT_DELETE = 0x00040000,
73924 + GR_AUDIT_LINK = 0x00080000,
73925 + GR_PTRACERD = 0x00100000,
73926 + GR_NOPTRACE = 0x00200000,
73927 + GR_SUPPRESS = 0x00400000,
73928 + GR_NOLEARN = 0x00800000,
73929 + GR_INIT_TRANSFER= 0x01000000
73930 +};
73931 +
73932 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
73933 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
73934 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
73935 +
73936 +/* ACL subject-only mode flags */
73937 +enum {
73938 + GR_KILL = 0x00000001,
73939 + GR_VIEW = 0x00000002,
73940 + GR_PROTECTED = 0x00000004,
73941 + GR_LEARN = 0x00000008,
73942 + GR_OVERRIDE = 0x00000010,
73943 + /* just a placeholder, this mode is only used in userspace */
73944 + GR_DUMMY = 0x00000020,
73945 + GR_PROTSHM = 0x00000040,
73946 + GR_KILLPROC = 0x00000080,
73947 + GR_KILLIPPROC = 0x00000100,
73948 + /* just a placeholder, this mode is only used in userspace */
73949 + GR_NOTROJAN = 0x00000200,
73950 + GR_PROTPROCFD = 0x00000400,
73951 + GR_PROCACCT = 0x00000800,
73952 + GR_RELAXPTRACE = 0x00001000,
73953 + //GR_NESTED = 0x00002000,
73954 + GR_INHERITLEARN = 0x00004000,
73955 + GR_PROCFIND = 0x00008000,
73956 + GR_POVERRIDE = 0x00010000,
73957 + GR_KERNELAUTH = 0x00020000,
73958 + GR_ATSECURE = 0x00040000,
73959 + GR_SHMEXEC = 0x00080000
73960 +};
73961 +
73962 +enum {
73963 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
73964 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
73965 + GR_PAX_ENABLE_MPROTECT = 0x0004,
73966 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
73967 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
73968 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
73969 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
73970 + GR_PAX_DISABLE_MPROTECT = 0x0400,
73971 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
73972 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
73973 +};
73974 +
73975 +enum {
73976 + GR_ID_USER = 0x01,
73977 + GR_ID_GROUP = 0x02,
73978 +};
73979 +
73980 +enum {
73981 + GR_ID_ALLOW = 0x01,
73982 + GR_ID_DENY = 0x02,
73983 +};
73984 +
73985 +#define GR_CRASH_RES 31
73986 +#define GR_UIDTABLE_MAX 500
73987 +
73988 +/* begin resource learning section */
73989 +enum {
73990 + GR_RLIM_CPU_BUMP = 60,
73991 + GR_RLIM_FSIZE_BUMP = 50000,
73992 + GR_RLIM_DATA_BUMP = 10000,
73993 + GR_RLIM_STACK_BUMP = 1000,
73994 + GR_RLIM_CORE_BUMP = 10000,
73995 + GR_RLIM_RSS_BUMP = 500000,
73996 + GR_RLIM_NPROC_BUMP = 1,
73997 + GR_RLIM_NOFILE_BUMP = 5,
73998 + GR_RLIM_MEMLOCK_BUMP = 50000,
73999 + GR_RLIM_AS_BUMP = 500000,
74000 + GR_RLIM_LOCKS_BUMP = 2,
74001 + GR_RLIM_SIGPENDING_BUMP = 5,
74002 + GR_RLIM_MSGQUEUE_BUMP = 10000,
74003 + GR_RLIM_NICE_BUMP = 1,
74004 + GR_RLIM_RTPRIO_BUMP = 1,
74005 + GR_RLIM_RTTIME_BUMP = 1000000
74006 +};
74007 +
74008 +#endif
74009 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
74010 new file mode 100644
74011 index 0000000..e337683
74012 --- /dev/null
74013 +++ b/include/linux/grinternal.h
74014 @@ -0,0 +1,229 @@
74015 +#ifndef __GRINTERNAL_H
74016 +#define __GRINTERNAL_H
74017 +
74018 +#ifdef CONFIG_GRKERNSEC
74019 +
74020 +#include <linux/fs.h>
74021 +#include <linux/mnt_namespace.h>
74022 +#include <linux/nsproxy.h>
74023 +#include <linux/gracl.h>
74024 +#include <linux/grdefs.h>
74025 +#include <linux/grmsg.h>
74026 +
74027 +void gr_add_learn_entry(const char *fmt, ...)
74028 + __attribute__ ((format (printf, 1, 2)));
74029 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
74030 + const struct vfsmount *mnt);
74031 +__u32 gr_check_create(const struct dentry *new_dentry,
74032 + const struct dentry *parent,
74033 + const struct vfsmount *mnt, const __u32 mode);
74034 +int gr_check_protected_task(const struct task_struct *task);
74035 +__u32 to_gr_audit(const __u32 reqmode);
74036 +int gr_set_acls(const int type);
74037 +int gr_apply_subject_to_task(struct task_struct *task);
74038 +int gr_acl_is_enabled(void);
74039 +char gr_roletype_to_char(void);
74040 +
74041 +void gr_handle_alertkill(struct task_struct *task);
74042 +char *gr_to_filename(const struct dentry *dentry,
74043 + const struct vfsmount *mnt);
74044 +char *gr_to_filename1(const struct dentry *dentry,
74045 + const struct vfsmount *mnt);
74046 +char *gr_to_filename2(const struct dentry *dentry,
74047 + const struct vfsmount *mnt);
74048 +char *gr_to_filename3(const struct dentry *dentry,
74049 + const struct vfsmount *mnt);
74050 +
74051 +extern int grsec_enable_ptrace_readexec;
74052 +extern int grsec_enable_harden_ptrace;
74053 +extern int grsec_enable_link;
74054 +extern int grsec_enable_fifo;
74055 +extern int grsec_enable_execve;
74056 +extern int grsec_enable_shm;
74057 +extern int grsec_enable_execlog;
74058 +extern int grsec_enable_signal;
74059 +extern int grsec_enable_audit_ptrace;
74060 +extern int grsec_enable_forkfail;
74061 +extern int grsec_enable_time;
74062 +extern int grsec_enable_rofs;
74063 +extern int grsec_deny_new_usb;
74064 +extern int grsec_enable_chroot_shmat;
74065 +extern int grsec_enable_chroot_mount;
74066 +extern int grsec_enable_chroot_double;
74067 +extern int grsec_enable_chroot_pivot;
74068 +extern int grsec_enable_chroot_chdir;
74069 +extern int grsec_enable_chroot_chmod;
74070 +extern int grsec_enable_chroot_mknod;
74071 +extern int grsec_enable_chroot_fchdir;
74072 +extern int grsec_enable_chroot_nice;
74073 +extern int grsec_enable_chroot_execlog;
74074 +extern int grsec_enable_chroot_caps;
74075 +extern int grsec_enable_chroot_sysctl;
74076 +extern int grsec_enable_chroot_unix;
74077 +extern int grsec_enable_symlinkown;
74078 +extern kgid_t grsec_symlinkown_gid;
74079 +extern int grsec_enable_tpe;
74080 +extern kgid_t grsec_tpe_gid;
74081 +extern int grsec_enable_tpe_all;
74082 +extern int grsec_enable_tpe_invert;
74083 +extern int grsec_enable_socket_all;
74084 +extern kgid_t grsec_socket_all_gid;
74085 +extern int grsec_enable_socket_client;
74086 +extern kgid_t grsec_socket_client_gid;
74087 +extern int grsec_enable_socket_server;
74088 +extern kgid_t grsec_socket_server_gid;
74089 +extern kgid_t grsec_audit_gid;
74090 +extern int grsec_enable_group;
74091 +extern int grsec_enable_log_rwxmaps;
74092 +extern int grsec_enable_mount;
74093 +extern int grsec_enable_chdir;
74094 +extern int grsec_resource_logging;
74095 +extern int grsec_enable_blackhole;
74096 +extern int grsec_lastack_retries;
74097 +extern int grsec_enable_brute;
74098 +extern int grsec_lock;
74099 +
74100 +extern spinlock_t grsec_alert_lock;
74101 +extern unsigned long grsec_alert_wtime;
74102 +extern unsigned long grsec_alert_fyet;
74103 +
74104 +extern spinlock_t grsec_audit_lock;
74105 +
74106 +extern rwlock_t grsec_exec_file_lock;
74107 +
74108 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
74109 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
74110 + (tsk)->exec_file->f_path.mnt) : "/")
74111 +
74112 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
74113 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
74114 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74115 +
74116 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
74117 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
74118 + (tsk)->exec_file->f_path.mnt) : "/")
74119 +
74120 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
74121 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
74122 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
74123 +
74124 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
74125 +
74126 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
74127 +
74128 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
74129 +{
74130 + if (file1 && file2) {
74131 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
74132 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
74133 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
74134 + return true;
74135 + }
74136 +
74137 + return false;
74138 +}
74139 +
74140 +#define GR_CHROOT_CAPS {{ \
74141 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
74142 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
74143 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
74144 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
74145 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
74146 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
74147 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
74148 +
74149 +#define security_learn(normal_msg,args...) \
74150 +({ \
74151 + read_lock(&grsec_exec_file_lock); \
74152 + gr_add_learn_entry(normal_msg "\n", ## args); \
74153 + read_unlock(&grsec_exec_file_lock); \
74154 +})
74155 +
74156 +enum {
74157 + GR_DO_AUDIT,
74158 + GR_DONT_AUDIT,
74159 + /* used for non-audit messages that we shouldn't kill the task on */
74160 + GR_DONT_AUDIT_GOOD
74161 +};
74162 +
74163 +enum {
74164 + GR_TTYSNIFF,
74165 + GR_RBAC,
74166 + GR_RBAC_STR,
74167 + GR_STR_RBAC,
74168 + GR_RBAC_MODE2,
74169 + GR_RBAC_MODE3,
74170 + GR_FILENAME,
74171 + GR_SYSCTL_HIDDEN,
74172 + GR_NOARGS,
74173 + GR_ONE_INT,
74174 + GR_ONE_INT_TWO_STR,
74175 + GR_ONE_STR,
74176 + GR_STR_INT,
74177 + GR_TWO_STR_INT,
74178 + GR_TWO_INT,
74179 + GR_TWO_U64,
74180 + GR_THREE_INT,
74181 + GR_FIVE_INT_TWO_STR,
74182 + GR_TWO_STR,
74183 + GR_THREE_STR,
74184 + GR_FOUR_STR,
74185 + GR_STR_FILENAME,
74186 + GR_FILENAME_STR,
74187 + GR_FILENAME_TWO_INT,
74188 + GR_FILENAME_TWO_INT_STR,
74189 + GR_TEXTREL,
74190 + GR_PTRACE,
74191 + GR_RESOURCE,
74192 + GR_CAP,
74193 + GR_SIG,
74194 + GR_SIG2,
74195 + GR_CRASH1,
74196 + GR_CRASH2,
74197 + GR_PSACCT,
74198 + GR_RWXMAP,
74199 + GR_RWXMAPVMA
74200 +};
74201 +
74202 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
74203 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
74204 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
74205 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
74206 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
74207 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
74208 +#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)
74209 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
74210 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
74211 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
74212 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
74213 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
74214 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
74215 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
74216 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
74217 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
74218 +#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)
74219 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
74220 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
74221 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
74222 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
74223 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
74224 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
74225 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
74226 +#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)
74227 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
74228 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
74229 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
74230 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
74231 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
74232 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
74233 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
74234 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
74235 +#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)
74236 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
74237 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
74238 +
74239 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
74240 +
74241 +#endif
74242 +
74243 +#endif
74244 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
74245 new file mode 100644
74246 index 0000000..a4396b5
74247 --- /dev/null
74248 +++ b/include/linux/grmsg.h
74249 @@ -0,0 +1,113 @@
74250 +#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"
74251 +#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"
74252 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
74253 +#define GR_STOPMOD_MSG "denied modification of module state by "
74254 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
74255 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
74256 +#define GR_IOPERM_MSG "denied use of ioperm() by "
74257 +#define GR_IOPL_MSG "denied use of iopl() by "
74258 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
74259 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
74260 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
74261 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
74262 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
74263 +#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"
74264 +#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"
74265 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
74266 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
74267 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
74268 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
74269 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
74270 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
74271 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
74272 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
74273 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
74274 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
74275 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
74276 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
74277 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
74278 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
74279 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
74280 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
74281 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
74282 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
74283 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
74284 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
74285 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
74286 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
74287 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
74288 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
74289 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
74290 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
74291 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
74292 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
74293 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
74294 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
74295 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
74296 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
74297 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
74298 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
74299 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
74300 +#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"
74301 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
74302 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
74303 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
74304 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
74305 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
74306 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
74307 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
74308 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
74309 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
74310 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
74311 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
74312 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
74313 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
74314 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
74315 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
74316 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
74317 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
74318 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
74319 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
74320 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
74321 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
74322 +#define GR_NICE_CHROOT_MSG "denied priority change by "
74323 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
74324 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
74325 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
74326 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
74327 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
74328 +#define GR_TIME_MSG "time set by "
74329 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
74330 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
74331 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
74332 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
74333 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
74334 +#define GR_BIND_MSG "denied bind() by "
74335 +#define GR_CONNECT_MSG "denied connect() by "
74336 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
74337 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
74338 +#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"
74339 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
74340 +#define GR_CAP_ACL_MSG "use of %s denied for "
74341 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
74342 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
74343 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
74344 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
74345 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
74346 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
74347 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
74348 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
74349 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
74350 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
74351 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
74352 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
74353 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
74354 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
74355 +#define GR_VM86_MSG "denied use of vm86 by "
74356 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
74357 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
74358 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
74359 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
74360 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
74361 +#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 "
74362 +#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 "
74363 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
74364 new file mode 100644
74365 index 0000000..d6f5a21
74366 --- /dev/null
74367 +++ b/include/linux/grsecurity.h
74368 @@ -0,0 +1,244 @@
74369 +#ifndef GR_SECURITY_H
74370 +#define GR_SECURITY_H
74371 +#include <linux/fs.h>
74372 +#include <linux/fs_struct.h>
74373 +#include <linux/binfmts.h>
74374 +#include <linux/gracl.h>
74375 +
74376 +/* notify of brain-dead configs */
74377 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74378 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
74379 +#endif
74380 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
74381 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
74382 +#endif
74383 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
74384 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
74385 +#endif
74386 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
74387 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
74388 +#endif
74389 +
74390 +int gr_handle_new_usb(void);
74391 +
74392 +void gr_handle_brute_attach(unsigned long mm_flags);
74393 +void gr_handle_brute_check(void);
74394 +void gr_handle_kernel_exploit(void);
74395 +
74396 +char gr_roletype_to_char(void);
74397 +
74398 +int gr_acl_enable_at_secure(void);
74399 +
74400 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
74401 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
74402 +
74403 +void gr_del_task_from_ip_table(struct task_struct *p);
74404 +
74405 +int gr_pid_is_chrooted(struct task_struct *p);
74406 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
74407 +int gr_handle_chroot_nice(void);
74408 +int gr_handle_chroot_sysctl(const int op);
74409 +int gr_handle_chroot_setpriority(struct task_struct *p,
74410 + const int niceval);
74411 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
74412 +int gr_handle_chroot_chroot(const struct dentry *dentry,
74413 + const struct vfsmount *mnt);
74414 +void gr_handle_chroot_chdir(const struct path *path);
74415 +int gr_handle_chroot_chmod(const struct dentry *dentry,
74416 + const struct vfsmount *mnt, const int mode);
74417 +int gr_handle_chroot_mknod(const struct dentry *dentry,
74418 + const struct vfsmount *mnt, const int mode);
74419 +int gr_handle_chroot_mount(const struct dentry *dentry,
74420 + const struct vfsmount *mnt,
74421 + const char *dev_name);
74422 +int gr_handle_chroot_pivot(void);
74423 +int gr_handle_chroot_unix(const pid_t pid);
74424 +
74425 +int gr_handle_rawio(const struct inode *inode);
74426 +
74427 +void gr_handle_ioperm(void);
74428 +void gr_handle_iopl(void);
74429 +
74430 +umode_t gr_acl_umask(void);
74431 +
74432 +int gr_tpe_allow(const struct file *file);
74433 +
74434 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
74435 +void gr_clear_chroot_entries(struct task_struct *task);
74436 +
74437 +void gr_log_forkfail(const int retval);
74438 +void gr_log_timechange(void);
74439 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
74440 +void gr_log_chdir(const struct dentry *dentry,
74441 + const struct vfsmount *mnt);
74442 +void gr_log_chroot_exec(const struct dentry *dentry,
74443 + const struct vfsmount *mnt);
74444 +void gr_log_remount(const char *devname, const int retval);
74445 +void gr_log_unmount(const char *devname, const int retval);
74446 +void gr_log_mount(const char *from, const char *to, const int retval);
74447 +void gr_log_textrel(struct vm_area_struct *vma);
74448 +void gr_log_ptgnustack(struct file *file);
74449 +void gr_log_rwxmmap(struct file *file);
74450 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
74451 +
74452 +int gr_handle_follow_link(const struct inode *parent,
74453 + const struct inode *inode,
74454 + const struct dentry *dentry,
74455 + const struct vfsmount *mnt);
74456 +int gr_handle_fifo(const struct dentry *dentry,
74457 + const struct vfsmount *mnt,
74458 + const struct dentry *dir, const int flag,
74459 + const int acc_mode);
74460 +int gr_handle_hardlink(const struct dentry *dentry,
74461 + const struct vfsmount *mnt,
74462 + struct inode *inode,
74463 + const int mode, const struct filename *to);
74464 +
74465 +int gr_is_capable(const int cap);
74466 +int gr_is_capable_nolog(const int cap);
74467 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
74468 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
74469 +
74470 +void gr_copy_label(struct task_struct *tsk);
74471 +void gr_handle_crash(struct task_struct *task, const int sig);
74472 +int gr_handle_signal(const struct task_struct *p, const int sig);
74473 +int gr_check_crash_uid(const kuid_t uid);
74474 +int gr_check_protected_task(const struct task_struct *task);
74475 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
74476 +int gr_acl_handle_mmap(const struct file *file,
74477 + const unsigned long prot);
74478 +int gr_acl_handle_mprotect(const struct file *file,
74479 + const unsigned long prot);
74480 +int gr_check_hidden_task(const struct task_struct *tsk);
74481 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
74482 + const struct vfsmount *mnt);
74483 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
74484 + const struct vfsmount *mnt);
74485 +__u32 gr_acl_handle_access(const struct dentry *dentry,
74486 + const struct vfsmount *mnt, const int fmode);
74487 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
74488 + const struct vfsmount *mnt, umode_t *mode);
74489 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
74490 + const struct vfsmount *mnt);
74491 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
74492 + const struct vfsmount *mnt);
74493 +int gr_handle_ptrace(struct task_struct *task, const long request);
74494 +int gr_handle_proc_ptrace(struct task_struct *task);
74495 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
74496 + const struct vfsmount *mnt);
74497 +int gr_check_crash_exec(const struct file *filp);
74498 +int gr_acl_is_enabled(void);
74499 +void gr_set_kernel_label(struct task_struct *task);
74500 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
74501 + const kgid_t gid);
74502 +int gr_set_proc_label(const struct dentry *dentry,
74503 + const struct vfsmount *mnt,
74504 + const int unsafe_flags);
74505 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
74506 + const struct vfsmount *mnt);
74507 +__u32 gr_acl_handle_open(const struct dentry *dentry,
74508 + const struct vfsmount *mnt, int acc_mode);
74509 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
74510 + const struct dentry *p_dentry,
74511 + const struct vfsmount *p_mnt,
74512 + int open_flags, int acc_mode, const int imode);
74513 +void gr_handle_create(const struct dentry *dentry,
74514 + const struct vfsmount *mnt);
74515 +void gr_handle_proc_create(const struct dentry *dentry,
74516 + const struct inode *inode);
74517 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
74518 + const struct dentry *parent_dentry,
74519 + const struct vfsmount *parent_mnt,
74520 + const int mode);
74521 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
74522 + const struct dentry *parent_dentry,
74523 + const struct vfsmount *parent_mnt);
74524 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
74525 + const struct vfsmount *mnt);
74526 +void gr_handle_delete(const ino_t ino, const dev_t dev);
74527 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
74528 + const struct vfsmount *mnt);
74529 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
74530 + const struct dentry *parent_dentry,
74531 + const struct vfsmount *parent_mnt,
74532 + const struct filename *from);
74533 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
74534 + const struct dentry *parent_dentry,
74535 + const struct vfsmount *parent_mnt,
74536 + const struct dentry *old_dentry,
74537 + const struct vfsmount *old_mnt, const struct filename *to);
74538 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
74539 +int gr_acl_handle_rename(struct dentry *new_dentry,
74540 + struct dentry *parent_dentry,
74541 + const struct vfsmount *parent_mnt,
74542 + struct dentry *old_dentry,
74543 + struct inode *old_parent_inode,
74544 + struct vfsmount *old_mnt, const struct filename *newname);
74545 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
74546 + struct dentry *old_dentry,
74547 + struct dentry *new_dentry,
74548 + struct vfsmount *mnt, const __u8 replace);
74549 +__u32 gr_check_link(const struct dentry *new_dentry,
74550 + const struct dentry *parent_dentry,
74551 + const struct vfsmount *parent_mnt,
74552 + const struct dentry *old_dentry,
74553 + const struct vfsmount *old_mnt);
74554 +int gr_acl_handle_filldir(const struct file *file, const char *name,
74555 + const unsigned int namelen, const ino_t ino);
74556 +
74557 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
74558 + const struct vfsmount *mnt);
74559 +void gr_acl_handle_exit(void);
74560 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
74561 +int gr_acl_handle_procpidmem(const struct task_struct *task);
74562 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
74563 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
74564 +void gr_audit_ptrace(struct task_struct *task);
74565 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
74566 +void gr_put_exec_file(struct task_struct *task);
74567 +
74568 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
74569 +
74570 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
74571 +extern void gr_learn_resource(const struct task_struct *task, const int res,
74572 + const unsigned long wanted, const int gt);
74573 +#else
74574 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
74575 + const unsigned long wanted, const int gt)
74576 +{
74577 +}
74578 +#endif
74579 +
74580 +#ifdef CONFIG_GRKERNSEC_RESLOG
74581 +extern void gr_log_resource(const struct task_struct *task, const int res,
74582 + const unsigned long wanted, const int gt);
74583 +#else
74584 +static inline void gr_log_resource(const struct task_struct *task, const int res,
74585 + const unsigned long wanted, const int gt)
74586 +{
74587 +}
74588 +#endif
74589 +
74590 +#ifdef CONFIG_GRKERNSEC
74591 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
74592 +void gr_handle_vm86(void);
74593 +void gr_handle_mem_readwrite(u64 from, u64 to);
74594 +
74595 +void gr_log_badprocpid(const char *entry);
74596 +
74597 +extern int grsec_enable_dmesg;
74598 +extern int grsec_disable_privio;
74599 +
74600 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74601 +extern kgid_t grsec_proc_gid;
74602 +#endif
74603 +
74604 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
74605 +extern int grsec_enable_chroot_findtask;
74606 +#endif
74607 +#ifdef CONFIG_GRKERNSEC_SETXID
74608 +extern int grsec_enable_setxid;
74609 +#endif
74610 +#endif
74611 +
74612 +#endif
74613 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
74614 new file mode 100644
74615 index 0000000..e7ffaaf
74616 --- /dev/null
74617 +++ b/include/linux/grsock.h
74618 @@ -0,0 +1,19 @@
74619 +#ifndef __GRSOCK_H
74620 +#define __GRSOCK_H
74621 +
74622 +extern void gr_attach_curr_ip(const struct sock *sk);
74623 +extern int gr_handle_sock_all(const int family, const int type,
74624 + const int protocol);
74625 +extern int gr_handle_sock_server(const struct sockaddr *sck);
74626 +extern int gr_handle_sock_server_other(const struct sock *sck);
74627 +extern int gr_handle_sock_client(const struct sockaddr *sck);
74628 +extern int gr_search_connect(struct socket * sock,
74629 + struct sockaddr_in * addr);
74630 +extern int gr_search_bind(struct socket * sock,
74631 + struct sockaddr_in * addr);
74632 +extern int gr_search_listen(struct socket * sock);
74633 +extern int gr_search_accept(struct socket * sock);
74634 +extern int gr_search_socket(const int domain, const int type,
74635 + const int protocol);
74636 +
74637 +#endif
74638 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
74639 index 7fb31da..08b5114 100644
74640 --- a/include/linux/highmem.h
74641 +++ b/include/linux/highmem.h
74642 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
74643 kunmap_atomic(kaddr);
74644 }
74645
74646 +static inline void sanitize_highpage(struct page *page)
74647 +{
74648 + void *kaddr;
74649 + unsigned long flags;
74650 +
74651 + local_irq_save(flags);
74652 + kaddr = kmap_atomic(page);
74653 + clear_page(kaddr);
74654 + kunmap_atomic(kaddr);
74655 + local_irq_restore(flags);
74656 +}
74657 +
74658 static inline void zero_user_segments(struct page *page,
74659 unsigned start1, unsigned end1,
74660 unsigned start2, unsigned end2)
74661 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
74662 index 1c7b89a..7f52502 100644
74663 --- a/include/linux/hwmon-sysfs.h
74664 +++ b/include/linux/hwmon-sysfs.h
74665 @@ -25,7 +25,8 @@
74666 struct sensor_device_attribute{
74667 struct device_attribute dev_attr;
74668 int index;
74669 -};
74670 +} __do_const;
74671 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
74672 #define to_sensor_dev_attr(_dev_attr) \
74673 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
74674
74675 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
74676 struct device_attribute dev_attr;
74677 u8 index;
74678 u8 nr;
74679 -};
74680 +} __do_const;
74681 #define to_sensor_dev_attr_2(_dev_attr) \
74682 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
74683
74684 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
74685 index e988fa9..ff9f17e 100644
74686 --- a/include/linux/i2c.h
74687 +++ b/include/linux/i2c.h
74688 @@ -366,6 +366,7 @@ struct i2c_algorithm {
74689 /* To determine what the adapter supports */
74690 u32 (*functionality) (struct i2c_adapter *);
74691 };
74692 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
74693
74694 /**
74695 * struct i2c_bus_recovery_info - I2C bus recovery information
74696 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
74697 index d23c3c2..eb63c81 100644
74698 --- a/include/linux/i2o.h
74699 +++ b/include/linux/i2o.h
74700 @@ -565,7 +565,7 @@ struct i2o_controller {
74701 struct i2o_device *exec; /* Executive */
74702 #if BITS_PER_LONG == 64
74703 spinlock_t context_list_lock; /* lock for context_list */
74704 - atomic_t context_list_counter; /* needed for unique contexts */
74705 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
74706 struct list_head context_list; /* list of context id's
74707 and pointers */
74708 #endif
74709 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
74710 index aff7ad8..3942bbd 100644
74711 --- a/include/linux/if_pppox.h
74712 +++ b/include/linux/if_pppox.h
74713 @@ -76,7 +76,7 @@ struct pppox_proto {
74714 int (*ioctl)(struct socket *sock, unsigned int cmd,
74715 unsigned long arg);
74716 struct module *owner;
74717 -};
74718 +} __do_const;
74719
74720 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
74721 extern void unregister_pppox_proto(int proto_num);
74722 diff --git a/include/linux/init.h b/include/linux/init.h
74723 index e73f2b7..cc996e0 100644
74724 --- a/include/linux/init.h
74725 +++ b/include/linux/init.h
74726 @@ -39,9 +39,17 @@
74727 * Also note, that this data cannot be "const".
74728 */
74729
74730 +#define add_init_latent_entropy __latent_entropy
74731 +
74732 +#ifdef CONFIG_MEMORY_HOTPLUG
74733 +#define add_meminit_latent_entropy
74734 +#else
74735 +#define add_meminit_latent_entropy __latent_entropy
74736 +#endif
74737 +
74738 /* These are for everybody (although not all archs will actually
74739 discard it in modules) */
74740 -#define __init __section(.init.text) __cold notrace
74741 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
74742 #define __initdata __section(.init.data)
74743 #define __initconst __constsection(.init.rodata)
74744 #define __exitdata __section(.exit.data)
74745 @@ -102,7 +110,7 @@
74746 #define __cpuexitconst
74747
74748 /* Used for MEMORY_HOTPLUG */
74749 -#define __meminit __section(.meminit.text) __cold notrace
74750 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
74751 #define __meminitdata __section(.meminit.data)
74752 #define __meminitconst __constsection(.meminit.rodata)
74753 #define __memexit __section(.memexit.text) __exitused __cold notrace
74754 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
74755 index 5cd0f09..c9f67cc 100644
74756 --- a/include/linux/init_task.h
74757 +++ b/include/linux/init_task.h
74758 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
74759
74760 #define INIT_TASK_COMM "swapper"
74761
74762 +#ifdef CONFIG_X86
74763 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
74764 +#else
74765 +#define INIT_TASK_THREAD_INFO
74766 +#endif
74767 +
74768 /*
74769 * INIT_TASK is used to set up the first task table, touch at
74770 * your own risk!. Base=0, limit=0x1fffff (=2MB)
74771 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
74772 RCU_POINTER_INITIALIZER(cred, &init_cred), \
74773 .comm = INIT_TASK_COMM, \
74774 .thread = INIT_THREAD, \
74775 + INIT_TASK_THREAD_INFO \
74776 .fs = &init_fs, \
74777 .files = &init_files, \
74778 .signal = &init_signals, \
74779 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
74780 index 5fa5afe..ac55b25 100644
74781 --- a/include/linux/interrupt.h
74782 +++ b/include/linux/interrupt.h
74783 @@ -430,7 +430,7 @@ enum
74784 /* map softirq index to softirq name. update 'softirq_to_name' in
74785 * kernel/softirq.c when adding a new softirq.
74786 */
74787 -extern char *softirq_to_name[NR_SOFTIRQS];
74788 +extern const char * const softirq_to_name[NR_SOFTIRQS];
74789
74790 /* softirq mask and active fields moved to irq_cpustat_t in
74791 * asm/hardirq.h to get better cache usage. KAO
74792 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
74793
74794 struct softirq_action
74795 {
74796 - void (*action)(struct softirq_action *);
74797 -};
74798 + void (*action)(void);
74799 +} __no_const;
74800
74801 asmlinkage void do_softirq(void);
74802 asmlinkage void __do_softirq(void);
74803 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
74804 +extern void open_softirq(int nr, void (*action)(void));
74805 extern void softirq_init(void);
74806 extern void __raise_softirq_irqoff(unsigned int nr);
74807
74808 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
74809 index 3aeb730..2177f39 100644
74810 --- a/include/linux/iommu.h
74811 +++ b/include/linux/iommu.h
74812 @@ -113,7 +113,7 @@ struct iommu_ops {
74813 u32 (*domain_get_windows)(struct iommu_domain *domain);
74814
74815 unsigned long pgsize_bitmap;
74816 -};
74817 +} __do_const;
74818
74819 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
74820 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
74821 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
74822 index 89b7c24..382af74 100644
74823 --- a/include/linux/ioport.h
74824 +++ b/include/linux/ioport.h
74825 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
74826 int adjust_resource(struct resource *res, resource_size_t start,
74827 resource_size_t size);
74828 resource_size_t resource_alignment(struct resource *res);
74829 -static inline resource_size_t resource_size(const struct resource *res)
74830 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
74831 {
74832 return res->end - res->start + 1;
74833 }
74834 diff --git a/include/linux/irq.h b/include/linux/irq.h
74835 index f04d3ba..bcf2cfb 100644
74836 --- a/include/linux/irq.h
74837 +++ b/include/linux/irq.h
74838 @@ -333,7 +333,8 @@ struct irq_chip {
74839 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
74840
74841 unsigned long flags;
74842 -};
74843 +} __do_const;
74844 +typedef struct irq_chip __no_const irq_chip_no_const;
74845
74846 /*
74847 * irq_chip specific flags
74848 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
74849 index 3e203eb..3fe68d0 100644
74850 --- a/include/linux/irqchip/arm-gic.h
74851 +++ b/include/linux/irqchip/arm-gic.h
74852 @@ -59,9 +59,11 @@
74853
74854 #ifndef __ASSEMBLY__
74855
74856 +#include <linux/irq.h>
74857 +
74858 struct device_node;
74859
74860 -extern struct irq_chip gic_arch_extn;
74861 +extern irq_chip_no_const gic_arch_extn;
74862
74863 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
74864 u32 offset, struct device_node *);
74865 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
74866 index 6883e19..e854fcb 100644
74867 --- a/include/linux/kallsyms.h
74868 +++ b/include/linux/kallsyms.h
74869 @@ -15,7 +15,8 @@
74870
74871 struct module;
74872
74873 -#ifdef CONFIG_KALLSYMS
74874 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
74875 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
74876 /* Lookup the address for a symbol. Returns 0 if not found. */
74877 unsigned long kallsyms_lookup_name(const char *name);
74878
74879 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
74880 /* Stupid that this does nothing, but I didn't create this mess. */
74881 #define __print_symbol(fmt, addr)
74882 #endif /*CONFIG_KALLSYMS*/
74883 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
74884 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
74885 +extern unsigned long kallsyms_lookup_name(const char *name);
74886 +extern void __print_symbol(const char *fmt, unsigned long address);
74887 +extern int sprint_backtrace(char *buffer, unsigned long address);
74888 +extern int sprint_symbol(char *buffer, unsigned long address);
74889 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
74890 +const char *kallsyms_lookup(unsigned long addr,
74891 + unsigned long *symbolsize,
74892 + unsigned long *offset,
74893 + char **modname, char *namebuf);
74894 +extern int kallsyms_lookup_size_offset(unsigned long addr,
74895 + unsigned long *symbolsize,
74896 + unsigned long *offset);
74897 +#endif
74898
74899 /* This macro allows us to keep printk typechecking */
74900 static __printf(1, 2)
74901 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
74902 index 518a53a..5e28358 100644
74903 --- a/include/linux/key-type.h
74904 +++ b/include/linux/key-type.h
74905 @@ -125,7 +125,7 @@ struct key_type {
74906 /* internal fields */
74907 struct list_head link; /* link in types list */
74908 struct lock_class_key lock_class; /* key->sem lock class */
74909 -};
74910 +} __do_const;
74911
74912 extern struct key_type key_type_keyring;
74913
74914 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
74915 index c6e091b..a940adf 100644
74916 --- a/include/linux/kgdb.h
74917 +++ b/include/linux/kgdb.h
74918 @@ -52,7 +52,7 @@ extern int kgdb_connected;
74919 extern int kgdb_io_module_registered;
74920
74921 extern atomic_t kgdb_setting_breakpoint;
74922 -extern atomic_t kgdb_cpu_doing_single_step;
74923 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
74924
74925 extern struct task_struct *kgdb_usethread;
74926 extern struct task_struct *kgdb_contthread;
74927 @@ -254,7 +254,7 @@ struct kgdb_arch {
74928 void (*correct_hw_break)(void);
74929
74930 void (*enable_nmi)(bool on);
74931 -};
74932 +} __do_const;
74933
74934 /**
74935 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
74936 @@ -279,7 +279,7 @@ struct kgdb_io {
74937 void (*pre_exception) (void);
74938 void (*post_exception) (void);
74939 int is_console;
74940 -};
74941 +} __do_const;
74942
74943 extern struct kgdb_arch arch_kgdb_ops;
74944
74945 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
74946 index 0555cc6..b16a7a4 100644
74947 --- a/include/linux/kmod.h
74948 +++ b/include/linux/kmod.h
74949 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
74950 * usually useless though. */
74951 extern __printf(2, 3)
74952 int __request_module(bool wait, const char *name, ...);
74953 +extern __printf(3, 4)
74954 +int ___request_module(bool wait, char *param_name, const char *name, ...);
74955 #define request_module(mod...) __request_module(true, mod)
74956 #define request_module_nowait(mod...) __request_module(false, mod)
74957 #define try_then_request_module(x, mod...) \
74958 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
74959 index 939b112..ed6ed51 100644
74960 --- a/include/linux/kobject.h
74961 +++ b/include/linux/kobject.h
74962 @@ -111,7 +111,7 @@ struct kobj_type {
74963 struct attribute **default_attrs;
74964 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
74965 const void *(*namespace)(struct kobject *kobj);
74966 -};
74967 +} __do_const;
74968
74969 struct kobj_uevent_env {
74970 char *envp[UEVENT_NUM_ENVP];
74971 @@ -134,6 +134,7 @@ struct kobj_attribute {
74972 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
74973 const char *buf, size_t count);
74974 };
74975 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
74976
74977 extern const struct sysfs_ops kobj_sysfs_ops;
74978
74979 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
74980 index f66b065..c2c29b4 100644
74981 --- a/include/linux/kobject_ns.h
74982 +++ b/include/linux/kobject_ns.h
74983 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
74984 const void *(*netlink_ns)(struct sock *sk);
74985 const void *(*initial_ns)(void);
74986 void (*drop_ns)(void *);
74987 -};
74988 +} __do_const;
74989
74990 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
74991 int kobj_ns_type_registered(enum kobj_ns_type type);
74992 diff --git a/include/linux/kref.h b/include/linux/kref.h
74993 index 484604d..0f6c5b6 100644
74994 --- a/include/linux/kref.h
74995 +++ b/include/linux/kref.h
74996 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
74997 static inline int kref_sub(struct kref *kref, unsigned int count,
74998 void (*release)(struct kref *kref))
74999 {
75000 - WARN_ON(release == NULL);
75001 + BUG_ON(release == NULL);
75002
75003 if (atomic_sub_and_test((int) count, &kref->refcount)) {
75004 release(kref);
75005 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
75006 index a63d83e..77fd685 100644
75007 --- a/include/linux/kvm_host.h
75008 +++ b/include/linux/kvm_host.h
75009 @@ -446,7 +446,7 @@ static inline void kvm_irqfd_exit(void)
75010 {
75011 }
75012 #endif
75013 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75014 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
75015 struct module *module);
75016 void kvm_exit(void);
75017
75018 @@ -618,7 +618,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
75019 struct kvm_guest_debug *dbg);
75020 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
75021
75022 -int kvm_arch_init(void *opaque);
75023 +int kvm_arch_init(const void *opaque);
75024 void kvm_arch_exit(void);
75025
75026 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
75027 diff --git a/include/linux/libata.h b/include/linux/libata.h
75028 index 4ea55bb..dcd2601 100644
75029 --- a/include/linux/libata.h
75030 +++ b/include/linux/libata.h
75031 @@ -924,7 +924,7 @@ struct ata_port_operations {
75032 * fields must be pointers.
75033 */
75034 const struct ata_port_operations *inherits;
75035 -};
75036 +} __do_const;
75037
75038 struct ata_port_info {
75039 unsigned long flags;
75040 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
75041 index d3e8ad2..a949f68 100644
75042 --- a/include/linux/linkage.h
75043 +++ b/include/linux/linkage.h
75044 @@ -31,6 +31,7 @@
75045 #endif
75046
75047 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
75048 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
75049 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
75050
75051 /*
75052 diff --git a/include/linux/list.h b/include/linux/list.h
75053 index f4d8a2f..38e6e46 100644
75054 --- a/include/linux/list.h
75055 +++ b/include/linux/list.h
75056 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
75057 extern void list_del(struct list_head *entry);
75058 #endif
75059
75060 +extern void __pax_list_add(struct list_head *new,
75061 + struct list_head *prev,
75062 + struct list_head *next);
75063 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
75064 +{
75065 + __pax_list_add(new, head, head->next);
75066 +}
75067 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
75068 +{
75069 + __pax_list_add(new, head->prev, head);
75070 +}
75071 +extern void pax_list_del(struct list_head *entry);
75072 +
75073 /**
75074 * list_replace - replace old entry by new one
75075 * @old : the element to be replaced
75076 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
75077 INIT_LIST_HEAD(entry);
75078 }
75079
75080 +extern void pax_list_del_init(struct list_head *entry);
75081 +
75082 /**
75083 * list_move - delete from one list and add as another's head
75084 * @list: the entry to move
75085 diff --git a/include/linux/math64.h b/include/linux/math64.h
75086 index 2913b86..8dcbb1e 100644
75087 --- a/include/linux/math64.h
75088 +++ b/include/linux/math64.h
75089 @@ -15,7 +15,7 @@
75090 * This is commonly provided by 32bit archs to provide an optimized 64bit
75091 * divide.
75092 */
75093 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75094 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75095 {
75096 *remainder = dividend % divisor;
75097 return dividend / divisor;
75098 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
75099 /**
75100 * div64_u64 - unsigned 64bit divide with 64bit divisor
75101 */
75102 -static inline u64 div64_u64(u64 dividend, u64 divisor)
75103 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
75104 {
75105 return dividend / divisor;
75106 }
75107 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
75108 #define div64_ul(x, y) div_u64((x), (y))
75109
75110 #ifndef div_u64_rem
75111 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75112 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
75113 {
75114 *remainder = do_div(dividend, divisor);
75115 return dividend;
75116 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
75117 * divide.
75118 */
75119 #ifndef div_u64
75120 -static inline u64 div_u64(u64 dividend, u32 divisor)
75121 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
75122 {
75123 u32 remainder;
75124 return div_u64_rem(dividend, divisor, &remainder);
75125 diff --git a/include/linux/mm.h b/include/linux/mm.h
75126 index f022460..6ecf4f9 100644
75127 --- a/include/linux/mm.h
75128 +++ b/include/linux/mm.h
75129 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
75130 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
75131 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
75132 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
75133 +
75134 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
75135 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
75136 +#endif
75137 +
75138 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
75139
75140 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
75141 @@ -208,8 +213,8 @@ struct vm_operations_struct {
75142 /* called by access_process_vm when get_user_pages() fails, typically
75143 * for use by special VMAs that can switch between memory and hardware
75144 */
75145 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
75146 - void *buf, int len, int write);
75147 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
75148 + void *buf, size_t len, int write);
75149 #ifdef CONFIG_NUMA
75150 /*
75151 * set_policy() op must add a reference to any non-NULL @new mempolicy
75152 @@ -239,6 +244,7 @@ struct vm_operations_struct {
75153 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
75154 unsigned long size, pgoff_t pgoff);
75155 };
75156 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
75157
75158 struct mmu_gather;
75159 struct inode;
75160 @@ -983,8 +989,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
75161 unsigned long *pfn);
75162 int follow_phys(struct vm_area_struct *vma, unsigned long address,
75163 unsigned int flags, unsigned long *prot, resource_size_t *phys);
75164 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75165 - void *buf, int len, int write);
75166 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
75167 + void *buf, size_t len, int write);
75168
75169 static inline void unmap_shared_mapping_range(struct address_space *mapping,
75170 loff_t const holebegin, loff_t const holelen)
75171 @@ -1023,9 +1029,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
75172 }
75173 #endif
75174
75175 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
75176 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
75177 - void *buf, int len, int write);
75178 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
75179 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
75180 + void *buf, size_t len, int write);
75181
75182 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
75183 unsigned long start, unsigned long nr_pages,
75184 @@ -1057,34 +1063,6 @@ int set_page_dirty(struct page *page);
75185 int set_page_dirty_lock(struct page *page);
75186 int clear_page_dirty_for_io(struct page *page);
75187
75188 -/* Is the vma a continuation of the stack vma above it? */
75189 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
75190 -{
75191 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
75192 -}
75193 -
75194 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
75195 - unsigned long addr)
75196 -{
75197 - return (vma->vm_flags & VM_GROWSDOWN) &&
75198 - (vma->vm_start == addr) &&
75199 - !vma_growsdown(vma->vm_prev, addr);
75200 -}
75201 -
75202 -/* Is the vma a continuation of the stack vma below it? */
75203 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
75204 -{
75205 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
75206 -}
75207 -
75208 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
75209 - unsigned long addr)
75210 -{
75211 - return (vma->vm_flags & VM_GROWSUP) &&
75212 - (vma->vm_end == addr) &&
75213 - !vma_growsup(vma->vm_next, addr);
75214 -}
75215 -
75216 extern pid_t
75217 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
75218
75219 @@ -1184,6 +1162,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
75220 }
75221 #endif
75222
75223 +#ifdef CONFIG_MMU
75224 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
75225 +#else
75226 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
75227 +{
75228 + return __pgprot(0);
75229 +}
75230 +#endif
75231 +
75232 int vma_wants_writenotify(struct vm_area_struct *vma);
75233
75234 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
75235 @@ -1202,8 +1189,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
75236 {
75237 return 0;
75238 }
75239 +
75240 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
75241 + unsigned long address)
75242 +{
75243 + return 0;
75244 +}
75245 #else
75246 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75247 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
75248 #endif
75249
75250 #ifdef __PAGETABLE_PMD_FOLDED
75251 @@ -1212,8 +1206,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
75252 {
75253 return 0;
75254 }
75255 +
75256 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
75257 + unsigned long address)
75258 +{
75259 + return 0;
75260 +}
75261 #else
75262 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
75263 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
75264 #endif
75265
75266 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
75267 @@ -1231,11 +1232,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
75268 NULL: pud_offset(pgd, address);
75269 }
75270
75271 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
75272 +{
75273 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
75274 + NULL: pud_offset(pgd, address);
75275 +}
75276 +
75277 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
75278 {
75279 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
75280 NULL: pmd_offset(pud, address);
75281 }
75282 +
75283 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
75284 +{
75285 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
75286 + NULL: pmd_offset(pud, address);
75287 +}
75288 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
75289
75290 #if USE_SPLIT_PTLOCKS
75291 @@ -1531,6 +1544,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
75292 unsigned long len, unsigned long prot, unsigned long flags,
75293 unsigned long pgoff, unsigned long *populate);
75294 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
75295 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
75296
75297 #ifdef CONFIG_MMU
75298 extern int __mm_populate(unsigned long addr, unsigned long len,
75299 @@ -1559,10 +1573,11 @@ struct vm_unmapped_area_info {
75300 unsigned long high_limit;
75301 unsigned long align_mask;
75302 unsigned long align_offset;
75303 + unsigned long threadstack_offset;
75304 };
75305
75306 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
75307 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75308 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
75309 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
75310
75311 /*
75312 * Search for an unmapped address range.
75313 @@ -1574,7 +1589,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
75314 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
75315 */
75316 static inline unsigned long
75317 -vm_unmapped_area(struct vm_unmapped_area_info *info)
75318 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
75319 {
75320 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
75321 return unmapped_area(info);
75322 @@ -1637,6 +1652,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
75323 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
75324 struct vm_area_struct **pprev);
75325
75326 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
75327 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
75328 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
75329 +
75330 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
75331 NULL if none. Assume start_addr < end_addr. */
75332 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
75333 @@ -1665,15 +1684,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
75334 return vma;
75335 }
75336
75337 -#ifdef CONFIG_MMU
75338 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
75339 -#else
75340 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
75341 -{
75342 - return __pgprot(0);
75343 -}
75344 -#endif
75345 -
75346 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
75347 unsigned long change_prot_numa(struct vm_area_struct *vma,
75348 unsigned long start, unsigned long end);
75349 @@ -1725,6 +1735,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
75350 static inline void vm_stat_account(struct mm_struct *mm,
75351 unsigned long flags, struct file *file, long pages)
75352 {
75353 +
75354 +#ifdef CONFIG_PAX_RANDMMAP
75355 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
75356 +#endif
75357 +
75358 mm->total_vm += pages;
75359 }
75360 #endif /* CONFIG_PROC_FS */
75361 @@ -1805,7 +1820,7 @@ extern int unpoison_memory(unsigned long pfn);
75362 extern int sysctl_memory_failure_early_kill;
75363 extern int sysctl_memory_failure_recovery;
75364 extern void shake_page(struct page *p, int access);
75365 -extern atomic_long_t num_poisoned_pages;
75366 +extern atomic_long_unchecked_t num_poisoned_pages;
75367 extern int soft_offline_page(struct page *page, int flags);
75368
75369 extern void dump_page(struct page *page);
75370 @@ -1842,5 +1857,11 @@ void __init setup_nr_node_ids(void);
75371 static inline void setup_nr_node_ids(void) {}
75372 #endif
75373
75374 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
75375 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
75376 +#else
75377 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
75378 +#endif
75379 +
75380 #endif /* __KERNEL__ */
75381 #endif /* _LINUX_MM_H */
75382 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
75383 index faf4b7c..1e70c6e 100644
75384 --- a/include/linux/mm_types.h
75385 +++ b/include/linux/mm_types.h
75386 @@ -289,6 +289,8 @@ struct vm_area_struct {
75387 #ifdef CONFIG_NUMA
75388 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
75389 #endif
75390 +
75391 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
75392 };
75393
75394 struct core_thread {
75395 @@ -435,6 +437,24 @@ struct mm_struct {
75396 int first_nid;
75397 #endif
75398 struct uprobes_state uprobes_state;
75399 +
75400 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
75401 + unsigned long pax_flags;
75402 +#endif
75403 +
75404 +#ifdef CONFIG_PAX_DLRESOLVE
75405 + unsigned long call_dl_resolve;
75406 +#endif
75407 +
75408 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
75409 + unsigned long call_syscall;
75410 +#endif
75411 +
75412 +#ifdef CONFIG_PAX_ASLR
75413 + unsigned long delta_mmap; /* randomized offset */
75414 + unsigned long delta_stack; /* randomized offset */
75415 +#endif
75416 +
75417 };
75418
75419 /* first nid will either be a valid NID or one of these values */
75420 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
75421 index c5d5278..f0b68c8 100644
75422 --- a/include/linux/mmiotrace.h
75423 +++ b/include/linux/mmiotrace.h
75424 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
75425 /* Called from ioremap.c */
75426 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
75427 void __iomem *addr);
75428 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
75429 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
75430
75431 /* For anyone to insert markers. Remember trailing newline. */
75432 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
75433 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
75434 {
75435 }
75436
75437 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
75438 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
75439 {
75440 }
75441
75442 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
75443 index af4a3b7..9ad8889 100644
75444 --- a/include/linux/mmzone.h
75445 +++ b/include/linux/mmzone.h
75446 @@ -396,7 +396,7 @@ struct zone {
75447 unsigned long flags; /* zone flags, see below */
75448
75449 /* Zone statistics */
75450 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75451 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75452
75453 /*
75454 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
75455 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
75456 index 45e9214..a7227d6 100644
75457 --- a/include/linux/mod_devicetable.h
75458 +++ b/include/linux/mod_devicetable.h
75459 @@ -13,7 +13,7 @@
75460 typedef unsigned long kernel_ulong_t;
75461 #endif
75462
75463 -#define PCI_ANY_ID (~0)
75464 +#define PCI_ANY_ID ((__u16)~0)
75465
75466 struct pci_device_id {
75467 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
75468 @@ -139,7 +139,7 @@ struct usb_device_id {
75469 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
75470 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
75471
75472 -#define HID_ANY_ID (~0)
75473 +#define HID_ANY_ID (~0U)
75474 #define HID_BUS_ANY 0xffff
75475 #define HID_GROUP_ANY 0x0000
75476
75477 @@ -467,7 +467,7 @@ struct dmi_system_id {
75478 const char *ident;
75479 struct dmi_strmatch matches[4];
75480 void *driver_data;
75481 -};
75482 +} __do_const;
75483 /*
75484 * struct dmi_device_id appears during expansion of
75485 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
75486 diff --git a/include/linux/module.h b/include/linux/module.h
75487 index 46f1ea0..a34ca37 100644
75488 --- a/include/linux/module.h
75489 +++ b/include/linux/module.h
75490 @@ -17,9 +17,11 @@
75491 #include <linux/moduleparam.h>
75492 #include <linux/tracepoint.h>
75493 #include <linux/export.h>
75494 +#include <linux/fs.h>
75495
75496 #include <linux/percpu.h>
75497 #include <asm/module.h>
75498 +#include <asm/pgtable.h>
75499
75500 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
75501 #define MODULE_SIG_STRING "~Module signature appended~\n"
75502 @@ -54,12 +56,13 @@ struct module_attribute {
75503 int (*test)(struct module *);
75504 void (*free)(struct module *);
75505 };
75506 +typedef struct module_attribute __no_const module_attribute_no_const;
75507
75508 struct module_version_attribute {
75509 struct module_attribute mattr;
75510 const char *module_name;
75511 const char *version;
75512 -} __attribute__ ((__aligned__(sizeof(void *))));
75513 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
75514
75515 extern ssize_t __modver_version_show(struct module_attribute *,
75516 struct module_kobject *, char *);
75517 @@ -232,7 +235,7 @@ struct module
75518
75519 /* Sysfs stuff. */
75520 struct module_kobject mkobj;
75521 - struct module_attribute *modinfo_attrs;
75522 + module_attribute_no_const *modinfo_attrs;
75523 const char *version;
75524 const char *srcversion;
75525 struct kobject *holders_dir;
75526 @@ -281,19 +284,16 @@ struct module
75527 int (*init)(void);
75528
75529 /* If this is non-NULL, vfree after init() returns */
75530 - void *module_init;
75531 + void *module_init_rx, *module_init_rw;
75532
75533 /* Here is the actual code + data, vfree'd on unload. */
75534 - void *module_core;
75535 + void *module_core_rx, *module_core_rw;
75536
75537 /* Here are the sizes of the init and core sections */
75538 - unsigned int init_size, core_size;
75539 + unsigned int init_size_rw, core_size_rw;
75540
75541 /* The size of the executable code in each section. */
75542 - unsigned int init_text_size, core_text_size;
75543 -
75544 - /* Size of RO sections of the module (text+rodata) */
75545 - unsigned int init_ro_size, core_ro_size;
75546 + unsigned int init_size_rx, core_size_rx;
75547
75548 /* Arch-specific module values */
75549 struct mod_arch_specific arch;
75550 @@ -349,6 +349,10 @@ struct module
75551 #ifdef CONFIG_EVENT_TRACING
75552 struct ftrace_event_call **trace_events;
75553 unsigned int num_trace_events;
75554 + struct file_operations trace_id;
75555 + struct file_operations trace_enable;
75556 + struct file_operations trace_format;
75557 + struct file_operations trace_filter;
75558 #endif
75559 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
75560 unsigned int num_ftrace_callsites;
75561 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
75562 bool is_module_percpu_address(unsigned long addr);
75563 bool is_module_text_address(unsigned long addr);
75564
75565 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
75566 +{
75567 +
75568 +#ifdef CONFIG_PAX_KERNEXEC
75569 + if (ktla_ktva(addr) >= (unsigned long)start &&
75570 + ktla_ktva(addr) < (unsigned long)start + size)
75571 + return 1;
75572 +#endif
75573 +
75574 + return ((void *)addr >= start && (void *)addr < start + size);
75575 +}
75576 +
75577 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
75578 +{
75579 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
75580 +}
75581 +
75582 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
75583 +{
75584 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
75585 +}
75586 +
75587 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
75588 +{
75589 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
75590 +}
75591 +
75592 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
75593 +{
75594 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
75595 +}
75596 +
75597 static inline int within_module_core(unsigned long addr, const struct module *mod)
75598 {
75599 - return (unsigned long)mod->module_core <= addr &&
75600 - addr < (unsigned long)mod->module_core + mod->core_size;
75601 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
75602 }
75603
75604 static inline int within_module_init(unsigned long addr, const struct module *mod)
75605 {
75606 - return (unsigned long)mod->module_init <= addr &&
75607 - addr < (unsigned long)mod->module_init + mod->init_size;
75608 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
75609 }
75610
75611 /* Search for module by name: must hold module_mutex. */
75612 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
75613 index 560ca53..ef621ef 100644
75614 --- a/include/linux/moduleloader.h
75615 +++ b/include/linux/moduleloader.h
75616 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
75617 sections. Returns NULL on failure. */
75618 void *module_alloc(unsigned long size);
75619
75620 +#ifdef CONFIG_PAX_KERNEXEC
75621 +void *module_alloc_exec(unsigned long size);
75622 +#else
75623 +#define module_alloc_exec(x) module_alloc(x)
75624 +#endif
75625 +
75626 /* Free memory returned from module_alloc. */
75627 void module_free(struct module *mod, void *module_region);
75628
75629 +#ifdef CONFIG_PAX_KERNEXEC
75630 +void module_free_exec(struct module *mod, void *module_region);
75631 +#else
75632 +#define module_free_exec(x, y) module_free((x), (y))
75633 +#endif
75634 +
75635 /*
75636 * Apply the given relocation to the (simplified) ELF. Return -error
75637 * or 0.
75638 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
75639 unsigned int relsec,
75640 struct module *me)
75641 {
75642 +#ifdef CONFIG_MODULES
75643 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75644 +#endif
75645 return -ENOEXEC;
75646 }
75647 #endif
75648 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
75649 unsigned int relsec,
75650 struct module *me)
75651 {
75652 +#ifdef CONFIG_MODULES
75653 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
75654 +#endif
75655 return -ENOEXEC;
75656 }
75657 #endif
75658 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
75659 index 27d9da3..5d94aa3 100644
75660 --- a/include/linux/moduleparam.h
75661 +++ b/include/linux/moduleparam.h
75662 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
75663 * @len is usually just sizeof(string).
75664 */
75665 #define module_param_string(name, string, len, perm) \
75666 - static const struct kparam_string __param_string_##name \
75667 + static const struct kparam_string __param_string_##name __used \
75668 = { len, string }; \
75669 __module_param_call(MODULE_PARAM_PREFIX, name, \
75670 &param_ops_string, \
75671 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
75672 */
75673 #define module_param_array_named(name, array, type, nump, perm) \
75674 param_check_##type(name, &(array)[0]); \
75675 - static const struct kparam_array __param_arr_##name \
75676 + static const struct kparam_array __param_arr_##name __used \
75677 = { .max = ARRAY_SIZE(array), .num = nump, \
75678 .ops = &param_ops_##type, \
75679 .elemsize = sizeof(array[0]), .elem = array }; \
75680 diff --git a/include/linux/namei.h b/include/linux/namei.h
75681 index 5a5ff57..5ae5070 100644
75682 --- a/include/linux/namei.h
75683 +++ b/include/linux/namei.h
75684 @@ -19,7 +19,7 @@ struct nameidata {
75685 unsigned seq;
75686 int last_type;
75687 unsigned depth;
75688 - char *saved_names[MAX_NESTED_LINKS + 1];
75689 + const char *saved_names[MAX_NESTED_LINKS + 1];
75690 };
75691
75692 /*
75693 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
75694
75695 extern void nd_jump_link(struct nameidata *nd, struct path *path);
75696
75697 -static inline void nd_set_link(struct nameidata *nd, char *path)
75698 +static inline void nd_set_link(struct nameidata *nd, const char *path)
75699 {
75700 nd->saved_names[nd->depth] = path;
75701 }
75702
75703 -static inline char *nd_get_link(struct nameidata *nd)
75704 +static inline const char *nd_get_link(const struct nameidata *nd)
75705 {
75706 return nd->saved_names[nd->depth];
75707 }
75708 diff --git a/include/linux/net.h b/include/linux/net.h
75709 index 4f27575..fc8a65f 100644
75710 --- a/include/linux/net.h
75711 +++ b/include/linux/net.h
75712 @@ -183,7 +183,7 @@ struct net_proto_family {
75713 int (*create)(struct net *net, struct socket *sock,
75714 int protocol, int kern);
75715 struct module *owner;
75716 -};
75717 +} __do_const;
75718
75719 struct iovec;
75720 struct kvec;
75721 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
75722 index 9a41568..203d903 100644
75723 --- a/include/linux/netdevice.h
75724 +++ b/include/linux/netdevice.h
75725 @@ -1061,6 +1061,7 @@ struct net_device_ops {
75726 int (*ndo_change_carrier)(struct net_device *dev,
75727 bool new_carrier);
75728 };
75729 +typedef struct net_device_ops __no_const net_device_ops_no_const;
75730
75731 /*
75732 * The DEVICE structure.
75733 @@ -1131,7 +1132,7 @@ struct net_device {
75734 int iflink;
75735
75736 struct net_device_stats stats;
75737 - atomic_long_t rx_dropped; /* dropped packets by core network
75738 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
75739 * Do not use this in drivers.
75740 */
75741
75742 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
75743 index de70f7b..2675e91 100644
75744 --- a/include/linux/netfilter.h
75745 +++ b/include/linux/netfilter.h
75746 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
75747 #endif
75748 /* Use the module struct to lock set/get code in place */
75749 struct module *owner;
75750 -};
75751 +} __do_const;
75752
75753 /* Function to register/unregister hook points. */
75754 int nf_register_hook(struct nf_hook_ops *reg);
75755 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
75756 index d80e275..c3510b8 100644
75757 --- a/include/linux/netfilter/ipset/ip_set.h
75758 +++ b/include/linux/netfilter/ipset/ip_set.h
75759 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
75760 /* Return true if "b" set is the same as "a"
75761 * according to the create set parameters */
75762 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
75763 -};
75764 +} __do_const;
75765
75766 /* The core set type structure */
75767 struct ip_set_type {
75768 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
75769 index cadb740..d7c37c0 100644
75770 --- a/include/linux/netfilter/nfnetlink.h
75771 +++ b/include/linux/netfilter/nfnetlink.h
75772 @@ -16,7 +16,7 @@ struct nfnl_callback {
75773 const struct nlattr * const cda[]);
75774 const struct nla_policy *policy; /* netlink attribute policy */
75775 const u_int16_t attr_count; /* number of nlattr's */
75776 -};
75777 +} __do_const;
75778
75779 struct nfnetlink_subsystem {
75780 const char *name;
75781 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
75782 new file mode 100644
75783 index 0000000..33f4af8
75784 --- /dev/null
75785 +++ b/include/linux/netfilter/xt_gradm.h
75786 @@ -0,0 +1,9 @@
75787 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
75788 +#define _LINUX_NETFILTER_XT_GRADM_H 1
75789 +
75790 +struct xt_gradm_mtinfo {
75791 + __u16 flags;
75792 + __u16 invflags;
75793 +};
75794 +
75795 +#endif
75796 diff --git a/include/linux/nls.h b/include/linux/nls.h
75797 index 5dc635f..35f5e11 100644
75798 --- a/include/linux/nls.h
75799 +++ b/include/linux/nls.h
75800 @@ -31,7 +31,7 @@ struct nls_table {
75801 const unsigned char *charset2upper;
75802 struct module *owner;
75803 struct nls_table *next;
75804 -};
75805 +} __do_const;
75806
75807 /* this value hold the maximum octet of charset */
75808 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
75809 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
75810 index d14a4c3..a078786 100644
75811 --- a/include/linux/notifier.h
75812 +++ b/include/linux/notifier.h
75813 @@ -54,7 +54,8 @@ struct notifier_block {
75814 notifier_fn_t notifier_call;
75815 struct notifier_block __rcu *next;
75816 int priority;
75817 -};
75818 +} __do_const;
75819 +typedef struct notifier_block __no_const notifier_block_no_const;
75820
75821 struct atomic_notifier_head {
75822 spinlock_t lock;
75823 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
75824 index a4c5624..79d6d88 100644
75825 --- a/include/linux/oprofile.h
75826 +++ b/include/linux/oprofile.h
75827 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
75828 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
75829 char const * name, ulong * val);
75830
75831 -/** Create a file for read-only access to an atomic_t. */
75832 +/** Create a file for read-only access to an atomic_unchecked_t. */
75833 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
75834 - char const * name, atomic_t * val);
75835 + char const * name, atomic_unchecked_t * val);
75836
75837 /** create a directory */
75838 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
75839 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
75840 index 8db71dc..a76bf2c 100644
75841 --- a/include/linux/pci_hotplug.h
75842 +++ b/include/linux/pci_hotplug.h
75843 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
75844 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
75845 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
75846 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
75847 -};
75848 +} __do_const;
75849 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
75850
75851 /**
75852 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
75853 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
75854 index c43f6ea..2d4416f 100644
75855 --- a/include/linux/perf_event.h
75856 +++ b/include/linux/perf_event.h
75857 @@ -328,8 +328,8 @@ struct perf_event {
75858
75859 enum perf_event_active_state state;
75860 unsigned int attach_state;
75861 - local64_t count;
75862 - atomic64_t child_count;
75863 + local64_t count; /* PaX: fix it one day */
75864 + atomic64_unchecked_t child_count;
75865
75866 /*
75867 * These are the total time in nanoseconds that the event
75868 @@ -380,8 +380,8 @@ struct perf_event {
75869 * These accumulate total time (in nanoseconds) that children
75870 * events have been enabled and running, respectively.
75871 */
75872 - atomic64_t child_total_time_enabled;
75873 - atomic64_t child_total_time_running;
75874 + atomic64_unchecked_t child_total_time_enabled;
75875 + atomic64_unchecked_t child_total_time_running;
75876
75877 /*
75878 * Protect attach/detach and child_list:
75879 @@ -703,7 +703,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
75880 entry->ip[entry->nr++] = ip;
75881 }
75882
75883 -extern int sysctl_perf_event_paranoid;
75884 +extern int sysctl_perf_event_legitimately_concerned;
75885 extern int sysctl_perf_event_mlock;
75886 extern int sysctl_perf_event_sample_rate;
75887 extern int sysctl_perf_cpu_time_max_percent;
75888 @@ -718,19 +718,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
75889 loff_t *ppos);
75890
75891
75892 +static inline bool perf_paranoid_any(void)
75893 +{
75894 + return sysctl_perf_event_legitimately_concerned > 2;
75895 +}
75896 +
75897 static inline bool perf_paranoid_tracepoint_raw(void)
75898 {
75899 - return sysctl_perf_event_paranoid > -1;
75900 + return sysctl_perf_event_legitimately_concerned > -1;
75901 }
75902
75903 static inline bool perf_paranoid_cpu(void)
75904 {
75905 - return sysctl_perf_event_paranoid > 0;
75906 + return sysctl_perf_event_legitimately_concerned > 0;
75907 }
75908
75909 static inline bool perf_paranoid_kernel(void)
75910 {
75911 - return sysctl_perf_event_paranoid > 1;
75912 + return sysctl_perf_event_legitimately_concerned > 1;
75913 }
75914
75915 extern void perf_event_init(void);
75916 @@ -846,7 +851,7 @@ struct perf_pmu_events_attr {
75917 struct device_attribute attr;
75918 u64 id;
75919 const char *event_str;
75920 -};
75921 +} __do_const;
75922
75923 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
75924 static struct perf_pmu_events_attr _var = { \
75925 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
75926 index b8809fe..ae4ccd0 100644
75927 --- a/include/linux/pipe_fs_i.h
75928 +++ b/include/linux/pipe_fs_i.h
75929 @@ -47,10 +47,10 @@ struct pipe_inode_info {
75930 struct mutex mutex;
75931 wait_queue_head_t wait;
75932 unsigned int nrbufs, curbuf, buffers;
75933 - unsigned int readers;
75934 - unsigned int writers;
75935 - unsigned int files;
75936 - unsigned int waiting_writers;
75937 + atomic_t readers;
75938 + atomic_t writers;
75939 + atomic_t files;
75940 + atomic_t waiting_writers;
75941 unsigned int r_counter;
75942 unsigned int w_counter;
75943 struct page *tmp_page;
75944 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
75945 index 5f28cae..3d23723 100644
75946 --- a/include/linux/platform_data/usb-ehci-s5p.h
75947 +++ b/include/linux/platform_data/usb-ehci-s5p.h
75948 @@ -14,7 +14,7 @@
75949 struct s5p_ehci_platdata {
75950 int (*phy_init)(struct platform_device *pdev, int type);
75951 int (*phy_exit)(struct platform_device *pdev, int type);
75952 -};
75953 +} __no_const;
75954
75955 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
75956
75957 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
75958 index c256c59..8ea94c7 100644
75959 --- a/include/linux/platform_data/usb-ohci-exynos.h
75960 +++ b/include/linux/platform_data/usb-ohci-exynos.h
75961 @@ -14,7 +14,7 @@
75962 struct exynos4_ohci_platdata {
75963 int (*phy_init)(struct platform_device *pdev, int type);
75964 int (*phy_exit)(struct platform_device *pdev, int type);
75965 -};
75966 +} __no_const;
75967
75968 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
75969
75970 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
75971 index 7c1d252..c5c773e 100644
75972 --- a/include/linux/pm_domain.h
75973 +++ b/include/linux/pm_domain.h
75974 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
75975
75976 struct gpd_cpu_data {
75977 unsigned int saved_exit_latency;
75978 - struct cpuidle_state *idle_state;
75979 + cpuidle_state_no_const *idle_state;
75980 };
75981
75982 struct generic_pm_domain {
75983 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
75984 index 6fa7cea..7bf6415 100644
75985 --- a/include/linux/pm_runtime.h
75986 +++ b/include/linux/pm_runtime.h
75987 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
75988
75989 static inline void pm_runtime_mark_last_busy(struct device *dev)
75990 {
75991 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
75992 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
75993 }
75994
75995 #else /* !CONFIG_PM_RUNTIME */
75996 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
75997 index 195aafc..49a7bc2 100644
75998 --- a/include/linux/pnp.h
75999 +++ b/include/linux/pnp.h
76000 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
76001 struct pnp_fixup {
76002 char id[7];
76003 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
76004 -};
76005 +} __do_const;
76006
76007 /* config parameters */
76008 #define PNP_CONFIG_NORMAL 0x0001
76009 diff --git a/include/linux/poison.h b/include/linux/poison.h
76010 index 2110a81..13a11bb 100644
76011 --- a/include/linux/poison.h
76012 +++ b/include/linux/poison.h
76013 @@ -19,8 +19,8 @@
76014 * under normal circumstances, used to verify that nobody uses
76015 * non-initialized list entries.
76016 */
76017 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
76018 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
76019 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
76020 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
76021
76022 /********** include/linux/timer.h **********/
76023 /*
76024 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
76025 index d8b187c3..9a9257a 100644
76026 --- a/include/linux/power/smartreflex.h
76027 +++ b/include/linux/power/smartreflex.h
76028 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
76029 int (*notify)(struct omap_sr *sr, u32 status);
76030 u8 notify_flags;
76031 u8 class_type;
76032 -};
76033 +} __do_const;
76034
76035 /**
76036 * struct omap_sr_nvalue_table - Smartreflex n-target value info
76037 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
76038 index 4ea1d37..80f4b33 100644
76039 --- a/include/linux/ppp-comp.h
76040 +++ b/include/linux/ppp-comp.h
76041 @@ -84,7 +84,7 @@ struct compressor {
76042 struct module *owner;
76043 /* Extra skb space needed by the compressor algorithm */
76044 unsigned int comp_extra;
76045 -};
76046 +} __do_const;
76047
76048 /*
76049 * The return value from decompress routine is the length of the
76050 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
76051 index f5d4723..a6ea2fa 100644
76052 --- a/include/linux/preempt.h
76053 +++ b/include/linux/preempt.h
76054 @@ -18,8 +18,13 @@
76055 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76056 #endif
76057
76058 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
76059 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
76060 +
76061 #define inc_preempt_count() add_preempt_count(1)
76062 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
76063 #define dec_preempt_count() sub_preempt_count(1)
76064 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
76065
76066 #define preempt_count() (current_thread_info()->preempt_count)
76067
76068 @@ -64,6 +69,12 @@ do { \
76069 barrier(); \
76070 } while (0)
76071
76072 +#define raw_preempt_disable() \
76073 +do { \
76074 + raw_inc_preempt_count(); \
76075 + barrier(); \
76076 +} while (0)
76077 +
76078 #define sched_preempt_enable_no_resched() \
76079 do { \
76080 barrier(); \
76081 @@ -72,6 +83,12 @@ do { \
76082
76083 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
76084
76085 +#define raw_preempt_enable_no_resched() \
76086 +do { \
76087 + barrier(); \
76088 + raw_dec_preempt_count(); \
76089 +} while (0)
76090 +
76091 #define preempt_enable() \
76092 do { \
76093 preempt_enable_no_resched(); \
76094 @@ -116,8 +133,10 @@ do { \
76095 * region.
76096 */
76097 #define preempt_disable() barrier()
76098 +#define raw_preempt_disable() barrier()
76099 #define sched_preempt_enable_no_resched() barrier()
76100 #define preempt_enable_no_resched() barrier()
76101 +#define raw_preempt_enable_no_resched() barrier()
76102 #define preempt_enable() barrier()
76103
76104 #define preempt_disable_notrace() barrier()
76105 diff --git a/include/linux/printk.h b/include/linux/printk.h
76106 index 22c7052..ad3fa0a 100644
76107 --- a/include/linux/printk.h
76108 +++ b/include/linux/printk.h
76109 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
76110 void early_printk(const char *s, ...) { }
76111 #endif
76112
76113 +extern int kptr_restrict;
76114 +
76115 #ifdef CONFIG_PRINTK
76116 asmlinkage __printf(5, 0)
76117 int vprintk_emit(int facility, int level,
76118 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
76119
76120 extern int printk_delay_msec;
76121 extern int dmesg_restrict;
76122 -extern int kptr_restrict;
76123
76124 extern void wake_up_klogd(void);
76125
76126 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
76127 index 608e60a..c26f864 100644
76128 --- a/include/linux/proc_fs.h
76129 +++ b/include/linux/proc_fs.h
76130 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
76131 return proc_create_data(name, mode, parent, proc_fops, NULL);
76132 }
76133
76134 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
76135 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
76136 +{
76137 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76138 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
76139 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76140 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
76141 +#else
76142 + return proc_create_data(name, mode, parent, proc_fops, NULL);
76143 +#endif
76144 +}
76145 +
76146 +
76147 extern void proc_set_size(struct proc_dir_entry *, loff_t);
76148 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
76149 extern void *PDE_DATA(const struct inode *);
76150 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
76151 index 34a1e10..03a6d03 100644
76152 --- a/include/linux/proc_ns.h
76153 +++ b/include/linux/proc_ns.h
76154 @@ -14,7 +14,7 @@ struct proc_ns_operations {
76155 void (*put)(void *ns);
76156 int (*install)(struct nsproxy *nsproxy, void *ns);
76157 unsigned int (*inum)(void *ns);
76158 -};
76159 +} __do_const;
76160
76161 struct proc_ns {
76162 void *ns;
76163 diff --git a/include/linux/random.h b/include/linux/random.h
76164 index 6312dd9..2561947 100644
76165 --- a/include/linux/random.h
76166 +++ b/include/linux/random.h
76167 @@ -10,9 +10,19 @@
76168
76169
76170 extern void add_device_randomness(const void *, unsigned int);
76171 +
76172 +static inline void add_latent_entropy(void)
76173 +{
76174 +
76175 +#ifdef LATENT_ENTROPY_PLUGIN
76176 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
76177 +#endif
76178 +
76179 +}
76180 +
76181 extern void add_input_randomness(unsigned int type, unsigned int code,
76182 - unsigned int value);
76183 -extern void add_interrupt_randomness(int irq, int irq_flags);
76184 + unsigned int value) __latent_entropy;
76185 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
76186
76187 extern void get_random_bytes(void *buf, int nbytes);
76188 extern void get_random_bytes_arch(void *buf, int nbytes);
76189 @@ -33,6 +43,11 @@ void prandom_seed(u32 seed);
76190 u32 prandom_u32_state(struct rnd_state *);
76191 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
76192
76193 +static inline unsigned long pax_get_random_long(void)
76194 +{
76195 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
76196 +}
76197 +
76198 /*
76199 * Handle minimum values for seeds
76200 */
76201 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
76202 index 4106721..132d42c 100644
76203 --- a/include/linux/rculist.h
76204 +++ b/include/linux/rculist.h
76205 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
76206 struct list_head *prev, struct list_head *next);
76207 #endif
76208
76209 +extern void __pax_list_add_rcu(struct list_head *new,
76210 + struct list_head *prev, struct list_head *next);
76211 +
76212 /**
76213 * list_add_rcu - add a new entry to rcu-protected list
76214 * @new: new entry to be added
76215 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
76216 __list_add_rcu(new, head, head->next);
76217 }
76218
76219 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
76220 +{
76221 + __pax_list_add_rcu(new, head, head->next);
76222 +}
76223 +
76224 /**
76225 * list_add_tail_rcu - add a new entry to rcu-protected list
76226 * @new: new entry to be added
76227 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
76228 __list_add_rcu(new, head->prev, head);
76229 }
76230
76231 +static inline void pax_list_add_tail_rcu(struct list_head *new,
76232 + struct list_head *head)
76233 +{
76234 + __pax_list_add_rcu(new, head->prev, head);
76235 +}
76236 +
76237 /**
76238 * list_del_rcu - deletes entry from list without re-initialization
76239 * @entry: the element to delete from the list.
76240 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
76241 entry->prev = LIST_POISON2;
76242 }
76243
76244 +extern void pax_list_del_rcu(struct list_head *entry);
76245 +
76246 /**
76247 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
76248 * @n: the element to delete from the hash list.
76249 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
76250 index 8e00f9f..9449b55 100644
76251 --- a/include/linux/reboot.h
76252 +++ b/include/linux/reboot.h
76253 @@ -43,9 +43,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
76254 * Architecture-specific implementations of sys_reboot commands.
76255 */
76256
76257 -extern void machine_restart(char *cmd);
76258 -extern void machine_halt(void);
76259 -extern void machine_power_off(void);
76260 +extern void machine_restart(char *cmd) __noreturn;
76261 +extern void machine_halt(void) __noreturn;
76262 +extern void machine_power_off(void) __noreturn;
76263
76264 extern void machine_shutdown(void);
76265 struct pt_regs;
76266 @@ -56,9 +56,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
76267 */
76268
76269 extern void kernel_restart_prepare(char *cmd);
76270 -extern void kernel_restart(char *cmd);
76271 -extern void kernel_halt(void);
76272 -extern void kernel_power_off(void);
76273 +extern void kernel_restart(char *cmd) __noreturn;
76274 +extern void kernel_halt(void) __noreturn;
76275 +extern void kernel_power_off(void) __noreturn;
76276
76277 extern int C_A_D; /* for sysctl */
76278 void ctrl_alt_del(void);
76279 @@ -72,7 +72,7 @@ extern int orderly_poweroff(bool force);
76280 * Emergency restart, callable from an interrupt handler.
76281 */
76282
76283 -extern void emergency_restart(void);
76284 +extern void emergency_restart(void) __noreturn;
76285 #include <asm/emergency-restart.h>
76286
76287 #endif /* _LINUX_REBOOT_H */
76288 diff --git a/include/linux/regset.h b/include/linux/regset.h
76289 index 8e0c9fe..ac4d221 100644
76290 --- a/include/linux/regset.h
76291 +++ b/include/linux/regset.h
76292 @@ -161,7 +161,8 @@ struct user_regset {
76293 unsigned int align;
76294 unsigned int bias;
76295 unsigned int core_note_type;
76296 -};
76297 +} __do_const;
76298 +typedef struct user_regset __no_const user_regset_no_const;
76299
76300 /**
76301 * struct user_regset_view - available regsets
76302 diff --git a/include/linux/relay.h b/include/linux/relay.h
76303 index d7c8359..818daf5 100644
76304 --- a/include/linux/relay.h
76305 +++ b/include/linux/relay.h
76306 @@ -157,7 +157,7 @@ struct rchan_callbacks
76307 * The callback should return 0 if successful, negative if not.
76308 */
76309 int (*remove_buf_file)(struct dentry *dentry);
76310 -};
76311 +} __no_const;
76312
76313 /*
76314 * CONFIG_RELAY kernel API, kernel/relay.c
76315 diff --git a/include/linux/rio.h b/include/linux/rio.h
76316 index b71d573..2f940bd 100644
76317 --- a/include/linux/rio.h
76318 +++ b/include/linux/rio.h
76319 @@ -355,7 +355,7 @@ struct rio_ops {
76320 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
76321 u64 rstart, u32 size, u32 flags);
76322 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
76323 -};
76324 +} __no_const;
76325
76326 #define RIO_RESOURCE_MEM 0x00000100
76327 #define RIO_RESOURCE_DOORBELL 0x00000200
76328 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
76329 index 6dacb93..6174423 100644
76330 --- a/include/linux/rmap.h
76331 +++ b/include/linux/rmap.h
76332 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
76333 void anon_vma_init(void); /* create anon_vma_cachep */
76334 int anon_vma_prepare(struct vm_area_struct *);
76335 void unlink_anon_vmas(struct vm_area_struct *);
76336 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
76337 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
76338 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
76339 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
76340
76341 static inline void anon_vma_merge(struct vm_area_struct *vma,
76342 struct vm_area_struct *next)
76343 diff --git a/include/linux/sched.h b/include/linux/sched.h
76344 index 078066d..4090b3b 100644
76345 --- a/include/linux/sched.h
76346 +++ b/include/linux/sched.h
76347 @@ -62,6 +62,7 @@ struct bio_list;
76348 struct fs_struct;
76349 struct perf_event_context;
76350 struct blk_plug;
76351 +struct linux_binprm;
76352
76353 /*
76354 * List of flags we want to share for kernel threads,
76355 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
76356 extern int in_sched_functions(unsigned long addr);
76357
76358 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
76359 -extern signed long schedule_timeout(signed long timeout);
76360 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
76361 extern signed long schedule_timeout_interruptible(signed long timeout);
76362 extern signed long schedule_timeout_killable(signed long timeout);
76363 extern signed long schedule_timeout_uninterruptible(signed long timeout);
76364 @@ -314,6 +315,19 @@ struct nsproxy;
76365 struct user_namespace;
76366
76367 #ifdef CONFIG_MMU
76368 +
76369 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
76370 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
76371 +#else
76372 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
76373 +{
76374 + return 0;
76375 +}
76376 +#endif
76377 +
76378 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
76379 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
76380 +
76381 extern void arch_pick_mmap_layout(struct mm_struct *mm);
76382 extern unsigned long
76383 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
76384 @@ -589,6 +603,17 @@ struct signal_struct {
76385 #ifdef CONFIG_TASKSTATS
76386 struct taskstats *stats;
76387 #endif
76388 +
76389 +#ifdef CONFIG_GRKERNSEC
76390 + u32 curr_ip;
76391 + u32 saved_ip;
76392 + u32 gr_saddr;
76393 + u32 gr_daddr;
76394 + u16 gr_sport;
76395 + u16 gr_dport;
76396 + u8 used_accept:1;
76397 +#endif
76398 +
76399 #ifdef CONFIG_AUDIT
76400 unsigned audit_tty;
76401 unsigned audit_tty_log_passwd;
76402 @@ -669,6 +694,14 @@ struct user_struct {
76403 struct key *session_keyring; /* UID's default session keyring */
76404 #endif
76405
76406 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
76407 + unsigned char kernel_banned;
76408 +#endif
76409 +#ifdef CONFIG_GRKERNSEC_BRUTE
76410 + unsigned char suid_banned;
76411 + unsigned long suid_ban_expires;
76412 +#endif
76413 +
76414 /* Hash table maintenance information */
76415 struct hlist_node uidhash_node;
76416 kuid_t uid;
76417 @@ -1151,8 +1184,8 @@ struct task_struct {
76418 struct list_head thread_group;
76419
76420 struct completion *vfork_done; /* for vfork() */
76421 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
76422 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76423 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
76424 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
76425
76426 cputime_t utime, stime, utimescaled, stimescaled;
76427 cputime_t gtime;
76428 @@ -1177,11 +1210,6 @@ struct task_struct {
76429 struct task_cputime cputime_expires;
76430 struct list_head cpu_timers[3];
76431
76432 -/* process credentials */
76433 - const struct cred __rcu *real_cred; /* objective and real subjective task
76434 - * credentials (COW) */
76435 - const struct cred __rcu *cred; /* effective (overridable) subjective task
76436 - * credentials (COW) */
76437 char comm[TASK_COMM_LEN]; /* executable name excluding path
76438 - access with [gs]et_task_comm (which lock
76439 it with task_lock())
76440 @@ -1198,6 +1226,10 @@ struct task_struct {
76441 #endif
76442 /* CPU-specific state of this task */
76443 struct thread_struct thread;
76444 +/* thread_info moved to task_struct */
76445 +#ifdef CONFIG_X86
76446 + struct thread_info tinfo;
76447 +#endif
76448 /* filesystem information */
76449 struct fs_struct *fs;
76450 /* open file information */
76451 @@ -1271,6 +1303,10 @@ struct task_struct {
76452 gfp_t lockdep_reclaim_gfp;
76453 #endif
76454
76455 +/* process credentials */
76456 + const struct cred __rcu *real_cred; /* objective and real subjective task
76457 + * credentials (COW) */
76458 +
76459 /* journalling filesystem info */
76460 void *journal_info;
76461
76462 @@ -1309,6 +1345,10 @@ struct task_struct {
76463 /* cg_list protected by css_set_lock and tsk->alloc_lock */
76464 struct list_head cg_list;
76465 #endif
76466 +
76467 + const struct cred __rcu *cred; /* effective (overridable) subjective task
76468 + * credentials (COW) */
76469 +
76470 #ifdef CONFIG_FUTEX
76471 struct robust_list_head __user *robust_list;
76472 #ifdef CONFIG_COMPAT
76473 @@ -1406,8 +1446,76 @@ struct task_struct {
76474 unsigned int sequential_io;
76475 unsigned int sequential_io_avg;
76476 #endif
76477 +
76478 +#ifdef CONFIG_GRKERNSEC
76479 + /* grsecurity */
76480 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76481 + u64 exec_id;
76482 +#endif
76483 +#ifdef CONFIG_GRKERNSEC_SETXID
76484 + const struct cred *delayed_cred;
76485 +#endif
76486 + struct dentry *gr_chroot_dentry;
76487 + struct acl_subject_label *acl;
76488 + struct acl_role_label *role;
76489 + struct file *exec_file;
76490 + unsigned long brute_expires;
76491 + u16 acl_role_id;
76492 + /* is this the task that authenticated to the special role */
76493 + u8 acl_sp_role;
76494 + u8 is_writable;
76495 + u8 brute;
76496 + u8 gr_is_chrooted;
76497 +#endif
76498 +
76499 };
76500
76501 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
76502 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
76503 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
76504 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
76505 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
76506 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
76507 +
76508 +#ifdef CONFIG_PAX_SOFTMODE
76509 +extern int pax_softmode;
76510 +#endif
76511 +
76512 +extern int pax_check_flags(unsigned long *);
76513 +
76514 +/* if tsk != current then task_lock must be held on it */
76515 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
76516 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
76517 +{
76518 + if (likely(tsk->mm))
76519 + return tsk->mm->pax_flags;
76520 + else
76521 + return 0UL;
76522 +}
76523 +
76524 +/* if tsk != current then task_lock must be held on it */
76525 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
76526 +{
76527 + if (likely(tsk->mm)) {
76528 + tsk->mm->pax_flags = flags;
76529 + return 0;
76530 + }
76531 + return -EINVAL;
76532 +}
76533 +#endif
76534 +
76535 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
76536 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
76537 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
76538 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
76539 +#endif
76540 +
76541 +struct path;
76542 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
76543 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
76544 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
76545 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
76546 +
76547 /* Future-safe accessor for struct task_struct's cpus_allowed. */
76548 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
76549
76550 @@ -1466,7 +1574,7 @@ struct pid_namespace;
76551 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
76552 struct pid_namespace *ns);
76553
76554 -static inline pid_t task_pid_nr(struct task_struct *tsk)
76555 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
76556 {
76557 return tsk->pid;
76558 }
76559 @@ -1916,7 +2024,9 @@ void yield(void);
76560 extern struct exec_domain default_exec_domain;
76561
76562 union thread_union {
76563 +#ifndef CONFIG_X86
76564 struct thread_info thread_info;
76565 +#endif
76566 unsigned long stack[THREAD_SIZE/sizeof(long)];
76567 };
76568
76569 @@ -1949,6 +2059,7 @@ extern struct pid_namespace init_pid_ns;
76570 */
76571
76572 extern struct task_struct *find_task_by_vpid(pid_t nr);
76573 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
76574 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
76575 struct pid_namespace *ns);
76576
76577 @@ -2113,7 +2224,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
76578 extern void exit_itimers(struct signal_struct *);
76579 extern void flush_itimer_signals(void);
76580
76581 -extern void do_group_exit(int);
76582 +extern __noreturn void do_group_exit(int);
76583
76584 extern int allow_signal(int);
76585 extern int disallow_signal(int);
76586 @@ -2304,9 +2415,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
76587
76588 #endif
76589
76590 -static inline int object_is_on_stack(void *obj)
76591 +static inline int object_starts_on_stack(void *obj)
76592 {
76593 - void *stack = task_stack_page(current);
76594 + const void *stack = task_stack_page(current);
76595
76596 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
76597 }
76598 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
76599 index bf8086b..962b035 100644
76600 --- a/include/linux/sched/sysctl.h
76601 +++ b/include/linux/sched/sysctl.h
76602 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
76603 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
76604
76605 extern int sysctl_max_map_count;
76606 +extern unsigned long sysctl_heap_stack_gap;
76607
76608 extern unsigned int sysctl_sched_latency;
76609 extern unsigned int sysctl_sched_min_granularity;
76610 diff --git a/include/linux/security.h b/include/linux/security.h
76611 index 7ce53ae..8ee24a5 100644
76612 --- a/include/linux/security.h
76613 +++ b/include/linux/security.h
76614 @@ -27,6 +27,7 @@
76615 #include <linux/slab.h>
76616 #include <linux/err.h>
76617 #include <linux/string.h>
76618 +#include <linux/grsecurity.h>
76619
76620 struct linux_binprm;
76621 struct cred;
76622 @@ -116,8 +117,6 @@ struct seq_file;
76623
76624 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
76625
76626 -void reset_security_ops(void);
76627 -
76628 #ifdef CONFIG_MMU
76629 extern unsigned long mmap_min_addr;
76630 extern unsigned long dac_mmap_min_addr;
76631 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
76632 index 4e32edc..f8f2d18 100644
76633 --- a/include/linux/seq_file.h
76634 +++ b/include/linux/seq_file.h
76635 @@ -26,6 +26,9 @@ struct seq_file {
76636 struct mutex lock;
76637 const struct seq_operations *op;
76638 int poll_event;
76639 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
76640 + u64 exec_id;
76641 +#endif
76642 #ifdef CONFIG_USER_NS
76643 struct user_namespace *user_ns;
76644 #endif
76645 @@ -38,6 +41,7 @@ struct seq_operations {
76646 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
76647 int (*show) (struct seq_file *m, void *v);
76648 };
76649 +typedef struct seq_operations __no_const seq_operations_no_const;
76650
76651 #define SEQ_SKIP 1
76652
76653 diff --git a/include/linux/shm.h b/include/linux/shm.h
76654 index 429c199..4d42e38 100644
76655 --- a/include/linux/shm.h
76656 +++ b/include/linux/shm.h
76657 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
76658
76659 /* The task created the shm object. NULL if the task is dead. */
76660 struct task_struct *shm_creator;
76661 +#ifdef CONFIG_GRKERNSEC
76662 + time_t shm_createtime;
76663 + pid_t shm_lapid;
76664 +#endif
76665 };
76666
76667 /* shm_mode upper byte flags */
76668 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
76669 index 3b71a4e..4823435 100644
76670 --- a/include/linux/skbuff.h
76671 +++ b/include/linux/skbuff.h
76672 @@ -648,7 +648,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
76673 extern struct sk_buff *__alloc_skb(unsigned int size,
76674 gfp_t priority, int flags, int node);
76675 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
76676 -static inline struct sk_buff *alloc_skb(unsigned int size,
76677 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
76678 gfp_t priority)
76679 {
76680 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
76681 @@ -764,7 +764,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
76682 */
76683 static inline int skb_queue_empty(const struct sk_buff_head *list)
76684 {
76685 - return list->next == (struct sk_buff *)list;
76686 + return list->next == (const struct sk_buff *)list;
76687 }
76688
76689 /**
76690 @@ -777,7 +777,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
76691 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76692 const struct sk_buff *skb)
76693 {
76694 - return skb->next == (struct sk_buff *)list;
76695 + return skb->next == (const struct sk_buff *)list;
76696 }
76697
76698 /**
76699 @@ -790,7 +790,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
76700 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
76701 const struct sk_buff *skb)
76702 {
76703 - return skb->prev == (struct sk_buff *)list;
76704 + return skb->prev == (const struct sk_buff *)list;
76705 }
76706
76707 /**
76708 @@ -1316,6 +1316,11 @@ static inline int skb_pagelen(const struct sk_buff *skb)
76709 return len + skb_headlen(skb);
76710 }
76711
76712 +static inline bool skb_has_frags(const struct sk_buff *skb)
76713 +{
76714 + return skb_shinfo(skb)->nr_frags;
76715 +}
76716 +
76717 /**
76718 * __skb_fill_page_desc - initialise a paged fragment in an skb
76719 * @skb: buffer containing fragment to be initialised
76720 @@ -1750,7 +1755,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
76721 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
76722 */
76723 #ifndef NET_SKB_PAD
76724 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
76725 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
76726 #endif
76727
76728 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
76729 @@ -2345,7 +2350,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
76730 int noblock, int *err);
76731 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
76732 struct poll_table_struct *wait);
76733 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
76734 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
76735 int offset, struct iovec *to,
76736 int size);
76737 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
76738 @@ -2636,6 +2641,9 @@ static inline void nf_reset(struct sk_buff *skb)
76739 nf_bridge_put(skb->nf_bridge);
76740 skb->nf_bridge = NULL;
76741 #endif
76742 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
76743 + skb->nf_trace = 0;
76744 +#endif
76745 }
76746
76747 static inline void nf_reset_trace(struct sk_buff *skb)
76748 diff --git a/include/linux/slab.h b/include/linux/slab.h
76749 index 6c5cc0e..9ca0fd6 100644
76750 --- a/include/linux/slab.h
76751 +++ b/include/linux/slab.h
76752 @@ -12,15 +12,29 @@
76753 #include <linux/gfp.h>
76754 #include <linux/types.h>
76755 #include <linux/workqueue.h>
76756 -
76757 +#include <linux/err.h>
76758
76759 /*
76760 * Flags to pass to kmem_cache_create().
76761 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
76762 */
76763 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
76764 +
76765 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76766 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
76767 +#else
76768 +#define SLAB_USERCOPY 0x00000000UL
76769 +#endif
76770 +
76771 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
76772 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
76773 +
76774 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76775 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
76776 +#else
76777 +#define SLAB_NO_SANITIZE 0x00000000UL
76778 +#endif
76779 +
76780 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
76781 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
76782 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
76783 @@ -89,10 +103,13 @@
76784 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
76785 * Both make kfree a no-op.
76786 */
76787 -#define ZERO_SIZE_PTR ((void *)16)
76788 +#define ZERO_SIZE_PTR \
76789 +({ \
76790 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
76791 + (void *)(-MAX_ERRNO-1L); \
76792 +})
76793
76794 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
76795 - (unsigned long)ZERO_SIZE_PTR)
76796 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
76797
76798
76799 struct mem_cgroup;
76800 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
76801 void kfree(const void *);
76802 void kzfree(const void *);
76803 size_t ksize(const void *);
76804 +const char *check_heap_object(const void *ptr, unsigned long n);
76805 +bool is_usercopy_object(const void *ptr);
76806
76807 /*
76808 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
76809 @@ -164,7 +183,7 @@ struct kmem_cache {
76810 unsigned int align; /* Alignment as calculated */
76811 unsigned long flags; /* Active flags on the slab */
76812 const char *name; /* Slab name for sysfs */
76813 - int refcount; /* Use counter */
76814 + atomic_t refcount; /* Use counter */
76815 void (*ctor)(void *); /* Called on object slot creation */
76816 struct list_head list; /* List of all slab caches on the system */
76817 };
76818 @@ -238,6 +257,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
76819 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76820 #endif
76821
76822 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76823 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
76824 +#endif
76825 +
76826 /*
76827 * Figure out which kmalloc slab an allocation of a certain size
76828 * belongs to.
76829 @@ -246,7 +269,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
76830 * 2 = 120 .. 192 bytes
76831 * n = 2^(n-1) .. 2^n -1
76832 */
76833 -static __always_inline int kmalloc_index(size_t size)
76834 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
76835 {
76836 if (!size)
76837 return 0;
76838 @@ -492,7 +515,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
76839 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76840 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76841 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76842 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76843 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
76844 #define kmalloc_track_caller(size, flags) \
76845 __kmalloc_track_caller(size, flags, _RET_IP_)
76846 #else
76847 @@ -512,7 +535,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
76848 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
76849 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
76850 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
76851 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
76852 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
76853 #define kmalloc_node_track_caller(size, flags, node) \
76854 __kmalloc_node_track_caller(size, flags, node, \
76855 _RET_IP_)
76856 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
76857 index cd40158..4e2f7af 100644
76858 --- a/include/linux/slab_def.h
76859 +++ b/include/linux/slab_def.h
76860 @@ -50,7 +50,7 @@ struct kmem_cache {
76861 /* 4) cache creation/removal */
76862 const char *name;
76863 struct list_head list;
76864 - int refcount;
76865 + atomic_t refcount;
76866 int object_size;
76867 int align;
76868
76869 @@ -66,10 +66,14 @@ struct kmem_cache {
76870 unsigned long node_allocs;
76871 unsigned long node_frees;
76872 unsigned long node_overflow;
76873 - atomic_t allochit;
76874 - atomic_t allocmiss;
76875 - atomic_t freehit;
76876 - atomic_t freemiss;
76877 + atomic_unchecked_t allochit;
76878 + atomic_unchecked_t allocmiss;
76879 + atomic_unchecked_t freehit;
76880 + atomic_unchecked_t freemiss;
76881 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
76882 + atomic_unchecked_t sanitized;
76883 + atomic_unchecked_t not_sanitized;
76884 +#endif
76885
76886 /*
76887 * If debugging is enabled, then the allocator can add additional
76888 @@ -103,7 +107,7 @@ struct kmem_cache {
76889 };
76890
76891 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76892 -void *__kmalloc(size_t size, gfp_t flags);
76893 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
76894
76895 #ifdef CONFIG_TRACING
76896 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
76897 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76898 cachep = kmalloc_dma_caches[i];
76899 else
76900 #endif
76901 +
76902 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76903 + if (flags & GFP_USERCOPY)
76904 + cachep = kmalloc_usercopy_caches[i];
76905 + else
76906 +#endif
76907 +
76908 cachep = kmalloc_caches[i];
76909
76910 ret = kmem_cache_alloc_trace(cachep, flags, size);
76911 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76912 }
76913
76914 #ifdef CONFIG_NUMA
76915 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
76916 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76917 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76918
76919 #ifdef CONFIG_TRACING
76920 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76921 cachep = kmalloc_dma_caches[i];
76922 else
76923 #endif
76924 +
76925 +#ifdef CONFIG_PAX_USERCOPY_SLABS
76926 + if (flags & GFP_USERCOPY)
76927 + cachep = kmalloc_usercopy_caches[i];
76928 + else
76929 +#endif
76930 +
76931 cachep = kmalloc_caches[i];
76932
76933 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
76934 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
76935 index 095a5a4..4b82027 100644
76936 --- a/include/linux/slob_def.h
76937 +++ b/include/linux/slob_def.h
76938 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
76939 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
76940 }
76941
76942 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76943 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76944
76945 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
76946 {
76947 @@ -23,7 +23,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76948 return __kmalloc_node(size, flags, NUMA_NO_NODE);
76949 }
76950
76951 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
76952 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
76953 {
76954 return kmalloc(size, flags);
76955 }
76956 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
76957 index 027276f..092bfe8 100644
76958 --- a/include/linux/slub_def.h
76959 +++ b/include/linux/slub_def.h
76960 @@ -80,7 +80,7 @@ struct kmem_cache {
76961 struct kmem_cache_order_objects max;
76962 struct kmem_cache_order_objects min;
76963 gfp_t allocflags; /* gfp flags to use on each alloc */
76964 - int refcount; /* Refcount for slab cache destroy */
76965 + atomic_t refcount; /* Refcount for slab cache destroy */
76966 void (*ctor)(void *);
76967 int inuse; /* Offset to metadata */
76968 int align; /* Alignment */
76969 @@ -105,7 +105,7 @@ struct kmem_cache {
76970 };
76971
76972 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
76973 -void *__kmalloc(size_t size, gfp_t flags);
76974 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
76975
76976 static __always_inline void *
76977 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
76978 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
76979 }
76980 #endif
76981
76982 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
76983 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
76984 {
76985 unsigned int order = get_order(size);
76986 return kmalloc_order_trace(size, flags, order);
76987 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
76988 }
76989
76990 #ifdef CONFIG_NUMA
76991 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
76992 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
76993 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
76994
76995 #ifdef CONFIG_TRACING
76996 diff --git a/include/linux/smp.h b/include/linux/smp.h
76997 index c181399..09d7b92 100644
76998 --- a/include/linux/smp.h
76999 +++ b/include/linux/smp.h
77000 @@ -217,7 +217,9 @@ static inline void kick_all_cpus_sync(void) { }
77001 #endif
77002
77003 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
77004 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
77005 #define put_cpu() preempt_enable()
77006 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
77007
77008 /*
77009 * Callback to arch code if there's nosmp or maxcpus=0 on the
77010 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
77011 index 54f91d3..be2c379 100644
77012 --- a/include/linux/sock_diag.h
77013 +++ b/include/linux/sock_diag.h
77014 @@ -11,7 +11,7 @@ struct sock;
77015 struct sock_diag_handler {
77016 __u8 family;
77017 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
77018 -};
77019 +} __do_const;
77020
77021 int sock_diag_register(const struct sock_diag_handler *h);
77022 void sock_diag_unregister(const struct sock_diag_handler *h);
77023 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
77024 index 680f9a3..f13aeb0 100644
77025 --- a/include/linux/sonet.h
77026 +++ b/include/linux/sonet.h
77027 @@ -7,7 +7,7 @@
77028 #include <uapi/linux/sonet.h>
77029
77030 struct k_sonet_stats {
77031 -#define __HANDLE_ITEM(i) atomic_t i
77032 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
77033 __SONET_ITEMS
77034 #undef __HANDLE_ITEM
77035 };
77036 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
77037 index 07d8e53..dc934c9 100644
77038 --- a/include/linux/sunrpc/addr.h
77039 +++ b/include/linux/sunrpc/addr.h
77040 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
77041 {
77042 switch (sap->sa_family) {
77043 case AF_INET:
77044 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
77045 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
77046 case AF_INET6:
77047 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
77048 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
77049 }
77050 return 0;
77051 }
77052 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
77053 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
77054 const struct sockaddr *src)
77055 {
77056 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
77057 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
77058 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
77059
77060 dsin->sin_family = ssin->sin_family;
77061 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
77062 if (sa->sa_family != AF_INET6)
77063 return 0;
77064
77065 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
77066 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
77067 }
77068
77069 #endif /* _LINUX_SUNRPC_ADDR_H */
77070 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
77071 index bfe11be..12bc8c4 100644
77072 --- a/include/linux/sunrpc/clnt.h
77073 +++ b/include/linux/sunrpc/clnt.h
77074 @@ -96,7 +96,7 @@ struct rpc_procinfo {
77075 unsigned int p_timer; /* Which RTT timer to use */
77076 u32 p_statidx; /* Which procedure to account */
77077 const char * p_name; /* name of procedure */
77078 -};
77079 +} __do_const;
77080
77081 #ifdef __KERNEL__
77082
77083 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
77084 index 1f0216b..6a4fa50 100644
77085 --- a/include/linux/sunrpc/svc.h
77086 +++ b/include/linux/sunrpc/svc.h
77087 @@ -411,7 +411,7 @@ struct svc_procedure {
77088 unsigned int pc_count; /* call count */
77089 unsigned int pc_cachetype; /* cache info (NFS) */
77090 unsigned int pc_xdrressize; /* maximum size of XDR reply */
77091 -};
77092 +} __do_const;
77093
77094 /*
77095 * Function prototypes.
77096 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
77097 index 0b8e3e6..33e0a01 100644
77098 --- a/include/linux/sunrpc/svc_rdma.h
77099 +++ b/include/linux/sunrpc/svc_rdma.h
77100 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
77101 extern unsigned int svcrdma_max_requests;
77102 extern unsigned int svcrdma_max_req_size;
77103
77104 -extern atomic_t rdma_stat_recv;
77105 -extern atomic_t rdma_stat_read;
77106 -extern atomic_t rdma_stat_write;
77107 -extern atomic_t rdma_stat_sq_starve;
77108 -extern atomic_t rdma_stat_rq_starve;
77109 -extern atomic_t rdma_stat_rq_poll;
77110 -extern atomic_t rdma_stat_rq_prod;
77111 -extern atomic_t rdma_stat_sq_poll;
77112 -extern atomic_t rdma_stat_sq_prod;
77113 +extern atomic_unchecked_t rdma_stat_recv;
77114 +extern atomic_unchecked_t rdma_stat_read;
77115 +extern atomic_unchecked_t rdma_stat_write;
77116 +extern atomic_unchecked_t rdma_stat_sq_starve;
77117 +extern atomic_unchecked_t rdma_stat_rq_starve;
77118 +extern atomic_unchecked_t rdma_stat_rq_poll;
77119 +extern atomic_unchecked_t rdma_stat_rq_prod;
77120 +extern atomic_unchecked_t rdma_stat_sq_poll;
77121 +extern atomic_unchecked_t rdma_stat_sq_prod;
77122
77123 #define RPCRDMA_VERSION 1
77124
77125 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
77126 index 8d71d65..f79586e 100644
77127 --- a/include/linux/sunrpc/svcauth.h
77128 +++ b/include/linux/sunrpc/svcauth.h
77129 @@ -120,7 +120,7 @@ struct auth_ops {
77130 int (*release)(struct svc_rqst *rq);
77131 void (*domain_release)(struct auth_domain *);
77132 int (*set_client)(struct svc_rqst *rq);
77133 -};
77134 +} __do_const;
77135
77136 #define SVC_GARBAGE 1
77137 #define SVC_SYSERR 2
77138 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
77139 index a5ffd32..0935dea 100644
77140 --- a/include/linux/swiotlb.h
77141 +++ b/include/linux/swiotlb.h
77142 @@ -60,7 +60,8 @@ extern void
77143
77144 extern void
77145 swiotlb_free_coherent(struct device *hwdev, size_t size,
77146 - void *vaddr, dma_addr_t dma_handle);
77147 + void *vaddr, dma_addr_t dma_handle,
77148 + struct dma_attrs *attrs);
77149
77150 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
77151 unsigned long offset, size_t size,
77152 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
77153 index 84662ec..5271947 100644
77154 --- a/include/linux/syscalls.h
77155 +++ b/include/linux/syscalls.h
77156 @@ -97,8 +97,14 @@ struct sigaltstack;
77157 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
77158
77159 #define __SC_DECL(t, a) t a
77160 +#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))
77161 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
77162 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
77163 +#define __SC_LONG(t, a) __typeof( \
77164 + __builtin_choose_expr( \
77165 + sizeof(t) > sizeof(int), \
77166 + (t) 0, \
77167 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
77168 + )) a
77169 #define __SC_CAST(t, a) (t) a
77170 #define __SC_ARGS(t, a) a
77171 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
77172 @@ -362,11 +368,11 @@ asmlinkage long sys_sync(void);
77173 asmlinkage long sys_fsync(unsigned int fd);
77174 asmlinkage long sys_fdatasync(unsigned int fd);
77175 asmlinkage long sys_bdflush(int func, long data);
77176 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
77177 - char __user *type, unsigned long flags,
77178 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
77179 + const char __user *type, unsigned long flags,
77180 void __user *data);
77181 -asmlinkage long sys_umount(char __user *name, int flags);
77182 -asmlinkage long sys_oldumount(char __user *name);
77183 +asmlinkage long sys_umount(const char __user *name, int flags);
77184 +asmlinkage long sys_oldumount(const char __user *name);
77185 asmlinkage long sys_truncate(const char __user *path, long length);
77186 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
77187 asmlinkage long sys_stat(const char __user *filename,
77188 @@ -578,7 +584,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
77189 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
77190 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
77191 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
77192 - struct sockaddr __user *, int);
77193 + struct sockaddr __user *, int) __intentional_overflow(0);
77194 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
77195 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
77196 unsigned int vlen, unsigned flags);
77197 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
77198 index 27b3b0b..e093dd9 100644
77199 --- a/include/linux/syscore_ops.h
77200 +++ b/include/linux/syscore_ops.h
77201 @@ -16,7 +16,7 @@ struct syscore_ops {
77202 int (*suspend)(void);
77203 void (*resume)(void);
77204 void (*shutdown)(void);
77205 -};
77206 +} __do_const;
77207
77208 extern void register_syscore_ops(struct syscore_ops *ops);
77209 extern void unregister_syscore_ops(struct syscore_ops *ops);
77210 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
77211 index 14a8ff2..af52bad 100644
77212 --- a/include/linux/sysctl.h
77213 +++ b/include/linux/sysctl.h
77214 @@ -34,13 +34,13 @@ struct ctl_table_root;
77215 struct ctl_table_header;
77216 struct ctl_dir;
77217
77218 -typedef struct ctl_table ctl_table;
77219 -
77220 typedef int proc_handler (struct ctl_table *ctl, int write,
77221 void __user *buffer, size_t *lenp, loff_t *ppos);
77222
77223 extern int proc_dostring(struct ctl_table *, int,
77224 void __user *, size_t *, loff_t *);
77225 +extern int proc_dostring_modpriv(struct ctl_table *, int,
77226 + void __user *, size_t *, loff_t *);
77227 extern int proc_dointvec(struct ctl_table *, int,
77228 void __user *, size_t *, loff_t *);
77229 extern int proc_dointvec_minmax(struct ctl_table *, int,
77230 @@ -115,7 +115,9 @@ struct ctl_table
77231 struct ctl_table_poll *poll;
77232 void *extra1;
77233 void *extra2;
77234 -};
77235 +} __do_const;
77236 +typedef struct ctl_table __no_const ctl_table_no_const;
77237 +typedef struct ctl_table ctl_table;
77238
77239 struct ctl_node {
77240 struct rb_node node;
77241 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
77242 index 9e8a9b5..753de68 100644
77243 --- a/include/linux/sysfs.h
77244 +++ b/include/linux/sysfs.h
77245 @@ -33,7 +33,8 @@ struct attribute {
77246 struct lock_class_key *key;
77247 struct lock_class_key skey;
77248 #endif
77249 -};
77250 +} __do_const;
77251 +typedef struct attribute __no_const attribute_no_const;
77252
77253 /**
77254 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
77255 @@ -62,7 +63,8 @@ struct attribute_group {
77256 struct attribute *, int);
77257 struct attribute **attrs;
77258 struct bin_attribute **bin_attrs;
77259 -};
77260 +} __do_const;
77261 +typedef struct attribute_group __no_const attribute_group_no_const;
77262
77263 /**
77264 * Use these macros to make defining attributes easier. See include/linux/device.h
77265 @@ -123,7 +125,8 @@ struct bin_attribute {
77266 char *, loff_t, size_t);
77267 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
77268 struct vm_area_struct *vma);
77269 -};
77270 +} __do_const;
77271 +typedef struct bin_attribute __no_const bin_attribute_no_const;
77272
77273 /**
77274 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
77275 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
77276 index 7faf933..9b85a0c 100644
77277 --- a/include/linux/sysrq.h
77278 +++ b/include/linux/sysrq.h
77279 @@ -16,6 +16,7 @@
77280
77281 #include <linux/errno.h>
77282 #include <linux/types.h>
77283 +#include <linux/compiler.h>
77284
77285 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
77286 #define SYSRQ_DEFAULT_ENABLE 1
77287 @@ -36,7 +37,7 @@ struct sysrq_key_op {
77288 char *help_msg;
77289 char *action_msg;
77290 int enable_mask;
77291 -};
77292 +} __do_const;
77293
77294 #ifdef CONFIG_MAGIC_SYSRQ
77295
77296 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
77297 index e7e0473..7989295 100644
77298 --- a/include/linux/thread_info.h
77299 +++ b/include/linux/thread_info.h
77300 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
77301 #error "no set_restore_sigmask() provided and default one won't work"
77302 #endif
77303
77304 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
77305 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
77306 +{
77307 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
77308 + if (!__builtin_constant_p(n))
77309 +#endif
77310 + __check_object_size(ptr, n, to_user);
77311 +}
77312 +
77313 #endif /* __KERNEL__ */
77314
77315 #endif /* _LINUX_THREAD_INFO_H */
77316 diff --git a/include/linux/tty.h b/include/linux/tty.h
77317 index 01ac30e..bf18a71 100644
77318 --- a/include/linux/tty.h
77319 +++ b/include/linux/tty.h
77320 @@ -194,7 +194,7 @@ struct tty_port {
77321 const struct tty_port_operations *ops; /* Port operations */
77322 spinlock_t lock; /* Lock protecting tty field */
77323 int blocked_open; /* Waiting to open */
77324 - int count; /* Usage count */
77325 + atomic_t count; /* Usage count */
77326 wait_queue_head_t open_wait; /* Open waiters */
77327 wait_queue_head_t close_wait; /* Close waiters */
77328 wait_queue_head_t delta_msr_wait; /* Modem status change */
77329 @@ -547,7 +547,7 @@ extern int tty_port_open(struct tty_port *port,
77330 struct tty_struct *tty, struct file *filp);
77331 static inline int tty_port_users(struct tty_port *port)
77332 {
77333 - return port->count + port->blocked_open;
77334 + return atomic_read(&port->count) + port->blocked_open;
77335 }
77336
77337 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
77338 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
77339 index 756a609..b302dd6 100644
77340 --- a/include/linux/tty_driver.h
77341 +++ b/include/linux/tty_driver.h
77342 @@ -285,7 +285,7 @@ struct tty_operations {
77343 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
77344 #endif
77345 const struct file_operations *proc_fops;
77346 -};
77347 +} __do_const;
77348
77349 struct tty_driver {
77350 int magic; /* magic number for this structure */
77351 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
77352 index a1b0489..f02e17c 100644
77353 --- a/include/linux/tty_ldisc.h
77354 +++ b/include/linux/tty_ldisc.h
77355 @@ -198,7 +198,7 @@ struct tty_ldisc_ops {
77356
77357 struct module *owner;
77358
77359 - int refcount;
77360 + atomic_t refcount;
77361 };
77362
77363 struct tty_ldisc {
77364 diff --git a/include/linux/types.h b/include/linux/types.h
77365 index 4d118ba..c3ee9bf 100644
77366 --- a/include/linux/types.h
77367 +++ b/include/linux/types.h
77368 @@ -176,10 +176,26 @@ typedef struct {
77369 int counter;
77370 } atomic_t;
77371
77372 +#ifdef CONFIG_PAX_REFCOUNT
77373 +typedef struct {
77374 + int counter;
77375 +} atomic_unchecked_t;
77376 +#else
77377 +typedef atomic_t atomic_unchecked_t;
77378 +#endif
77379 +
77380 #ifdef CONFIG_64BIT
77381 typedef struct {
77382 long counter;
77383 } atomic64_t;
77384 +
77385 +#ifdef CONFIG_PAX_REFCOUNT
77386 +typedef struct {
77387 + long counter;
77388 +} atomic64_unchecked_t;
77389 +#else
77390 +typedef atomic64_t atomic64_unchecked_t;
77391 +#endif
77392 #endif
77393
77394 struct list_head {
77395 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
77396 index 5ca0951..ab496a5 100644
77397 --- a/include/linux/uaccess.h
77398 +++ b/include/linux/uaccess.h
77399 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
77400 long ret; \
77401 mm_segment_t old_fs = get_fs(); \
77402 \
77403 - set_fs(KERNEL_DS); \
77404 pagefault_disable(); \
77405 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
77406 - pagefault_enable(); \
77407 + set_fs(KERNEL_DS); \
77408 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
77409 set_fs(old_fs); \
77410 + pagefault_enable(); \
77411 ret; \
77412 })
77413
77414 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
77415 index 8e522cbc..aa8572d 100644
77416 --- a/include/linux/uidgid.h
77417 +++ b/include/linux/uidgid.h
77418 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
77419
77420 #endif /* CONFIG_USER_NS */
77421
77422 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
77423 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
77424 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
77425 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
77426 +
77427 #endif /* _LINUX_UIDGID_H */
77428 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
77429 index 99c1b4d..562e6f3 100644
77430 --- a/include/linux/unaligned/access_ok.h
77431 +++ b/include/linux/unaligned/access_ok.h
77432 @@ -4,34 +4,34 @@
77433 #include <linux/kernel.h>
77434 #include <asm/byteorder.h>
77435
77436 -static inline u16 get_unaligned_le16(const void *p)
77437 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
77438 {
77439 - return le16_to_cpup((__le16 *)p);
77440 + return le16_to_cpup((const __le16 *)p);
77441 }
77442
77443 -static inline u32 get_unaligned_le32(const void *p)
77444 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
77445 {
77446 - return le32_to_cpup((__le32 *)p);
77447 + return le32_to_cpup((const __le32 *)p);
77448 }
77449
77450 -static inline u64 get_unaligned_le64(const void *p)
77451 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
77452 {
77453 - return le64_to_cpup((__le64 *)p);
77454 + return le64_to_cpup((const __le64 *)p);
77455 }
77456
77457 -static inline u16 get_unaligned_be16(const void *p)
77458 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
77459 {
77460 - return be16_to_cpup((__be16 *)p);
77461 + return be16_to_cpup((const __be16 *)p);
77462 }
77463
77464 -static inline u32 get_unaligned_be32(const void *p)
77465 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
77466 {
77467 - return be32_to_cpup((__be32 *)p);
77468 + return be32_to_cpup((const __be32 *)p);
77469 }
77470
77471 -static inline u64 get_unaligned_be64(const void *p)
77472 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
77473 {
77474 - return be64_to_cpup((__be64 *)p);
77475 + return be64_to_cpup((const __be64 *)p);
77476 }
77477
77478 static inline void put_unaligned_le16(u16 val, void *p)
77479 diff --git a/include/linux/usb.h b/include/linux/usb.h
77480 index 0eec268..4496526 100644
77481 --- a/include/linux/usb.h
77482 +++ b/include/linux/usb.h
77483 @@ -560,7 +560,7 @@ struct usb_device {
77484 int maxchild;
77485
77486 u32 quirks;
77487 - atomic_t urbnum;
77488 + atomic_unchecked_t urbnum;
77489
77490 unsigned long active_duration;
77491
77492 @@ -1617,7 +1617,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
77493
77494 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
77495 __u8 request, __u8 requesttype, __u16 value, __u16 index,
77496 - void *data, __u16 size, int timeout);
77497 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
77498 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
77499 void *data, int len, int *actual_length, int timeout);
77500 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
77501 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
77502 index e452ba6..78f8e80 100644
77503 --- a/include/linux/usb/renesas_usbhs.h
77504 +++ b/include/linux/usb/renesas_usbhs.h
77505 @@ -39,7 +39,7 @@ enum {
77506 */
77507 struct renesas_usbhs_driver_callback {
77508 int (*notify_hotplug)(struct platform_device *pdev);
77509 -};
77510 +} __no_const;
77511
77512 /*
77513 * callback functions for platform
77514 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
77515 index 6f8fbcf..8259001 100644
77516 --- a/include/linux/vermagic.h
77517 +++ b/include/linux/vermagic.h
77518 @@ -25,9 +25,35 @@
77519 #define MODULE_ARCH_VERMAGIC ""
77520 #endif
77521
77522 +#ifdef CONFIG_PAX_REFCOUNT
77523 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
77524 +#else
77525 +#define MODULE_PAX_REFCOUNT ""
77526 +#endif
77527 +
77528 +#ifdef CONSTIFY_PLUGIN
77529 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
77530 +#else
77531 +#define MODULE_CONSTIFY_PLUGIN ""
77532 +#endif
77533 +
77534 +#ifdef STACKLEAK_PLUGIN
77535 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
77536 +#else
77537 +#define MODULE_STACKLEAK_PLUGIN ""
77538 +#endif
77539 +
77540 +#ifdef CONFIG_GRKERNSEC
77541 +#define MODULE_GRSEC "GRSEC "
77542 +#else
77543 +#define MODULE_GRSEC ""
77544 +#endif
77545 +
77546 #define VERMAGIC_STRING \
77547 UTS_RELEASE " " \
77548 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
77549 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
77550 - MODULE_ARCH_VERMAGIC
77551 + MODULE_ARCH_VERMAGIC \
77552 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
77553 + MODULE_GRSEC
77554
77555 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
77556 index 4b8a891..c20e936 100644
77557 --- a/include/linux/vmalloc.h
77558 +++ b/include/linux/vmalloc.h
77559 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
77560 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
77561 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
77562 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
77563 +
77564 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
77565 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
77566 +#endif
77567 +
77568 /* bits [20..32] reserved for arch specific ioremap internals */
77569
77570 /*
77571 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
77572 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
77573 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
77574 unsigned long start, unsigned long end, gfp_t gfp_mask,
77575 - pgprot_t prot, int node, const void *caller);
77576 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
77577 extern void vfree(const void *addr);
77578
77579 extern void *vmap(struct page **pages, unsigned int count,
77580 @@ -141,8 +146,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
77581 extern void free_vm_area(struct vm_struct *area);
77582
77583 /* for /dev/kmem */
77584 -extern long vread(char *buf, char *addr, unsigned long count);
77585 -extern long vwrite(char *buf, char *addr, unsigned long count);
77586 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
77587 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
77588
77589 /*
77590 * Internals. Dont't use..
77591 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
77592 index c586679..f06b389 100644
77593 --- a/include/linux/vmstat.h
77594 +++ b/include/linux/vmstat.h
77595 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
77596 /*
77597 * Zone based page accounting with per cpu differentials.
77598 */
77599 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77600 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77601
77602 static inline void zone_page_state_add(long x, struct zone *zone,
77603 enum zone_stat_item item)
77604 {
77605 - atomic_long_add(x, &zone->vm_stat[item]);
77606 - atomic_long_add(x, &vm_stat[item]);
77607 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
77608 + atomic_long_add_unchecked(x, &vm_stat[item]);
77609 }
77610
77611 static inline unsigned long global_page_state(enum zone_stat_item item)
77612 {
77613 - long x = atomic_long_read(&vm_stat[item]);
77614 + long x = atomic_long_read_unchecked(&vm_stat[item]);
77615 #ifdef CONFIG_SMP
77616 if (x < 0)
77617 x = 0;
77618 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
77619 static inline unsigned long zone_page_state(struct zone *zone,
77620 enum zone_stat_item item)
77621 {
77622 - long x = atomic_long_read(&zone->vm_stat[item]);
77623 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77624 #ifdef CONFIG_SMP
77625 if (x < 0)
77626 x = 0;
77627 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
77628 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
77629 enum zone_stat_item item)
77630 {
77631 - long x = atomic_long_read(&zone->vm_stat[item]);
77632 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
77633
77634 #ifdef CONFIG_SMP
77635 int cpu;
77636 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
77637
77638 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
77639 {
77640 - atomic_long_inc(&zone->vm_stat[item]);
77641 - atomic_long_inc(&vm_stat[item]);
77642 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
77643 + atomic_long_inc_unchecked(&vm_stat[item]);
77644 }
77645
77646 static inline void __inc_zone_page_state(struct page *page,
77647 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
77648
77649 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
77650 {
77651 - atomic_long_dec(&zone->vm_stat[item]);
77652 - atomic_long_dec(&vm_stat[item]);
77653 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
77654 + atomic_long_dec_unchecked(&vm_stat[item]);
77655 }
77656
77657 static inline void __dec_zone_page_state(struct page *page,
77658 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
77659 index fdbafc6..49dfe4f 100644
77660 --- a/include/linux/xattr.h
77661 +++ b/include/linux/xattr.h
77662 @@ -28,7 +28,7 @@ struct xattr_handler {
77663 size_t size, int handler_flags);
77664 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
77665 size_t size, int flags, int handler_flags);
77666 -};
77667 +} __do_const;
77668
77669 struct xattr {
77670 char *name;
77671 @@ -37,6 +37,9 @@ struct xattr {
77672 };
77673
77674 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
77675 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
77676 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
77677 +#endif
77678 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
77679 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
77680 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
77681 diff --git a/include/linux/yam.h b/include/linux/yam.h
77682 index 7fe2822..512cdc2 100644
77683 --- a/include/linux/yam.h
77684 +++ b/include/linux/yam.h
77685 @@ -77,6 +77,6 @@ struct yamdrv_ioctl_cfg {
77686
77687 struct yamdrv_ioctl_mcs {
77688 int cmd;
77689 - int bitrate;
77690 + unsigned int bitrate;
77691 unsigned char bits[YAM_FPGA_SIZE];
77692 };
77693 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
77694 index 9c5a6b4..09c9438 100644
77695 --- a/include/linux/zlib.h
77696 +++ b/include/linux/zlib.h
77697 @@ -31,6 +31,7 @@
77698 #define _ZLIB_H
77699
77700 #include <linux/zconf.h>
77701 +#include <linux/compiler.h>
77702
77703 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
77704 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
77705 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
77706
77707 /* basic functions */
77708
77709 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
77710 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
77711 /*
77712 Returns the number of bytes that needs to be allocated for a per-
77713 stream workspace with the specified parameters. A pointer to this
77714 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
77715 index c768c9f..bdcaa5a 100644
77716 --- a/include/media/v4l2-dev.h
77717 +++ b/include/media/v4l2-dev.h
77718 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
77719 int (*mmap) (struct file *, struct vm_area_struct *);
77720 int (*open) (struct file *);
77721 int (*release) (struct file *);
77722 -};
77723 +} __do_const;
77724
77725 /*
77726 * Newer version of video_device, handled by videodev2.c
77727 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
77728 index c9b1593..a572459 100644
77729 --- a/include/media/v4l2-device.h
77730 +++ b/include/media/v4l2-device.h
77731 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
77732 this function returns 0. If the name ends with a digit (e.g. cx18),
77733 then the name will be set to cx18-0 since cx180 looks really odd. */
77734 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
77735 - atomic_t *instance);
77736 + atomic_unchecked_t *instance);
77737
77738 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
77739 Since the parent disappears this ensures that v4l2_dev doesn't have an
77740 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
77741 index d9fa68f..45c88d1 100644
77742 --- a/include/net/9p/transport.h
77743 +++ b/include/net/9p/transport.h
77744 @@ -63,7 +63,7 @@ struct p9_trans_module {
77745 int (*cancelled)(struct p9_client *, struct p9_req_t *req);
77746 int (*zc_request)(struct p9_client *, struct p9_req_t *,
77747 char *, char *, int , int, int, int);
77748 -};
77749 +} __do_const;
77750
77751 void v9fs_register_trans(struct p9_trans_module *m);
77752 void v9fs_unregister_trans(struct p9_trans_module *m);
77753 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
77754 index 1a966af..2767cf6 100644
77755 --- a/include/net/bluetooth/l2cap.h
77756 +++ b/include/net/bluetooth/l2cap.h
77757 @@ -551,7 +551,7 @@ struct l2cap_ops {
77758 void (*defer) (struct l2cap_chan *chan);
77759 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
77760 unsigned long len, int nb);
77761 -};
77762 +} __do_const;
77763
77764 struct l2cap_conn {
77765 struct hci_conn *hcon;
77766 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
77767 index f2ae33d..c457cf0 100644
77768 --- a/include/net/caif/cfctrl.h
77769 +++ b/include/net/caif/cfctrl.h
77770 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
77771 void (*radioset_rsp)(void);
77772 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
77773 struct cflayer *client_layer);
77774 -};
77775 +} __no_const;
77776
77777 /* Link Setup Parameters for CAIF-Links. */
77778 struct cfctrl_link_param {
77779 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
77780 struct cfctrl {
77781 struct cfsrvl serv;
77782 struct cfctrl_rsp res;
77783 - atomic_t req_seq_no;
77784 - atomic_t rsp_seq_no;
77785 + atomic_unchecked_t req_seq_no;
77786 + atomic_unchecked_t rsp_seq_no;
77787 struct list_head list;
77788 /* Protects from simultaneous access to first_req list */
77789 spinlock_t info_list_lock;
77790 diff --git a/include/net/flow.h b/include/net/flow.h
77791 index 628e11b..4c475df 100644
77792 --- a/include/net/flow.h
77793 +++ b/include/net/flow.h
77794 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
77795
77796 extern void flow_cache_flush(void);
77797 extern void flow_cache_flush_deferred(void);
77798 -extern atomic_t flow_cache_genid;
77799 +extern atomic_unchecked_t flow_cache_genid;
77800
77801 #endif
77802 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
77803 index 8e0b6c8..73cf605 100644
77804 --- a/include/net/genetlink.h
77805 +++ b/include/net/genetlink.h
77806 @@ -120,7 +120,7 @@ struct genl_ops {
77807 struct netlink_callback *cb);
77808 int (*done)(struct netlink_callback *cb);
77809 struct list_head ops_list;
77810 -};
77811 +} __do_const;
77812
77813 extern int __genl_register_family(struct genl_family *family);
77814
77815 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
77816 index 734d9b5..48a9a4b 100644
77817 --- a/include/net/gro_cells.h
77818 +++ b/include/net/gro_cells.h
77819 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
77820 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
77821
77822 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
77823 - atomic_long_inc(&dev->rx_dropped);
77824 + atomic_long_inc_unchecked(&dev->rx_dropped);
77825 kfree_skb(skb);
77826 return;
77827 }
77828 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
77829 index de2c785..0588a6b 100644
77830 --- a/include/net/inet_connection_sock.h
77831 +++ b/include/net/inet_connection_sock.h
77832 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
77833 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
77834 int (*bind_conflict)(const struct sock *sk,
77835 const struct inet_bind_bucket *tb, bool relax);
77836 -};
77837 +} __do_const;
77838
77839 /** inet_connection_sock - INET connection oriented sock
77840 *
77841 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
77842 index 53f464d..0bd0b49 100644
77843 --- a/include/net/inetpeer.h
77844 +++ b/include/net/inetpeer.h
77845 @@ -47,8 +47,8 @@ struct inet_peer {
77846 */
77847 union {
77848 struct {
77849 - atomic_t rid; /* Frag reception counter */
77850 - atomic_t ip_id_count; /* IP ID for the next packet */
77851 + atomic_unchecked_t rid; /* Frag reception counter */
77852 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
77853 };
77854 struct rcu_head rcu;
77855 struct inet_peer *gc_next;
77856 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
77857 /* can be called with or without local BH being disabled */
77858 static inline int inet_getid(struct inet_peer *p, int more)
77859 {
77860 - int old, new;
77861 + int id;
77862 more++;
77863 inet_peer_refcheck(p);
77864 - do {
77865 - old = atomic_read(&p->ip_id_count);
77866 - new = old + more;
77867 - if (!new)
77868 - new = 1;
77869 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
77870 - return new;
77871 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
77872 + if (!id)
77873 + id = atomic_inc_return_unchecked(&p->ip_id_count);
77874 + return id;
77875 }
77876
77877 #endif /* _NET_INETPEER_H */
77878 diff --git a/include/net/ip.h b/include/net/ip.h
77879 index edfa591..a643b82 100644
77880 --- a/include/net/ip.h
77881 +++ b/include/net/ip.h
77882 @@ -202,7 +202,7 @@ extern struct local_ports {
77883 } sysctl_local_ports;
77884 extern void inet_get_local_port_range(int *low, int *high);
77885
77886 -extern unsigned long *sysctl_local_reserved_ports;
77887 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
77888 static inline int inet_is_reserved_local_port(int port)
77889 {
77890 return test_bit(port, sysctl_local_reserved_ports);
77891 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
77892 index cbf2be3..3683f6d 100644
77893 --- a/include/net/ip_fib.h
77894 +++ b/include/net/ip_fib.h
77895 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
77896
77897 #define FIB_RES_SADDR(net, res) \
77898 ((FIB_RES_NH(res).nh_saddr_genid == \
77899 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
77900 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
77901 FIB_RES_NH(res).nh_saddr : \
77902 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
77903 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
77904 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
77905 index f0d70f0..185f15b 100644
77906 --- a/include/net/ip_vs.h
77907 +++ b/include/net/ip_vs.h
77908 @@ -588,7 +588,7 @@ struct ip_vs_conn {
77909 struct ip_vs_conn *control; /* Master control connection */
77910 atomic_t n_control; /* Number of controlled ones */
77911 struct ip_vs_dest *dest; /* real server */
77912 - atomic_t in_pkts; /* incoming packet counter */
77913 + atomic_unchecked_t in_pkts; /* incoming packet counter */
77914
77915 /* packet transmitter for different forwarding methods. If it
77916 mangles the packet, it must return NF_DROP or better NF_STOLEN,
77917 @@ -737,7 +737,7 @@ struct ip_vs_dest {
77918 __be16 port; /* port number of the server */
77919 union nf_inet_addr addr; /* IP address of the server */
77920 volatile unsigned int flags; /* dest status flags */
77921 - atomic_t conn_flags; /* flags to copy to conn */
77922 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
77923 atomic_t weight; /* server weight */
77924
77925 atomic_t refcnt; /* reference counter */
77926 @@ -993,11 +993,11 @@ struct netns_ipvs {
77927 /* ip_vs_lblc */
77928 int sysctl_lblc_expiration;
77929 struct ctl_table_header *lblc_ctl_header;
77930 - struct ctl_table *lblc_ctl_table;
77931 + ctl_table_no_const *lblc_ctl_table;
77932 /* ip_vs_lblcr */
77933 int sysctl_lblcr_expiration;
77934 struct ctl_table_header *lblcr_ctl_header;
77935 - struct ctl_table *lblcr_ctl_table;
77936 + ctl_table_no_const *lblcr_ctl_table;
77937 /* ip_vs_est */
77938 struct list_head est_list; /* estimator list */
77939 spinlock_t est_lock;
77940 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
77941 index 80ffde3..968b0f4 100644
77942 --- a/include/net/irda/ircomm_tty.h
77943 +++ b/include/net/irda/ircomm_tty.h
77944 @@ -35,6 +35,7 @@
77945 #include <linux/termios.h>
77946 #include <linux/timer.h>
77947 #include <linux/tty.h> /* struct tty_struct */
77948 +#include <asm/local.h>
77949
77950 #include <net/irda/irias_object.h>
77951 #include <net/irda/ircomm_core.h>
77952 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
77953 index 714cc9a..ea05f3e 100644
77954 --- a/include/net/iucv/af_iucv.h
77955 +++ b/include/net/iucv/af_iucv.h
77956 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
77957 struct iucv_sock_list {
77958 struct hlist_head head;
77959 rwlock_t lock;
77960 - atomic_t autobind_name;
77961 + atomic_unchecked_t autobind_name;
77962 };
77963
77964 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
77965 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
77966 index df83f69..9b640b8 100644
77967 --- a/include/net/llc_c_ac.h
77968 +++ b/include/net/llc_c_ac.h
77969 @@ -87,7 +87,7 @@
77970 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
77971 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
77972
77973 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77974 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
77975
77976 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
77977 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
77978 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
77979 index 6ca3113..f8026dd 100644
77980 --- a/include/net/llc_c_ev.h
77981 +++ b/include/net/llc_c_ev.h
77982 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
77983 return (struct llc_conn_state_ev *)skb->cb;
77984 }
77985
77986 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77987 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77988 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
77989 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
77990
77991 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
77992 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
77993 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
77994 index 0e79cfb..f46db31 100644
77995 --- a/include/net/llc_c_st.h
77996 +++ b/include/net/llc_c_st.h
77997 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
77998 u8 next_state;
77999 llc_conn_ev_qfyr_t *ev_qualifiers;
78000 llc_conn_action_t *ev_actions;
78001 -};
78002 +} __do_const;
78003
78004 struct llc_conn_state {
78005 u8 current_state;
78006 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
78007 index 37a3bbd..55a4241 100644
78008 --- a/include/net/llc_s_ac.h
78009 +++ b/include/net/llc_s_ac.h
78010 @@ -23,7 +23,7 @@
78011 #define SAP_ACT_TEST_IND 9
78012
78013 /* All action functions must look like this */
78014 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78015 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
78016
78017 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
78018 struct sk_buff *skb);
78019 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
78020 index 567c681..cd73ac0 100644
78021 --- a/include/net/llc_s_st.h
78022 +++ b/include/net/llc_s_st.h
78023 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
78024 llc_sap_ev_t ev;
78025 u8 next_state;
78026 llc_sap_action_t *ev_actions;
78027 -};
78028 +} __do_const;
78029
78030 struct llc_sap_state {
78031 u8 curr_state;
78032 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
78033 index 551ba6a..11c99c1 100644
78034 --- a/include/net/mac80211.h
78035 +++ b/include/net/mac80211.h
78036 @@ -4221,7 +4221,7 @@ struct rate_control_ops {
78037 void (*add_sta_debugfs)(void *priv, void *priv_sta,
78038 struct dentry *dir);
78039 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
78040 -};
78041 +} __do_const;
78042
78043 static inline int rate_supported(struct ieee80211_sta *sta,
78044 enum ieee80211_band band,
78045 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
78046 index 7e748ad..5c6229b 100644
78047 --- a/include/net/neighbour.h
78048 +++ b/include/net/neighbour.h
78049 @@ -123,7 +123,7 @@ struct neigh_ops {
78050 void (*error_report)(struct neighbour *, struct sk_buff *);
78051 int (*output)(struct neighbour *, struct sk_buff *);
78052 int (*connected_output)(struct neighbour *, struct sk_buff *);
78053 -};
78054 +} __do_const;
78055
78056 struct pneigh_entry {
78057 struct pneigh_entry *next;
78058 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
78059 index 84e37b1..8eba19a 100644
78060 --- a/include/net/net_namespace.h
78061 +++ b/include/net/net_namespace.h
78062 @@ -119,8 +119,8 @@ struct net {
78063 struct netns_ipvs *ipvs;
78064 #endif
78065 struct sock *diag_nlsk;
78066 - atomic_t rt_genid;
78067 - atomic_t fnhe_genid;
78068 + atomic_unchecked_t rt_genid;
78069 + atomic_unchecked_t fnhe_genid;
78070 };
78071
78072 /*
78073 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
78074 #define __net_init __init
78075 #define __net_exit __exit_refok
78076 #define __net_initdata __initdata
78077 +#ifdef CONSTIFY_PLUGIN
78078 #define __net_initconst __initconst
78079 +#else
78080 +#define __net_initconst __initdata
78081 +#endif
78082 #endif
78083
78084 struct pernet_operations {
78085 @@ -287,7 +291,7 @@ struct pernet_operations {
78086 void (*exit_batch)(struct list_head *net_exit_list);
78087 int *id;
78088 size_t size;
78089 -};
78090 +} __do_const;
78091
78092 /*
78093 * Use these carefully. If you implement a network device and it
78094 @@ -335,22 +339,22 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
78095
78096 static inline int rt_genid(struct net *net)
78097 {
78098 - return atomic_read(&net->rt_genid);
78099 + return atomic_read_unchecked(&net->rt_genid);
78100 }
78101
78102 static inline void rt_genid_bump(struct net *net)
78103 {
78104 - atomic_inc(&net->rt_genid);
78105 + atomic_inc_unchecked(&net->rt_genid);
78106 }
78107
78108 static inline int fnhe_genid(struct net *net)
78109 {
78110 - return atomic_read(&net->fnhe_genid);
78111 + return atomic_read_unchecked(&net->fnhe_genid);
78112 }
78113
78114 static inline void fnhe_genid_bump(struct net *net)
78115 {
78116 - atomic_inc(&net->fnhe_genid);
78117 + atomic_inc_unchecked(&net->fnhe_genid);
78118 }
78119
78120 #endif /* __NET_NET_NAMESPACE_H */
78121 diff --git a/include/net/netdma.h b/include/net/netdma.h
78122 index 8ba8ce2..99b7fff 100644
78123 --- a/include/net/netdma.h
78124 +++ b/include/net/netdma.h
78125 @@ -24,7 +24,7 @@
78126 #include <linux/dmaengine.h>
78127 #include <linux/skbuff.h>
78128
78129 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78130 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
78131 struct sk_buff *skb, int offset, struct iovec *to,
78132 size_t len, struct dma_pinned_list *pinned_list);
78133
78134 diff --git a/include/net/netlink.h b/include/net/netlink.h
78135 index 9690b0f..87aded7 100644
78136 --- a/include/net/netlink.h
78137 +++ b/include/net/netlink.h
78138 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
78139 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
78140 {
78141 if (mark)
78142 - skb_trim(skb, (unsigned char *) mark - skb->data);
78143 + skb_trim(skb, (const unsigned char *) mark - skb->data);
78144 }
78145
78146 /**
78147 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
78148 index c9c0c53..53f24c3 100644
78149 --- a/include/net/netns/conntrack.h
78150 +++ b/include/net/netns/conntrack.h
78151 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
78152 struct nf_proto_net {
78153 #ifdef CONFIG_SYSCTL
78154 struct ctl_table_header *ctl_table_header;
78155 - struct ctl_table *ctl_table;
78156 + ctl_table_no_const *ctl_table;
78157 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
78158 struct ctl_table_header *ctl_compat_header;
78159 - struct ctl_table *ctl_compat_table;
78160 + ctl_table_no_const *ctl_compat_table;
78161 #endif
78162 #endif
78163 unsigned int users;
78164 @@ -58,7 +58,7 @@ struct nf_ip_net {
78165 struct nf_icmp_net icmpv6;
78166 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
78167 struct ctl_table_header *ctl_table_header;
78168 - struct ctl_table *ctl_table;
78169 + ctl_table_no_const *ctl_table;
78170 #endif
78171 };
78172
78173 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
78174 index 2ba9de8..47bd6c7 100644
78175 --- a/include/net/netns/ipv4.h
78176 +++ b/include/net/netns/ipv4.h
78177 @@ -67,7 +67,7 @@ struct netns_ipv4 {
78178 kgid_t sysctl_ping_group_range[2];
78179 long sysctl_tcp_mem[3];
78180
78181 - atomic_t dev_addr_genid;
78182 + atomic_unchecked_t dev_addr_genid;
78183
78184 #ifdef CONFIG_IP_MROUTE
78185 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
78186 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
78187 index 005e2c2..023d340 100644
78188 --- a/include/net/netns/ipv6.h
78189 +++ b/include/net/netns/ipv6.h
78190 @@ -71,7 +71,7 @@ struct netns_ipv6 {
78191 struct fib_rules_ops *mr6_rules_ops;
78192 #endif
78193 #endif
78194 - atomic_t dev_addr_genid;
78195 + atomic_unchecked_t dev_addr_genid;
78196 };
78197
78198 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
78199 diff --git a/include/net/ping.h b/include/net/ping.h
78200 index 5db0224..0d65365 100644
78201 --- a/include/net/ping.h
78202 +++ b/include/net/ping.h
78203 @@ -55,7 +55,7 @@ struct ping_iter_state {
78204 extern struct proto ping_prot;
78205 extern struct ping_table ping_table;
78206 #if IS_ENABLED(CONFIG_IPV6)
78207 -extern struct pingv6_ops pingv6_ops;
78208 +extern struct pingv6_ops *pingv6_ops;
78209 #endif
78210
78211 struct pingfakehdr {
78212 diff --git a/include/net/protocol.h b/include/net/protocol.h
78213 index 047c047..b9dad15 100644
78214 --- a/include/net/protocol.h
78215 +++ b/include/net/protocol.h
78216 @@ -44,7 +44,7 @@ struct net_protocol {
78217 void (*err_handler)(struct sk_buff *skb, u32 info);
78218 unsigned int no_policy:1,
78219 netns_ok:1;
78220 -};
78221 +} __do_const;
78222
78223 #if IS_ENABLED(CONFIG_IPV6)
78224 struct inet6_protocol {
78225 @@ -57,7 +57,7 @@ struct inet6_protocol {
78226 u8 type, u8 code, int offset,
78227 __be32 info);
78228 unsigned int flags; /* INET6_PROTO_xxx */
78229 -};
78230 +} __do_const;
78231
78232 #define INET6_PROTO_NOPOLICY 0x1
78233 #define INET6_PROTO_FINAL 0x2
78234 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
78235 index 7026648..584cc8c 100644
78236 --- a/include/net/rtnetlink.h
78237 +++ b/include/net/rtnetlink.h
78238 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
78239 const struct net_device *dev);
78240 unsigned int (*get_num_tx_queues)(void);
78241 unsigned int (*get_num_rx_queues)(void);
78242 -};
78243 +} __do_const;
78244
78245 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
78246 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
78247 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
78248 index 2a82d13..62a31c2 100644
78249 --- a/include/net/sctp/sm.h
78250 +++ b/include/net/sctp/sm.h
78251 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
78252 typedef struct {
78253 sctp_state_fn_t *fn;
78254 const char *name;
78255 -} sctp_sm_table_entry_t;
78256 +} __do_const sctp_sm_table_entry_t;
78257
78258 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
78259 * currently in use.
78260 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
78261 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
78262
78263 /* Extern declarations for major data structures. */
78264 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78265 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
78266
78267
78268 /* Get the size of a DATA chunk payload. */
78269 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
78270 index e745c92..3641448 100644
78271 --- a/include/net/sctp/structs.h
78272 +++ b/include/net/sctp/structs.h
78273 @@ -516,7 +516,7 @@ struct sctp_pf {
78274 struct sctp_association *asoc);
78275 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
78276 struct sctp_af *af;
78277 -};
78278 +} __do_const;
78279
78280
78281 /* Structure to track chunk fragments that have been acked, but peer
78282 diff --git a/include/net/sock.h b/include/net/sock.h
78283 index 31d5cfb..9ee0602 100644
78284 --- a/include/net/sock.h
78285 +++ b/include/net/sock.h
78286 @@ -331,7 +331,7 @@ struct sock {
78287 unsigned int sk_napi_id;
78288 unsigned int sk_ll_usec;
78289 #endif
78290 - atomic_t sk_drops;
78291 + atomic_unchecked_t sk_drops;
78292 int sk_rcvbuf;
78293
78294 struct sk_filter __rcu *sk_filter;
78295 @@ -1803,7 +1803,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
78296 }
78297
78298 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
78299 - char __user *from, char *to,
78300 + char __user *from, unsigned char *to,
78301 int copy, int offset)
78302 {
78303 if (skb->ip_summed == CHECKSUM_NONE) {
78304 @@ -2065,7 +2065,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
78305 }
78306 }
78307
78308 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78309 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
78310
78311 /**
78312 * sk_page_frag - return an appropriate page_frag
78313 diff --git a/include/net/tcp.h b/include/net/tcp.h
78314 index d198005..c974a393 100644
78315 --- a/include/net/tcp.h
78316 +++ b/include/net/tcp.h
78317 @@ -521,7 +521,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
78318 extern void tcp_xmit_retransmit_queue(struct sock *);
78319 extern void tcp_simple_retransmit(struct sock *);
78320 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
78321 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78322 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
78323
78324 extern void tcp_send_probe0(struct sock *);
78325 extern void tcp_send_partial(struct sock *);
78326 @@ -694,8 +694,8 @@ struct tcp_skb_cb {
78327 struct inet6_skb_parm h6;
78328 #endif
78329 } header; /* For incoming frames */
78330 - __u32 seq; /* Starting sequence number */
78331 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
78332 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
78333 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
78334 __u32 when; /* used to compute rtt's */
78335 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
78336
78337 @@ -709,7 +709,7 @@ struct tcp_skb_cb {
78338
78339 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
78340 /* 1 byte hole */
78341 - __u32 ack_seq; /* Sequence number ACK'd */
78342 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
78343 };
78344
78345 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
78346 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
78347 index e823786..53b0608 100644
78348 --- a/include/net/xfrm.h
78349 +++ b/include/net/xfrm.h
78350 @@ -287,7 +287,6 @@ struct xfrm_dst;
78351 struct xfrm_policy_afinfo {
78352 unsigned short family;
78353 struct dst_ops *dst_ops;
78354 - void (*garbage_collect)(struct net *net);
78355 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
78356 const xfrm_address_t *saddr,
78357 const xfrm_address_t *daddr);
78358 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
78359 struct net_device *dev,
78360 const struct flowi *fl);
78361 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
78362 -};
78363 +} __do_const;
78364
78365 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
78366 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
78367 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
78368 int (*transport_finish)(struct sk_buff *skb,
78369 int async);
78370 void (*local_error)(struct sk_buff *skb, u32 mtu);
78371 -};
78372 +} __do_const;
78373
78374 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
78375 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
78376 @@ -427,7 +426,7 @@ struct xfrm_mode {
78377 struct module *owner;
78378 unsigned int encap;
78379 int flags;
78380 -};
78381 +} __do_const;
78382
78383 /* Flags for xfrm_mode. */
78384 enum {
78385 @@ -524,7 +523,7 @@ struct xfrm_policy {
78386 struct timer_list timer;
78387
78388 struct flow_cache_object flo;
78389 - atomic_t genid;
78390 + atomic_unchecked_t genid;
78391 u32 priority;
78392 u32 index;
78393 struct xfrm_mark mark;
78394 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
78395 }
78396
78397 extern void xfrm_garbage_collect(struct net *net);
78398 +extern void xfrm_garbage_collect_deferred(struct net *net);
78399
78400 #else
78401
78402 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
78403 static inline void xfrm_garbage_collect(struct net *net)
78404 {
78405 }
78406 +static inline void xfrm_garbage_collect_deferred(struct net *net)
78407 +{
78408 +}
78409 #endif
78410
78411 static __inline__
78412 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
78413 index 1a046b1..ee0bef0 100644
78414 --- a/include/rdma/iw_cm.h
78415 +++ b/include/rdma/iw_cm.h
78416 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
78417 int backlog);
78418
78419 int (*destroy_listen)(struct iw_cm_id *cm_id);
78420 -};
78421 +} __no_const;
78422
78423 /**
78424 * iw_create_cm_id - Create an IW CM identifier.
78425 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
78426 index e1379b4..67eafbe 100644
78427 --- a/include/scsi/libfc.h
78428 +++ b/include/scsi/libfc.h
78429 @@ -762,6 +762,7 @@ struct libfc_function_template {
78430 */
78431 void (*disc_stop_final) (struct fc_lport *);
78432 };
78433 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
78434
78435 /**
78436 * struct fc_disc - Discovery context
78437 @@ -866,7 +867,7 @@ struct fc_lport {
78438 struct fc_vport *vport;
78439
78440 /* Operational Information */
78441 - struct libfc_function_template tt;
78442 + libfc_function_template_no_const tt;
78443 u8 link_up;
78444 u8 qfull;
78445 enum fc_lport_state state;
78446 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
78447 index a44954c..5da04b2 100644
78448 --- a/include/scsi/scsi_device.h
78449 +++ b/include/scsi/scsi_device.h
78450 @@ -172,9 +172,9 @@ struct scsi_device {
78451 unsigned int max_device_blocked; /* what device_blocked counts down from */
78452 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
78453
78454 - atomic_t iorequest_cnt;
78455 - atomic_t iodone_cnt;
78456 - atomic_t ioerr_cnt;
78457 + atomic_unchecked_t iorequest_cnt;
78458 + atomic_unchecked_t iodone_cnt;
78459 + atomic_unchecked_t ioerr_cnt;
78460
78461 struct device sdev_gendev,
78462 sdev_dev;
78463 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
78464 index b797e8f..8e2c3aa 100644
78465 --- a/include/scsi/scsi_transport_fc.h
78466 +++ b/include/scsi/scsi_transport_fc.h
78467 @@ -751,7 +751,8 @@ struct fc_function_template {
78468 unsigned long show_host_system_hostname:1;
78469
78470 unsigned long disable_target_scan:1;
78471 -};
78472 +} __do_const;
78473 +typedef struct fc_function_template __no_const fc_function_template_no_const;
78474
78475
78476 /**
78477 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
78478 index 9031a26..750d592 100644
78479 --- a/include/sound/compress_driver.h
78480 +++ b/include/sound/compress_driver.h
78481 @@ -128,7 +128,7 @@ struct snd_compr_ops {
78482 struct snd_compr_caps *caps);
78483 int (*get_codec_caps) (struct snd_compr_stream *stream,
78484 struct snd_compr_codec_caps *codec);
78485 -};
78486 +} __no_const;
78487
78488 /**
78489 * struct snd_compr: Compressed device
78490 diff --git a/include/sound/soc.h b/include/sound/soc.h
78491 index 6eabee7..58afb50 100644
78492 --- a/include/sound/soc.h
78493 +++ b/include/sound/soc.h
78494 @@ -783,7 +783,7 @@ struct snd_soc_codec_driver {
78495 /* probe ordering - for components with runtime dependencies */
78496 int probe_order;
78497 int remove_order;
78498 -};
78499 +} __do_const;
78500
78501 /* SoC platform interface */
78502 struct snd_soc_platform_driver {
78503 @@ -829,7 +829,7 @@ struct snd_soc_platform_driver {
78504 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
78505 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
78506 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
78507 -};
78508 +} __do_const;
78509
78510 struct snd_soc_platform {
78511 const char *name;
78512 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
78513 index e34fc90..ecefa2c 100644
78514 --- a/include/target/target_core_base.h
78515 +++ b/include/target/target_core_base.h
78516 @@ -643,7 +643,7 @@ struct se_device {
78517 spinlock_t stats_lock;
78518 /* Active commands on this virtual SE device */
78519 atomic_t simple_cmds;
78520 - atomic_t dev_ordered_id;
78521 + atomic_unchecked_t dev_ordered_id;
78522 atomic_t dev_ordered_sync;
78523 atomic_t dev_qf_count;
78524 int export_count;
78525 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
78526 new file mode 100644
78527 index 0000000..fb634b7
78528 --- /dev/null
78529 +++ b/include/trace/events/fs.h
78530 @@ -0,0 +1,53 @@
78531 +#undef TRACE_SYSTEM
78532 +#define TRACE_SYSTEM fs
78533 +
78534 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
78535 +#define _TRACE_FS_H
78536 +
78537 +#include <linux/fs.h>
78538 +#include <linux/tracepoint.h>
78539 +
78540 +TRACE_EVENT(do_sys_open,
78541 +
78542 + TP_PROTO(const char *filename, int flags, int mode),
78543 +
78544 + TP_ARGS(filename, flags, mode),
78545 +
78546 + TP_STRUCT__entry(
78547 + __string( filename, filename )
78548 + __field( int, flags )
78549 + __field( int, mode )
78550 + ),
78551 +
78552 + TP_fast_assign(
78553 + __assign_str(filename, filename);
78554 + __entry->flags = flags;
78555 + __entry->mode = mode;
78556 + ),
78557 +
78558 + TP_printk("\"%s\" %x %o",
78559 + __get_str(filename), __entry->flags, __entry->mode)
78560 +);
78561 +
78562 +TRACE_EVENT(open_exec,
78563 +
78564 + TP_PROTO(const char *filename),
78565 +
78566 + TP_ARGS(filename),
78567 +
78568 + TP_STRUCT__entry(
78569 + __string( filename, filename )
78570 + ),
78571 +
78572 + TP_fast_assign(
78573 + __assign_str(filename, filename);
78574 + ),
78575 +
78576 + TP_printk("\"%s\"",
78577 + __get_str(filename))
78578 +);
78579 +
78580 +#endif /* _TRACE_FS_H */
78581 +
78582 +/* This part must be outside protection */
78583 +#include <trace/define_trace.h>
78584 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
78585 index 1c09820..7f5ec79 100644
78586 --- a/include/trace/events/irq.h
78587 +++ b/include/trace/events/irq.h
78588 @@ -36,7 +36,7 @@ struct softirq_action;
78589 */
78590 TRACE_EVENT(irq_handler_entry,
78591
78592 - TP_PROTO(int irq, struct irqaction *action),
78593 + TP_PROTO(int irq, const struct irqaction *action),
78594
78595 TP_ARGS(irq, action),
78596
78597 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
78598 */
78599 TRACE_EVENT(irq_handler_exit,
78600
78601 - TP_PROTO(int irq, struct irqaction *action, int ret),
78602 + TP_PROTO(int irq, const struct irqaction *action, int ret),
78603
78604 TP_ARGS(irq, action, ret),
78605
78606 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
78607 index 7caf44c..23c6f27 100644
78608 --- a/include/uapi/linux/a.out.h
78609 +++ b/include/uapi/linux/a.out.h
78610 @@ -39,6 +39,14 @@ enum machine_type {
78611 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
78612 };
78613
78614 +/* Constants for the N_FLAGS field */
78615 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78616 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
78617 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
78618 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
78619 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78620 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78621 +
78622 #if !defined (N_MAGIC)
78623 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
78624 #endif
78625 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
78626 index d876736..ccce5c0 100644
78627 --- a/include/uapi/linux/byteorder/little_endian.h
78628 +++ b/include/uapi/linux/byteorder/little_endian.h
78629 @@ -42,51 +42,51 @@
78630
78631 static inline __le64 __cpu_to_le64p(const __u64 *p)
78632 {
78633 - return (__force __le64)*p;
78634 + return (__force const __le64)*p;
78635 }
78636 -static inline __u64 __le64_to_cpup(const __le64 *p)
78637 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
78638 {
78639 - return (__force __u64)*p;
78640 + return (__force const __u64)*p;
78641 }
78642 static inline __le32 __cpu_to_le32p(const __u32 *p)
78643 {
78644 - return (__force __le32)*p;
78645 + return (__force const __le32)*p;
78646 }
78647 static inline __u32 __le32_to_cpup(const __le32 *p)
78648 {
78649 - return (__force __u32)*p;
78650 + return (__force const __u32)*p;
78651 }
78652 static inline __le16 __cpu_to_le16p(const __u16 *p)
78653 {
78654 - return (__force __le16)*p;
78655 + return (__force const __le16)*p;
78656 }
78657 static inline __u16 __le16_to_cpup(const __le16 *p)
78658 {
78659 - return (__force __u16)*p;
78660 + return (__force const __u16)*p;
78661 }
78662 static inline __be64 __cpu_to_be64p(const __u64 *p)
78663 {
78664 - return (__force __be64)__swab64p(p);
78665 + return (__force const __be64)__swab64p(p);
78666 }
78667 static inline __u64 __be64_to_cpup(const __be64 *p)
78668 {
78669 - return __swab64p((__u64 *)p);
78670 + return __swab64p((const __u64 *)p);
78671 }
78672 static inline __be32 __cpu_to_be32p(const __u32 *p)
78673 {
78674 - return (__force __be32)__swab32p(p);
78675 + return (__force const __be32)__swab32p(p);
78676 }
78677 -static inline __u32 __be32_to_cpup(const __be32 *p)
78678 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
78679 {
78680 - return __swab32p((__u32 *)p);
78681 + return __swab32p((const __u32 *)p);
78682 }
78683 static inline __be16 __cpu_to_be16p(const __u16 *p)
78684 {
78685 - return (__force __be16)__swab16p(p);
78686 + return (__force const __be16)__swab16p(p);
78687 }
78688 static inline __u16 __be16_to_cpup(const __be16 *p)
78689 {
78690 - return __swab16p((__u16 *)p);
78691 + return __swab16p((const __u16 *)p);
78692 }
78693 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
78694 #define __le64_to_cpus(x) do { (void)(x); } while (0)
78695 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
78696 index ef6103b..d4e65dd 100644
78697 --- a/include/uapi/linux/elf.h
78698 +++ b/include/uapi/linux/elf.h
78699 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
78700 #define PT_GNU_EH_FRAME 0x6474e550
78701
78702 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
78703 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
78704 +
78705 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
78706 +
78707 +/* Constants for the e_flags field */
78708 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
78709 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
78710 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
78711 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
78712 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
78713 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
78714
78715 /*
78716 * Extended Numbering
78717 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
78718 #define DT_DEBUG 21
78719 #define DT_TEXTREL 22
78720 #define DT_JMPREL 23
78721 +#define DT_FLAGS 30
78722 + #define DF_TEXTREL 0x00000004
78723 #define DT_ENCODING 32
78724 #define OLD_DT_LOOS 0x60000000
78725 #define DT_LOOS 0x6000000d
78726 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
78727 #define PF_W 0x2
78728 #define PF_X 0x1
78729
78730 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
78731 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
78732 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
78733 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
78734 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
78735 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
78736 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
78737 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
78738 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
78739 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
78740 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
78741 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
78742 +
78743 typedef struct elf32_phdr{
78744 Elf32_Word p_type;
78745 Elf32_Off p_offset;
78746 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
78747 #define EI_OSABI 7
78748 #define EI_PAD 8
78749
78750 +#define EI_PAX 14
78751 +
78752 #define ELFMAG0 0x7f /* EI_MAG */
78753 #define ELFMAG1 'E'
78754 #define ELFMAG2 'L'
78755 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
78756 index aa169c4..6a2771d 100644
78757 --- a/include/uapi/linux/personality.h
78758 +++ b/include/uapi/linux/personality.h
78759 @@ -30,6 +30,7 @@ enum {
78760 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
78761 ADDR_NO_RANDOMIZE | \
78762 ADDR_COMPAT_LAYOUT | \
78763 + ADDR_LIMIT_3GB | \
78764 MMAP_PAGE_ZERO)
78765
78766 /*
78767 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
78768 index 7530e74..e714828 100644
78769 --- a/include/uapi/linux/screen_info.h
78770 +++ b/include/uapi/linux/screen_info.h
78771 @@ -43,7 +43,8 @@ struct screen_info {
78772 __u16 pages; /* 0x32 */
78773 __u16 vesa_attributes; /* 0x34 */
78774 __u32 capabilities; /* 0x36 */
78775 - __u8 _reserved[6]; /* 0x3a */
78776 + __u16 vesapm_size; /* 0x3a */
78777 + __u8 _reserved[4]; /* 0x3c */
78778 } __attribute__((packed));
78779
78780 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
78781 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
78782 index 0e011eb..82681b1 100644
78783 --- a/include/uapi/linux/swab.h
78784 +++ b/include/uapi/linux/swab.h
78785 @@ -43,7 +43,7 @@
78786 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
78787 */
78788
78789 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
78790 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
78791 {
78792 #ifdef __HAVE_BUILTIN_BSWAP16__
78793 return __builtin_bswap16(val);
78794 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
78795 #endif
78796 }
78797
78798 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
78799 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
78800 {
78801 #ifdef __HAVE_BUILTIN_BSWAP32__
78802 return __builtin_bswap32(val);
78803 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
78804 #endif
78805 }
78806
78807 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
78808 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
78809 {
78810 #ifdef __HAVE_BUILTIN_BSWAP64__
78811 return __builtin_bswap64(val);
78812 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
78813 index 6d67213..8dab561 100644
78814 --- a/include/uapi/linux/sysctl.h
78815 +++ b/include/uapi/linux/sysctl.h
78816 @@ -155,7 +155,11 @@ enum
78817 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
78818 };
78819
78820 -
78821 +#ifdef CONFIG_PAX_SOFTMODE
78822 +enum {
78823 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
78824 +};
78825 +#endif
78826
78827 /* CTL_VM names: */
78828 enum
78829 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
78830 index e4629b9..6958086 100644
78831 --- a/include/uapi/linux/xattr.h
78832 +++ b/include/uapi/linux/xattr.h
78833 @@ -63,5 +63,9 @@
78834 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
78835 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
78836
78837 +/* User namespace */
78838 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
78839 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
78840 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
78841
78842 #endif /* _UAPI_LINUX_XATTR_H */
78843 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
78844 index f9466fa..f4e2b81 100644
78845 --- a/include/video/udlfb.h
78846 +++ b/include/video/udlfb.h
78847 @@ -53,10 +53,10 @@ struct dlfb_data {
78848 u32 pseudo_palette[256];
78849 int blank_mode; /*one of FB_BLANK_ */
78850 /* blit-only rendering path metrics, exposed through sysfs */
78851 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78852 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
78853 - atomic_t bytes_sent; /* to usb, after compression including overhead */
78854 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
78855 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
78856 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
78857 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
78858 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
78859 };
78860
78861 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
78862 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
78863 index 30f5362..8ed8ac9 100644
78864 --- a/include/video/uvesafb.h
78865 +++ b/include/video/uvesafb.h
78866 @@ -122,6 +122,7 @@ struct uvesafb_par {
78867 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
78868 u8 pmi_setpal; /* PMI for palette changes */
78869 u16 *pmi_base; /* protected mode interface location */
78870 + u8 *pmi_code; /* protected mode code location */
78871 void *pmi_start;
78872 void *pmi_pal;
78873 u8 *vbe_state_orig; /*
78874 diff --git a/init/Kconfig b/init/Kconfig
78875 index fed81b5..0d3b964 100644
78876 --- a/init/Kconfig
78877 +++ b/init/Kconfig
78878 @@ -1069,6 +1069,7 @@ endif # CGROUPS
78879
78880 config CHECKPOINT_RESTORE
78881 bool "Checkpoint/restore support" if EXPERT
78882 + depends on !GRKERNSEC
78883 default n
78884 help
78885 Enables additional kernel features in a sake of checkpoint/restore.
78886 @@ -1553,7 +1554,7 @@ config SLUB_DEBUG
78887
78888 config COMPAT_BRK
78889 bool "Disable heap randomization"
78890 - default y
78891 + default n
78892 help
78893 Randomizing heap placement makes heap exploits harder, but it
78894 also breaks ancient binaries (including anything libc5 based).
78895 @@ -1827,7 +1828,7 @@ config INIT_ALL_POSSIBLE
78896 config STOP_MACHINE
78897 bool
78898 default y
78899 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
78900 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
78901 help
78902 Need stop_machine() primitive.
78903
78904 diff --git a/init/Makefile b/init/Makefile
78905 index 7bc47ee..6da2dc7 100644
78906 --- a/init/Makefile
78907 +++ b/init/Makefile
78908 @@ -2,6 +2,9 @@
78909 # Makefile for the linux kernel.
78910 #
78911
78912 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
78913 +asflags-y := $(GCC_PLUGINS_AFLAGS)
78914 +
78915 obj-y := main.o version.o mounts.o
78916 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
78917 obj-y += noinitramfs.o
78918 diff --git a/init/do_mounts.c b/init/do_mounts.c
78919 index 816014c..c2054db 100644
78920 --- a/init/do_mounts.c
78921 +++ b/init/do_mounts.c
78922 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
78923 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
78924 {
78925 struct super_block *s;
78926 - int err = sys_mount(name, "/root", fs, flags, data);
78927 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
78928 if (err)
78929 return err;
78930
78931 - sys_chdir("/root");
78932 + sys_chdir((const char __force_user *)"/root");
78933 s = current->fs->pwd.dentry->d_sb;
78934 ROOT_DEV = s->s_dev;
78935 printk(KERN_INFO
78936 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
78937 va_start(args, fmt);
78938 vsprintf(buf, fmt, args);
78939 va_end(args);
78940 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
78941 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
78942 if (fd >= 0) {
78943 sys_ioctl(fd, FDEJECT, 0);
78944 sys_close(fd);
78945 }
78946 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
78947 - fd = sys_open("/dev/console", O_RDWR, 0);
78948 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
78949 if (fd >= 0) {
78950 sys_ioctl(fd, TCGETS, (long)&termios);
78951 termios.c_lflag &= ~ICANON;
78952 sys_ioctl(fd, TCSETSF, (long)&termios);
78953 - sys_read(fd, &c, 1);
78954 + sys_read(fd, (char __user *)&c, 1);
78955 termios.c_lflag |= ICANON;
78956 sys_ioctl(fd, TCSETSF, (long)&termios);
78957 sys_close(fd);
78958 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
78959 mount_root();
78960 out:
78961 devtmpfs_mount("dev");
78962 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
78963 - sys_chroot(".");
78964 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
78965 + sys_chroot((const char __force_user *)".");
78966 }
78967 diff --git a/init/do_mounts.h b/init/do_mounts.h
78968 index f5b978a..69dbfe8 100644
78969 --- a/init/do_mounts.h
78970 +++ b/init/do_mounts.h
78971 @@ -15,15 +15,15 @@ extern int root_mountflags;
78972
78973 static inline int create_dev(char *name, dev_t dev)
78974 {
78975 - sys_unlink(name);
78976 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
78977 + sys_unlink((char __force_user *)name);
78978 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
78979 }
78980
78981 #if BITS_PER_LONG == 32
78982 static inline u32 bstat(char *name)
78983 {
78984 struct stat64 stat;
78985 - if (sys_stat64(name, &stat) != 0)
78986 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
78987 return 0;
78988 if (!S_ISBLK(stat.st_mode))
78989 return 0;
78990 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
78991 static inline u32 bstat(char *name)
78992 {
78993 struct stat stat;
78994 - if (sys_newstat(name, &stat) != 0)
78995 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
78996 return 0;
78997 if (!S_ISBLK(stat.st_mode))
78998 return 0;
78999 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
79000 index 3e0878e..8a9d7a0 100644
79001 --- a/init/do_mounts_initrd.c
79002 +++ b/init/do_mounts_initrd.c
79003 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
79004 {
79005 sys_unshare(CLONE_FS | CLONE_FILES);
79006 /* stdin/stdout/stderr for /linuxrc */
79007 - sys_open("/dev/console", O_RDWR, 0);
79008 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
79009 sys_dup(0);
79010 sys_dup(0);
79011 /* move initrd over / and chdir/chroot in initrd root */
79012 - sys_chdir("/root");
79013 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
79014 - sys_chroot(".");
79015 + sys_chdir((const char __force_user *)"/root");
79016 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
79017 + sys_chroot((const char __force_user *)".");
79018 sys_setsid();
79019 return 0;
79020 }
79021 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
79022 create_dev("/dev/root.old", Root_RAM0);
79023 /* mount initrd on rootfs' /root */
79024 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
79025 - sys_mkdir("/old", 0700);
79026 - sys_chdir("/old");
79027 + sys_mkdir((const char __force_user *)"/old", 0700);
79028 + sys_chdir((const char __force_user *)"/old");
79029
79030 /* try loading default modules from initrd */
79031 load_default_modules();
79032 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
79033 current->flags &= ~PF_FREEZER_SKIP;
79034
79035 /* move initrd to rootfs' /old */
79036 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
79037 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
79038 /* switch root and cwd back to / of rootfs */
79039 - sys_chroot("..");
79040 + sys_chroot((const char __force_user *)"..");
79041
79042 if (new_decode_dev(real_root_dev) == Root_RAM0) {
79043 - sys_chdir("/old");
79044 + sys_chdir((const char __force_user *)"/old");
79045 return;
79046 }
79047
79048 - sys_chdir("/");
79049 + sys_chdir((const char __force_user *)"/");
79050 ROOT_DEV = new_decode_dev(real_root_dev);
79051 mount_root();
79052
79053 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
79054 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
79055 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
79056 if (!error)
79057 printk("okay\n");
79058 else {
79059 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
79060 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
79061 if (error == -ENOENT)
79062 printk("/initrd does not exist. Ignored.\n");
79063 else
79064 printk("failed\n");
79065 printk(KERN_NOTICE "Unmounting old root\n");
79066 - sys_umount("/old", MNT_DETACH);
79067 + sys_umount((char __force_user *)"/old", MNT_DETACH);
79068 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
79069 if (fd < 0) {
79070 error = fd;
79071 @@ -127,11 +127,11 @@ int __init initrd_load(void)
79072 * mounted in the normal path.
79073 */
79074 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
79075 - sys_unlink("/initrd.image");
79076 + sys_unlink((const char __force_user *)"/initrd.image");
79077 handle_initrd();
79078 return 1;
79079 }
79080 }
79081 - sys_unlink("/initrd.image");
79082 + sys_unlink((const char __force_user *)"/initrd.image");
79083 return 0;
79084 }
79085 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
79086 index 8cb6db5..d729f50 100644
79087 --- a/init/do_mounts_md.c
79088 +++ b/init/do_mounts_md.c
79089 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
79090 partitioned ? "_d" : "", minor,
79091 md_setup_args[ent].device_names);
79092
79093 - fd = sys_open(name, 0, 0);
79094 + fd = sys_open((char __force_user *)name, 0, 0);
79095 if (fd < 0) {
79096 printk(KERN_ERR "md: open failed - cannot start "
79097 "array %s\n", name);
79098 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
79099 * array without it
79100 */
79101 sys_close(fd);
79102 - fd = sys_open(name, 0, 0);
79103 + fd = sys_open((char __force_user *)name, 0, 0);
79104 sys_ioctl(fd, BLKRRPART, 0);
79105 }
79106 sys_close(fd);
79107 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
79108
79109 wait_for_device_probe();
79110
79111 - fd = sys_open("/dev/md0", 0, 0);
79112 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
79113 if (fd >= 0) {
79114 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
79115 sys_close(fd);
79116 diff --git a/init/init_task.c b/init/init_task.c
79117 index ba0a7f36..2bcf1d5 100644
79118 --- a/init/init_task.c
79119 +++ b/init/init_task.c
79120 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
79121 * Initial thread structure. Alignment of this is handled by a special
79122 * linker map entry.
79123 */
79124 +#ifdef CONFIG_X86
79125 +union thread_union init_thread_union __init_task_data;
79126 +#else
79127 union thread_union init_thread_union __init_task_data =
79128 { INIT_THREAD_INFO(init_task) };
79129 +#endif
79130 diff --git a/init/initramfs.c b/init/initramfs.c
79131 index a67ef9d..2d17ed9 100644
79132 --- a/init/initramfs.c
79133 +++ b/init/initramfs.c
79134 @@ -84,7 +84,7 @@ static void __init free_hash(void)
79135 }
79136 }
79137
79138 -static long __init do_utime(char *filename, time_t mtime)
79139 +static long __init do_utime(char __force_user *filename, time_t mtime)
79140 {
79141 struct timespec t[2];
79142
79143 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
79144 struct dir_entry *de, *tmp;
79145 list_for_each_entry_safe(de, tmp, &dir_list, list) {
79146 list_del(&de->list);
79147 - do_utime(de->name, de->mtime);
79148 + do_utime((char __force_user *)de->name, de->mtime);
79149 kfree(de->name);
79150 kfree(de);
79151 }
79152 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
79153 if (nlink >= 2) {
79154 char *old = find_link(major, minor, ino, mode, collected);
79155 if (old)
79156 - return (sys_link(old, collected) < 0) ? -1 : 1;
79157 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
79158 }
79159 return 0;
79160 }
79161 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
79162 {
79163 struct stat st;
79164
79165 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
79166 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
79167 if (S_ISDIR(st.st_mode))
79168 - sys_rmdir(path);
79169 + sys_rmdir((char __force_user *)path);
79170 else
79171 - sys_unlink(path);
79172 + sys_unlink((char __force_user *)path);
79173 }
79174 }
79175
79176 @@ -315,7 +315,7 @@ static int __init do_name(void)
79177 int openflags = O_WRONLY|O_CREAT;
79178 if (ml != 1)
79179 openflags |= O_TRUNC;
79180 - wfd = sys_open(collected, openflags, mode);
79181 + wfd = sys_open((char __force_user *)collected, openflags, mode);
79182
79183 if (wfd >= 0) {
79184 sys_fchown(wfd, uid, gid);
79185 @@ -327,17 +327,17 @@ static int __init do_name(void)
79186 }
79187 }
79188 } else if (S_ISDIR(mode)) {
79189 - sys_mkdir(collected, mode);
79190 - sys_chown(collected, uid, gid);
79191 - sys_chmod(collected, mode);
79192 + sys_mkdir((char __force_user *)collected, mode);
79193 + sys_chown((char __force_user *)collected, uid, gid);
79194 + sys_chmod((char __force_user *)collected, mode);
79195 dir_add(collected, mtime);
79196 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
79197 S_ISFIFO(mode) || S_ISSOCK(mode)) {
79198 if (maybe_link() == 0) {
79199 - sys_mknod(collected, mode, rdev);
79200 - sys_chown(collected, uid, gid);
79201 - sys_chmod(collected, mode);
79202 - do_utime(collected, mtime);
79203 + sys_mknod((char __force_user *)collected, mode, rdev);
79204 + sys_chown((char __force_user *)collected, uid, gid);
79205 + sys_chmod((char __force_user *)collected, mode);
79206 + do_utime((char __force_user *)collected, mtime);
79207 }
79208 }
79209 return 0;
79210 @@ -346,15 +346,15 @@ static int __init do_name(void)
79211 static int __init do_copy(void)
79212 {
79213 if (count >= body_len) {
79214 - sys_write(wfd, victim, body_len);
79215 + sys_write(wfd, (char __force_user *)victim, body_len);
79216 sys_close(wfd);
79217 - do_utime(vcollected, mtime);
79218 + do_utime((char __force_user *)vcollected, mtime);
79219 kfree(vcollected);
79220 eat(body_len);
79221 state = SkipIt;
79222 return 0;
79223 } else {
79224 - sys_write(wfd, victim, count);
79225 + sys_write(wfd, (char __force_user *)victim, count);
79226 body_len -= count;
79227 eat(count);
79228 return 1;
79229 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
79230 {
79231 collected[N_ALIGN(name_len) + body_len] = '\0';
79232 clean_path(collected, 0);
79233 - sys_symlink(collected + N_ALIGN(name_len), collected);
79234 - sys_lchown(collected, uid, gid);
79235 - do_utime(collected, mtime);
79236 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
79237 + sys_lchown((char __force_user *)collected, uid, gid);
79238 + do_utime((char __force_user *)collected, mtime);
79239 state = SkipIt;
79240 next_state = Reset;
79241 return 0;
79242 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
79243 {
79244 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
79245 if (err)
79246 - panic(err); /* Failed to decompress INTERNAL initramfs */
79247 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
79248 if (initrd_start) {
79249 #ifdef CONFIG_BLK_DEV_RAM
79250 int fd;
79251 diff --git a/init/main.c b/init/main.c
79252 index 586cd33..f1af30f 100644
79253 --- a/init/main.c
79254 +++ b/init/main.c
79255 @@ -102,6 +102,8 @@ static inline void mark_rodata_ro(void) { }
79256 extern void tc_init(void);
79257 #endif
79258
79259 +extern void grsecurity_init(void);
79260 +
79261 /*
79262 * Debug helper: via this flag we know that we are in 'early bootup code'
79263 * where only the boot processor is running with IRQ disabled. This means
79264 @@ -155,6 +157,74 @@ static int __init set_reset_devices(char *str)
79265
79266 __setup("reset_devices", set_reset_devices);
79267
79268 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
79269 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
79270 +static int __init setup_grsec_proc_gid(char *str)
79271 +{
79272 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
79273 + return 1;
79274 +}
79275 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
79276 +#endif
79277 +
79278 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
79279 +unsigned long pax_user_shadow_base __read_only;
79280 +EXPORT_SYMBOL(pax_user_shadow_base);
79281 +extern char pax_enter_kernel_user[];
79282 +extern char pax_exit_kernel_user[];
79283 +#endif
79284 +
79285 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
79286 +static int __init setup_pax_nouderef(char *str)
79287 +{
79288 +#ifdef CONFIG_X86_32
79289 + unsigned int cpu;
79290 + struct desc_struct *gdt;
79291 +
79292 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
79293 + gdt = get_cpu_gdt_table(cpu);
79294 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
79295 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
79296 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
79297 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
79298 + }
79299 + loadsegment(ds, __KERNEL_DS);
79300 + loadsegment(es, __KERNEL_DS);
79301 + loadsegment(ss, __KERNEL_DS);
79302 +#else
79303 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
79304 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
79305 + clone_pgd_mask = ~(pgdval_t)0UL;
79306 + pax_user_shadow_base = 0UL;
79307 + setup_clear_cpu_cap(X86_FEATURE_PCID);
79308 +#endif
79309 +
79310 + return 0;
79311 +}
79312 +early_param("pax_nouderef", setup_pax_nouderef);
79313 +
79314 +#ifdef CONFIG_X86_64
79315 +static int __init setup_pax_weakuderef(char *str)
79316 +{
79317 + if (clone_pgd_mask != ~(pgdval_t)0UL)
79318 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
79319 + return 1;
79320 +}
79321 +__setup("pax_weakuderef", setup_pax_weakuderef);
79322 +#endif
79323 +#endif
79324 +
79325 +#ifdef CONFIG_PAX_SOFTMODE
79326 +int pax_softmode;
79327 +
79328 +static int __init setup_pax_softmode(char *str)
79329 +{
79330 + get_option(&str, &pax_softmode);
79331 + return 1;
79332 +}
79333 +__setup("pax_softmode=", setup_pax_softmode);
79334 +#endif
79335 +
79336 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
79337 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
79338 static const char *panic_later, *panic_param;
79339 @@ -680,25 +750,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
79340 {
79341 int count = preempt_count();
79342 int ret;
79343 - char msgbuf[64];
79344 + const char *msg1 = "", *msg2 = "";
79345
79346 if (initcall_debug)
79347 ret = do_one_initcall_debug(fn);
79348 else
79349 ret = fn();
79350
79351 - msgbuf[0] = 0;
79352 -
79353 if (preempt_count() != count) {
79354 - sprintf(msgbuf, "preemption imbalance ");
79355 + msg1 = " preemption imbalance";
79356 preempt_count() = count;
79357 }
79358 if (irqs_disabled()) {
79359 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
79360 + msg2 = " disabled interrupts";
79361 local_irq_enable();
79362 }
79363 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
79364 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
79365
79366 + add_latent_entropy();
79367 return ret;
79368 }
79369
79370 @@ -805,8 +874,8 @@ static int run_init_process(const char *init_filename)
79371 {
79372 argv_init[0] = init_filename;
79373 return do_execve(init_filename,
79374 - (const char __user *const __user *)argv_init,
79375 - (const char __user *const __user *)envp_init);
79376 + (const char __user *const __force_user *)argv_init,
79377 + (const char __user *const __force_user *)envp_init);
79378 }
79379
79380 static noinline void __init kernel_init_freeable(void);
79381 @@ -883,7 +952,7 @@ static noinline void __init kernel_init_freeable(void)
79382 do_basic_setup();
79383
79384 /* Open the /dev/console on the rootfs, this should never fail */
79385 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
79386 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
79387 pr_err("Warning: unable to open an initial console.\n");
79388
79389 (void) sys_dup(0);
79390 @@ -896,11 +965,13 @@ static noinline void __init kernel_init_freeable(void)
79391 if (!ramdisk_execute_command)
79392 ramdisk_execute_command = "/init";
79393
79394 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
79395 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
79396 ramdisk_execute_command = NULL;
79397 prepare_namespace();
79398 }
79399
79400 + grsecurity_init();
79401 +
79402 /*
79403 * Ok, we have completed the initial bootup, and
79404 * we're essentially up and running. Get rid of the
79405 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
79406 index 130dfec..cc88451 100644
79407 --- a/ipc/ipc_sysctl.c
79408 +++ b/ipc/ipc_sysctl.c
79409 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
79410 static int proc_ipc_dointvec(ctl_table *table, int write,
79411 void __user *buffer, size_t *lenp, loff_t *ppos)
79412 {
79413 - struct ctl_table ipc_table;
79414 + ctl_table_no_const ipc_table;
79415
79416 memcpy(&ipc_table, table, sizeof(ipc_table));
79417 ipc_table.data = get_ipc(table);
79418 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
79419 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
79420 void __user *buffer, size_t *lenp, loff_t *ppos)
79421 {
79422 - struct ctl_table ipc_table;
79423 + ctl_table_no_const ipc_table;
79424
79425 memcpy(&ipc_table, table, sizeof(ipc_table));
79426 ipc_table.data = get_ipc(table);
79427 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
79428 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79429 void __user *buffer, size_t *lenp, loff_t *ppos)
79430 {
79431 - struct ctl_table ipc_table;
79432 + ctl_table_no_const ipc_table;
79433 size_t lenp_bef = *lenp;
79434 int rc;
79435
79436 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
79437 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
79438 void __user *buffer, size_t *lenp, loff_t *ppos)
79439 {
79440 - struct ctl_table ipc_table;
79441 + ctl_table_no_const ipc_table;
79442 memcpy(&ipc_table, table, sizeof(ipc_table));
79443 ipc_table.data = get_ipc(table);
79444
79445 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
79446 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
79447 void __user *buffer, size_t *lenp, loff_t *ppos)
79448 {
79449 - struct ctl_table ipc_table;
79450 + ctl_table_no_const ipc_table;
79451 size_t lenp_bef = *lenp;
79452 int oldval;
79453 int rc;
79454 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
79455 index 383d638..943fdbb 100644
79456 --- a/ipc/mq_sysctl.c
79457 +++ b/ipc/mq_sysctl.c
79458 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
79459 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
79460 void __user *buffer, size_t *lenp, loff_t *ppos)
79461 {
79462 - struct ctl_table mq_table;
79463 + ctl_table_no_const mq_table;
79464 memcpy(&mq_table, table, sizeof(mq_table));
79465 mq_table.data = get_mq(table);
79466
79467 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
79468 index ae1996d..a35f2cc 100644
79469 --- a/ipc/mqueue.c
79470 +++ b/ipc/mqueue.c
79471 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
79472 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
79473 info->attr.mq_msgsize);
79474
79475 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
79476 spin_lock(&mq_lock);
79477 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
79478 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
79479 diff --git a/ipc/msg.c b/ipc/msg.c
79480 index 558aa91..359e718 100644
79481 --- a/ipc/msg.c
79482 +++ b/ipc/msg.c
79483 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
79484 return security_msg_queue_associate(msq, msgflg);
79485 }
79486
79487 +static struct ipc_ops msg_ops = {
79488 + .getnew = newque,
79489 + .associate = msg_security,
79490 + .more_checks = NULL
79491 +};
79492 +
79493 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
79494 {
79495 struct ipc_namespace *ns;
79496 - struct ipc_ops msg_ops;
79497 struct ipc_params msg_params;
79498
79499 ns = current->nsproxy->ipc_ns;
79500
79501 - msg_ops.getnew = newque;
79502 - msg_ops.associate = msg_security;
79503 - msg_ops.more_checks = NULL;
79504 -
79505 msg_params.key = key;
79506 msg_params.flg = msgflg;
79507
79508 diff --git a/ipc/sem.c b/ipc/sem.c
79509 index 8e2bf30..a711151 100644
79510 --- a/ipc/sem.c
79511 +++ b/ipc/sem.c
79512 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
79513 return 0;
79514 }
79515
79516 +static struct ipc_ops sem_ops = {
79517 + .getnew = newary,
79518 + .associate = sem_security,
79519 + .more_checks = sem_more_checks
79520 +};
79521 +
79522 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79523 {
79524 struct ipc_namespace *ns;
79525 - struct ipc_ops sem_ops;
79526 struct ipc_params sem_params;
79527
79528 ns = current->nsproxy->ipc_ns;
79529 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
79530 if (nsems < 0 || nsems > ns->sc_semmsl)
79531 return -EINVAL;
79532
79533 - sem_ops.getnew = newary;
79534 - sem_ops.associate = sem_security;
79535 - sem_ops.more_checks = sem_more_checks;
79536 -
79537 sem_params.key = key;
79538 sem_params.flg = semflg;
79539 sem_params.u.nsems = nsems;
79540 diff --git a/ipc/shm.c b/ipc/shm.c
79541 index d697396..40e887d 100644
79542 --- a/ipc/shm.c
79543 +++ b/ipc/shm.c
79544 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
79545 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
79546 #endif
79547
79548 +#ifdef CONFIG_GRKERNSEC
79549 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79550 + const time_t shm_createtime, const kuid_t cuid,
79551 + const int shmid);
79552 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
79553 + const time_t shm_createtime);
79554 +#endif
79555 +
79556 void shm_init_ns(struct ipc_namespace *ns)
79557 {
79558 ns->shm_ctlmax = SHMMAX;
79559 @@ -551,6 +559,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
79560 shp->shm_lprid = 0;
79561 shp->shm_atim = shp->shm_dtim = 0;
79562 shp->shm_ctim = get_seconds();
79563 +#ifdef CONFIG_GRKERNSEC
79564 + {
79565 + struct timespec timeval;
79566 + do_posix_clock_monotonic_gettime(&timeval);
79567 +
79568 + shp->shm_createtime = timeval.tv_sec;
79569 + }
79570 +#endif
79571 shp->shm_segsz = size;
79572 shp->shm_nattch = 0;
79573 shp->shm_file = file;
79574 @@ -604,18 +620,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
79575 return 0;
79576 }
79577
79578 +static struct ipc_ops shm_ops = {
79579 + .getnew = newseg,
79580 + .associate = shm_security,
79581 + .more_checks = shm_more_checks
79582 +};
79583 +
79584 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
79585 {
79586 struct ipc_namespace *ns;
79587 - struct ipc_ops shm_ops;
79588 struct ipc_params shm_params;
79589
79590 ns = current->nsproxy->ipc_ns;
79591
79592 - shm_ops.getnew = newseg;
79593 - shm_ops.associate = shm_security;
79594 - shm_ops.more_checks = shm_more_checks;
79595 -
79596 shm_params.key = key;
79597 shm_params.flg = shmflg;
79598 shm_params.u.size = size;
79599 @@ -1076,6 +1093,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79600 f_mode = FMODE_READ | FMODE_WRITE;
79601 }
79602 if (shmflg & SHM_EXEC) {
79603 +
79604 +#ifdef CONFIG_PAX_MPROTECT
79605 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
79606 + goto out;
79607 +#endif
79608 +
79609 prot |= PROT_EXEC;
79610 acc_mode |= S_IXUGO;
79611 }
79612 @@ -1100,10 +1123,22 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
79613 if (err)
79614 goto out_unlock;
79615
79616 +#ifdef CONFIG_GRKERNSEC
79617 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
79618 + shp->shm_perm.cuid, shmid) ||
79619 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
79620 + err = -EACCES;
79621 + goto out_unlock;
79622 + }
79623 +#endif
79624 +
79625 ipc_lock_object(&shp->shm_perm);
79626 path = shp->shm_file->f_path;
79627 path_get(&path);
79628 shp->shm_nattch++;
79629 +#ifdef CONFIG_GRKERNSEC
79630 + shp->shm_lapid = current->pid;
79631 +#endif
79632 size = i_size_read(path.dentry->d_inode);
79633 ipc_unlock_object(&shp->shm_perm);
79634 rcu_read_unlock();
79635 diff --git a/kernel/acct.c b/kernel/acct.c
79636 index 8d6e145..33e0b1e 100644
79637 --- a/kernel/acct.c
79638 +++ b/kernel/acct.c
79639 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
79640 */
79641 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
79642 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
79643 - file->f_op->write(file, (char *)&ac,
79644 + file->f_op->write(file, (char __force_user *)&ac,
79645 sizeof(acct_t), &file->f_pos);
79646 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
79647 set_fs(fs);
79648 diff --git a/kernel/audit.c b/kernel/audit.c
79649 index 7b0e23a..5b27ab9 100644
79650 --- a/kernel/audit.c
79651 +++ b/kernel/audit.c
79652 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
79653 3) suppressed due to audit_rate_limit
79654 4) suppressed due to audit_backlog_limit
79655 */
79656 -static atomic_t audit_lost = ATOMIC_INIT(0);
79657 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
79658
79659 /* The netlink socket. */
79660 static struct sock *audit_sock;
79661 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
79662 unsigned long now;
79663 int print;
79664
79665 - atomic_inc(&audit_lost);
79666 + atomic_inc_unchecked(&audit_lost);
79667
79668 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
79669
79670 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
79671 printk(KERN_WARNING
79672 "audit: audit_lost=%d audit_rate_limit=%d "
79673 "audit_backlog_limit=%d\n",
79674 - atomic_read(&audit_lost),
79675 + atomic_read_unchecked(&audit_lost),
79676 audit_rate_limit,
79677 audit_backlog_limit);
79678 audit_panic(message);
79679 @@ -659,18 +659,19 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79680
79681 switch (msg_type) {
79682 case AUDIT_GET:
79683 + status_set.mask = 0;
79684 status_set.enabled = audit_enabled;
79685 status_set.failure = audit_failure;
79686 status_set.pid = audit_pid;
79687 status_set.rate_limit = audit_rate_limit;
79688 status_set.backlog_limit = audit_backlog_limit;
79689 - status_set.lost = atomic_read(&audit_lost);
79690 + status_set.lost = atomic_read_unchecked(&audit_lost);
79691 status_set.backlog = skb_queue_len(&audit_skb_queue);
79692 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
79693 &status_set, sizeof(status_set));
79694 break;
79695 case AUDIT_SET:
79696 - if (nlh->nlmsg_len < sizeof(struct audit_status))
79697 + if (nlmsg_len(nlh) < sizeof(struct audit_status))
79698 return -EINVAL;
79699 status_get = (struct audit_status *)data;
79700 if (status_get->mask & AUDIT_STATUS_ENABLED) {
79701 @@ -832,7 +833,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
79702
79703 memset(&s, 0, sizeof(s));
79704 /* guard against past and future API changes */
79705 - memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
79706 + memcpy(&s, data, min_t(size_t, sizeof(s), nlmsg_len(nlh)));
79707 if ((s.enabled != 0 && s.enabled != 1) ||
79708 (s.log_passwd != 0 && s.log_passwd != 1))
79709 return -EINVAL;
79710 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
79711 index 9845cb3..3ec9369 100644
79712 --- a/kernel/auditsc.c
79713 +++ b/kernel/auditsc.c
79714 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
79715 }
79716
79717 /* global counter which is incremented every time something logs in */
79718 -static atomic_t session_id = ATOMIC_INIT(0);
79719 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
79720
79721 /**
79722 * audit_set_loginuid - set current task's audit_context loginuid
79723 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
79724 return -EPERM;
79725 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
79726
79727 - sessionid = atomic_inc_return(&session_id);
79728 + sessionid = atomic_inc_return_unchecked(&session_id);
79729 if (context && context->in_syscall) {
79730 struct audit_buffer *ab;
79731
79732 diff --git a/kernel/capability.c b/kernel/capability.c
79733 index f6c2ce5..982c0f9 100644
79734 --- a/kernel/capability.c
79735 +++ b/kernel/capability.c
79736 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
79737 * before modification is attempted and the application
79738 * fails.
79739 */
79740 + if (tocopy > ARRAY_SIZE(kdata))
79741 + return -EFAULT;
79742 +
79743 if (copy_to_user(dataptr, kdata, tocopy
79744 * sizeof(struct __user_cap_data_struct))) {
79745 return -EFAULT;
79746 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
79747 int ret;
79748
79749 rcu_read_lock();
79750 - ret = security_capable(__task_cred(t), ns, cap);
79751 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
79752 + gr_task_is_capable(t, __task_cred(t), cap);
79753 rcu_read_unlock();
79754
79755 - return (ret == 0);
79756 + return ret;
79757 }
79758
79759 /**
79760 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
79761 int ret;
79762
79763 rcu_read_lock();
79764 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
79765 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
79766 rcu_read_unlock();
79767
79768 - return (ret == 0);
79769 + return ret;
79770 }
79771
79772 /**
79773 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
79774 BUG();
79775 }
79776
79777 - if (security_capable(current_cred(), ns, cap) == 0) {
79778 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
79779 current->flags |= PF_SUPERPRIV;
79780 return true;
79781 }
79782 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
79783 }
79784 EXPORT_SYMBOL(ns_capable);
79785
79786 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
79787 +{
79788 + if (unlikely(!cap_valid(cap))) {
79789 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
79790 + BUG();
79791 + }
79792 +
79793 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
79794 + current->flags |= PF_SUPERPRIV;
79795 + return true;
79796 + }
79797 + return false;
79798 +}
79799 +EXPORT_SYMBOL(ns_capable_nolog);
79800 +
79801 /**
79802 * file_ns_capable - Determine if the file's opener had a capability in effect
79803 * @file: The file we want to check
79804 @@ -432,6 +451,12 @@ bool capable(int cap)
79805 }
79806 EXPORT_SYMBOL(capable);
79807
79808 +bool capable_nolog(int cap)
79809 +{
79810 + return ns_capable_nolog(&init_user_ns, cap);
79811 +}
79812 +EXPORT_SYMBOL(capable_nolog);
79813 +
79814 /**
79815 * nsown_capable - Check superior capability to one's own user_ns
79816 * @cap: The capability in question
79817 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
79818
79819 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79820 }
79821 +
79822 +bool inode_capable_nolog(const struct inode *inode, int cap)
79823 +{
79824 + struct user_namespace *ns = current_user_ns();
79825 +
79826 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
79827 +}
79828 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
79829 index e919633..f46b08f 100644
79830 --- a/kernel/cgroup.c
79831 +++ b/kernel/cgroup.c
79832 @@ -5623,7 +5623,7 @@ static int cgroup_css_links_read(struct cgroup *cgrp,
79833 struct css_set *cset = link->cset;
79834 struct task_struct *task;
79835 int count = 0;
79836 - seq_printf(seq, "css_set %p\n", cset);
79837 + seq_printf(seq, "css_set %pK\n", cset);
79838 list_for_each_entry(task, &cset->tasks, cg_list) {
79839 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
79840 seq_puts(seq, " ...\n");
79841 diff --git a/kernel/compat.c b/kernel/compat.c
79842 index 0a09e48..f44f3f0 100644
79843 --- a/kernel/compat.c
79844 +++ b/kernel/compat.c
79845 @@ -13,6 +13,7 @@
79846
79847 #include <linux/linkage.h>
79848 #include <linux/compat.h>
79849 +#include <linux/module.h>
79850 #include <linux/errno.h>
79851 #include <linux/time.h>
79852 #include <linux/signal.h>
79853 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
79854 mm_segment_t oldfs;
79855 long ret;
79856
79857 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
79858 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
79859 oldfs = get_fs();
79860 set_fs(KERNEL_DS);
79861 ret = hrtimer_nanosleep_restart(restart);
79862 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
79863 oldfs = get_fs();
79864 set_fs(KERNEL_DS);
79865 ret = hrtimer_nanosleep(&tu,
79866 - rmtp ? (struct timespec __user *)&rmt : NULL,
79867 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
79868 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
79869 set_fs(oldfs);
79870
79871 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
79872 mm_segment_t old_fs = get_fs();
79873
79874 set_fs(KERNEL_DS);
79875 - ret = sys_sigpending((old_sigset_t __user *) &s);
79876 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
79877 set_fs(old_fs);
79878 if (ret == 0)
79879 ret = put_user(s, set);
79880 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
79881 mm_segment_t old_fs = get_fs();
79882
79883 set_fs(KERNEL_DS);
79884 - ret = sys_old_getrlimit(resource, &r);
79885 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
79886 set_fs(old_fs);
79887
79888 if (!ret) {
79889 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
79890 set_fs (KERNEL_DS);
79891 ret = sys_wait4(pid,
79892 (stat_addr ?
79893 - (unsigned int __user *) &status : NULL),
79894 - options, (struct rusage __user *) &r);
79895 + (unsigned int __force_user *) &status : NULL),
79896 + options, (struct rusage __force_user *) &r);
79897 set_fs (old_fs);
79898
79899 if (ret > 0) {
79900 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
79901 memset(&info, 0, sizeof(info));
79902
79903 set_fs(KERNEL_DS);
79904 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
79905 - uru ? (struct rusage __user *)&ru : NULL);
79906 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
79907 + uru ? (struct rusage __force_user *)&ru : NULL);
79908 set_fs(old_fs);
79909
79910 if ((ret < 0) || (info.si_signo == 0))
79911 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
79912 oldfs = get_fs();
79913 set_fs(KERNEL_DS);
79914 err = sys_timer_settime(timer_id, flags,
79915 - (struct itimerspec __user *) &newts,
79916 - (struct itimerspec __user *) &oldts);
79917 + (struct itimerspec __force_user *) &newts,
79918 + (struct itimerspec __force_user *) &oldts);
79919 set_fs(oldfs);
79920 if (!err && old && put_compat_itimerspec(old, &oldts))
79921 return -EFAULT;
79922 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
79923 oldfs = get_fs();
79924 set_fs(KERNEL_DS);
79925 err = sys_timer_gettime(timer_id,
79926 - (struct itimerspec __user *) &ts);
79927 + (struct itimerspec __force_user *) &ts);
79928 set_fs(oldfs);
79929 if (!err && put_compat_itimerspec(setting, &ts))
79930 return -EFAULT;
79931 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
79932 oldfs = get_fs();
79933 set_fs(KERNEL_DS);
79934 err = sys_clock_settime(which_clock,
79935 - (struct timespec __user *) &ts);
79936 + (struct timespec __force_user *) &ts);
79937 set_fs(oldfs);
79938 return err;
79939 }
79940 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
79941 oldfs = get_fs();
79942 set_fs(KERNEL_DS);
79943 err = sys_clock_gettime(which_clock,
79944 - (struct timespec __user *) &ts);
79945 + (struct timespec __force_user *) &ts);
79946 set_fs(oldfs);
79947 if (!err && put_compat_timespec(&ts, tp))
79948 return -EFAULT;
79949 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
79950
79951 oldfs = get_fs();
79952 set_fs(KERNEL_DS);
79953 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
79954 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
79955 set_fs(oldfs);
79956
79957 err = compat_put_timex(utp, &txc);
79958 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
79959 oldfs = get_fs();
79960 set_fs(KERNEL_DS);
79961 err = sys_clock_getres(which_clock,
79962 - (struct timespec __user *) &ts);
79963 + (struct timespec __force_user *) &ts);
79964 set_fs(oldfs);
79965 if (!err && tp && put_compat_timespec(&ts, tp))
79966 return -EFAULT;
79967 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
79968 long err;
79969 mm_segment_t oldfs;
79970 struct timespec tu;
79971 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
79972 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
79973
79974 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
79975 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
79976 oldfs = get_fs();
79977 set_fs(KERNEL_DS);
79978 err = clock_nanosleep_restart(restart);
79979 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
79980 oldfs = get_fs();
79981 set_fs(KERNEL_DS);
79982 err = sys_clock_nanosleep(which_clock, flags,
79983 - (struct timespec __user *) &in,
79984 - (struct timespec __user *) &out);
79985 + (struct timespec __force_user *) &in,
79986 + (struct timespec __force_user *) &out);
79987 set_fs(oldfs);
79988
79989 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
79990 diff --git a/kernel/configs.c b/kernel/configs.c
79991 index c18b1f1..b9a0132 100644
79992 --- a/kernel/configs.c
79993 +++ b/kernel/configs.c
79994 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
79995 struct proc_dir_entry *entry;
79996
79997 /* create the current config file */
79998 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
79999 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
80000 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
80001 + &ikconfig_file_ops);
80002 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80003 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
80004 + &ikconfig_file_ops);
80005 +#endif
80006 +#else
80007 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
80008 &ikconfig_file_ops);
80009 +#endif
80010 +
80011 if (!entry)
80012 return -ENOMEM;
80013
80014 diff --git a/kernel/cred.c b/kernel/cred.c
80015 index e0573a4..3874e41 100644
80016 --- a/kernel/cred.c
80017 +++ b/kernel/cred.c
80018 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
80019 validate_creds(cred);
80020 alter_cred_subscribers(cred, -1);
80021 put_cred(cred);
80022 +
80023 +#ifdef CONFIG_GRKERNSEC_SETXID
80024 + cred = (struct cred *) tsk->delayed_cred;
80025 + if (cred != NULL) {
80026 + tsk->delayed_cred = NULL;
80027 + validate_creds(cred);
80028 + alter_cred_subscribers(cred, -1);
80029 + put_cred(cred);
80030 + }
80031 +#endif
80032 }
80033
80034 /**
80035 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
80036 * Always returns 0 thus allowing this function to be tail-called at the end
80037 * of, say, sys_setgid().
80038 */
80039 -int commit_creds(struct cred *new)
80040 +static int __commit_creds(struct cred *new)
80041 {
80042 struct task_struct *task = current;
80043 const struct cred *old = task->real_cred;
80044 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
80045
80046 get_cred(new); /* we will require a ref for the subj creds too */
80047
80048 + gr_set_role_label(task, new->uid, new->gid);
80049 +
80050 /* dumpability changes */
80051 if (!uid_eq(old->euid, new->euid) ||
80052 !gid_eq(old->egid, new->egid) ||
80053 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
80054 put_cred(old);
80055 return 0;
80056 }
80057 +#ifdef CONFIG_GRKERNSEC_SETXID
80058 +extern int set_user(struct cred *new);
80059 +
80060 +void gr_delayed_cred_worker(void)
80061 +{
80062 + const struct cred *new = current->delayed_cred;
80063 + struct cred *ncred;
80064 +
80065 + current->delayed_cred = NULL;
80066 +
80067 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
80068 + // from doing get_cred on it when queueing this
80069 + put_cred(new);
80070 + return;
80071 + } else if (new == NULL)
80072 + return;
80073 +
80074 + ncred = prepare_creds();
80075 + if (!ncred)
80076 + goto die;
80077 + // uids
80078 + ncred->uid = new->uid;
80079 + ncred->euid = new->euid;
80080 + ncred->suid = new->suid;
80081 + ncred->fsuid = new->fsuid;
80082 + // gids
80083 + ncred->gid = new->gid;
80084 + ncred->egid = new->egid;
80085 + ncred->sgid = new->sgid;
80086 + ncred->fsgid = new->fsgid;
80087 + // groups
80088 + if (set_groups(ncred, new->group_info) < 0) {
80089 + abort_creds(ncred);
80090 + goto die;
80091 + }
80092 + // caps
80093 + ncred->securebits = new->securebits;
80094 + ncred->cap_inheritable = new->cap_inheritable;
80095 + ncred->cap_permitted = new->cap_permitted;
80096 + ncred->cap_effective = new->cap_effective;
80097 + ncred->cap_bset = new->cap_bset;
80098 +
80099 + if (set_user(ncred)) {
80100 + abort_creds(ncred);
80101 + goto die;
80102 + }
80103 +
80104 + // from doing get_cred on it when queueing this
80105 + put_cred(new);
80106 +
80107 + __commit_creds(ncred);
80108 + return;
80109 +die:
80110 + // from doing get_cred on it when queueing this
80111 + put_cred(new);
80112 + do_group_exit(SIGKILL);
80113 +}
80114 +#endif
80115 +
80116 +int commit_creds(struct cred *new)
80117 +{
80118 +#ifdef CONFIG_GRKERNSEC_SETXID
80119 + int ret;
80120 + int schedule_it = 0;
80121 + struct task_struct *t;
80122 +
80123 + /* we won't get called with tasklist_lock held for writing
80124 + and interrupts disabled as the cred struct in that case is
80125 + init_cred
80126 + */
80127 + if (grsec_enable_setxid && !current_is_single_threaded() &&
80128 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
80129 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
80130 + schedule_it = 1;
80131 + }
80132 + ret = __commit_creds(new);
80133 + if (schedule_it) {
80134 + rcu_read_lock();
80135 + read_lock(&tasklist_lock);
80136 + for (t = next_thread(current); t != current;
80137 + t = next_thread(t)) {
80138 + if (t->delayed_cred == NULL) {
80139 + t->delayed_cred = get_cred(new);
80140 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
80141 + set_tsk_need_resched(t);
80142 + }
80143 + }
80144 + read_unlock(&tasklist_lock);
80145 + rcu_read_unlock();
80146 + }
80147 + return ret;
80148 +#else
80149 + return __commit_creds(new);
80150 +#endif
80151 +}
80152 +
80153 EXPORT_SYMBOL(commit_creds);
80154
80155 /**
80156 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
80157 index 0506d44..2c20034 100644
80158 --- a/kernel/debug/debug_core.c
80159 +++ b/kernel/debug/debug_core.c
80160 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
80161 */
80162 static atomic_t masters_in_kgdb;
80163 static atomic_t slaves_in_kgdb;
80164 -static atomic_t kgdb_break_tasklet_var;
80165 +static atomic_unchecked_t kgdb_break_tasklet_var;
80166 atomic_t kgdb_setting_breakpoint;
80167
80168 struct task_struct *kgdb_usethread;
80169 @@ -133,7 +133,7 @@ int kgdb_single_step;
80170 static pid_t kgdb_sstep_pid;
80171
80172 /* to keep track of the CPU which is doing the single stepping*/
80173 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80174 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
80175
80176 /*
80177 * If you are debugging a problem where roundup (the collection of
80178 @@ -541,7 +541,7 @@ return_normal:
80179 * kernel will only try for the value of sstep_tries before
80180 * giving up and continuing on.
80181 */
80182 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
80183 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
80184 (kgdb_info[cpu].task &&
80185 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
80186 atomic_set(&kgdb_active, -1);
80187 @@ -635,8 +635,8 @@ cpu_master_loop:
80188 }
80189
80190 kgdb_restore:
80191 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
80192 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
80193 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
80194 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
80195 if (kgdb_info[sstep_cpu].task)
80196 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
80197 else
80198 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
80199 static void kgdb_tasklet_bpt(unsigned long ing)
80200 {
80201 kgdb_breakpoint();
80202 - atomic_set(&kgdb_break_tasklet_var, 0);
80203 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
80204 }
80205
80206 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
80207
80208 void kgdb_schedule_breakpoint(void)
80209 {
80210 - if (atomic_read(&kgdb_break_tasklet_var) ||
80211 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
80212 atomic_read(&kgdb_active) != -1 ||
80213 atomic_read(&kgdb_setting_breakpoint))
80214 return;
80215 - atomic_inc(&kgdb_break_tasklet_var);
80216 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
80217 tasklet_schedule(&kgdb_tasklet_breakpoint);
80218 }
80219 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
80220 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
80221 index 00eb8f7..d7e3244 100644
80222 --- a/kernel/debug/kdb/kdb_main.c
80223 +++ b/kernel/debug/kdb/kdb_main.c
80224 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
80225 continue;
80226
80227 kdb_printf("%-20s%8u 0x%p ", mod->name,
80228 - mod->core_size, (void *)mod);
80229 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
80230 #ifdef CONFIG_MODULE_UNLOAD
80231 kdb_printf("%4ld ", module_refcount(mod));
80232 #endif
80233 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
80234 kdb_printf(" (Loading)");
80235 else
80236 kdb_printf(" (Live)");
80237 - kdb_printf(" 0x%p", mod->module_core);
80238 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
80239
80240 #ifdef CONFIG_MODULE_UNLOAD
80241 {
80242 diff --git a/kernel/events/core.c b/kernel/events/core.c
80243 index f86599e..b18b180 100644
80244 --- a/kernel/events/core.c
80245 +++ b/kernel/events/core.c
80246 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
80247 * 0 - disallow raw tracepoint access for unpriv
80248 * 1 - disallow cpu events for unpriv
80249 * 2 - disallow kernel profiling for unpriv
80250 + * 3 - disallow all unpriv perf event use
80251 */
80252 -int sysctl_perf_event_paranoid __read_mostly = 1;
80253 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80254 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
80255 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
80256 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
80257 +#else
80258 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
80259 +#endif
80260
80261 /* Minimum for 512 kiB + 1 user control page */
80262 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
80263 @@ -270,7 +277,7 @@ void perf_sample_event_took(u64 sample_len_ns)
80264 update_perf_cpu_limits();
80265 }
80266
80267 -static atomic64_t perf_event_id;
80268 +static atomic64_unchecked_t perf_event_id;
80269
80270 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
80271 enum event_type_t event_type);
80272 @@ -2936,7 +2943,7 @@ static void __perf_event_read(void *info)
80273
80274 static inline u64 perf_event_count(struct perf_event *event)
80275 {
80276 - return local64_read(&event->count) + atomic64_read(&event->child_count);
80277 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
80278 }
80279
80280 static u64 perf_event_read(struct perf_event *event)
80281 @@ -3282,9 +3289,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
80282 mutex_lock(&event->child_mutex);
80283 total += perf_event_read(event);
80284 *enabled += event->total_time_enabled +
80285 - atomic64_read(&event->child_total_time_enabled);
80286 + atomic64_read_unchecked(&event->child_total_time_enabled);
80287 *running += event->total_time_running +
80288 - atomic64_read(&event->child_total_time_running);
80289 + atomic64_read_unchecked(&event->child_total_time_running);
80290
80291 list_for_each_entry(child, &event->child_list, child_list) {
80292 total += perf_event_read(child);
80293 @@ -3670,10 +3677,10 @@ void perf_event_update_userpage(struct perf_event *event)
80294 userpg->offset -= local64_read(&event->hw.prev_count);
80295
80296 userpg->time_enabled = enabled +
80297 - atomic64_read(&event->child_total_time_enabled);
80298 + atomic64_read_unchecked(&event->child_total_time_enabled);
80299
80300 userpg->time_running = running +
80301 - atomic64_read(&event->child_total_time_running);
80302 + atomic64_read_unchecked(&event->child_total_time_running);
80303
80304 arch_perf_update_userpage(userpg, now);
80305
80306 @@ -4223,7 +4230,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
80307
80308 /* Data. */
80309 sp = perf_user_stack_pointer(regs);
80310 - rem = __output_copy_user(handle, (void *) sp, dump_size);
80311 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
80312 dyn_size = dump_size - rem;
80313
80314 perf_output_skip(handle, rem);
80315 @@ -4311,11 +4318,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
80316 values[n++] = perf_event_count(event);
80317 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
80318 values[n++] = enabled +
80319 - atomic64_read(&event->child_total_time_enabled);
80320 + atomic64_read_unchecked(&event->child_total_time_enabled);
80321 }
80322 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
80323 values[n++] = running +
80324 - atomic64_read(&event->child_total_time_running);
80325 + atomic64_read_unchecked(&event->child_total_time_running);
80326 }
80327 if (read_format & PERF_FORMAT_ID)
80328 values[n++] = primary_event_id(event);
80329 @@ -5024,12 +5031,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
80330 * need to add enough zero bytes after the string to handle
80331 * the 64bit alignment we do later.
80332 */
80333 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
80334 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
80335 if (!buf) {
80336 name = strncpy(tmp, "//enomem", sizeof(tmp));
80337 goto got_name;
80338 }
80339 - name = d_path(&file->f_path, buf, PATH_MAX);
80340 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
80341 if (IS_ERR(name)) {
80342 name = strncpy(tmp, "//toolong", sizeof(tmp));
80343 goto got_name;
80344 @@ -6498,7 +6505,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
80345 event->parent = parent_event;
80346
80347 event->ns = get_pid_ns(task_active_pid_ns(current));
80348 - event->id = atomic64_inc_return(&perf_event_id);
80349 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
80350
80351 event->state = PERF_EVENT_STATE_INACTIVE;
80352
80353 @@ -6807,6 +6814,11 @@ SYSCALL_DEFINE5(perf_event_open,
80354 if (flags & ~PERF_FLAG_ALL)
80355 return -EINVAL;
80356
80357 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
80358 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
80359 + return -EACCES;
80360 +#endif
80361 +
80362 err = perf_copy_attr(attr_uptr, &attr);
80363 if (err)
80364 return err;
80365 @@ -7139,10 +7151,10 @@ static void sync_child_event(struct perf_event *child_event,
80366 /*
80367 * Add back the child's count to the parent's count:
80368 */
80369 - atomic64_add(child_val, &parent_event->child_count);
80370 - atomic64_add(child_event->total_time_enabled,
80371 + atomic64_add_unchecked(child_val, &parent_event->child_count);
80372 + atomic64_add_unchecked(child_event->total_time_enabled,
80373 &parent_event->child_total_time_enabled);
80374 - atomic64_add(child_event->total_time_running,
80375 + atomic64_add_unchecked(child_event->total_time_running,
80376 &parent_event->child_total_time_running);
80377
80378 /*
80379 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
80380 index ca65997..60df03d 100644
80381 --- a/kernel/events/internal.h
80382 +++ b/kernel/events/internal.h
80383 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
80384 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
80385 }
80386
80387 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
80388 -static inline unsigned int \
80389 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
80390 +static inline unsigned long \
80391 func_name(struct perf_output_handle *handle, \
80392 - const void *buf, unsigned int len) \
80393 + const void user *buf, unsigned long len) \
80394 { \
80395 unsigned long size, written; \
80396 \
80397 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
80398 return n;
80399 }
80400
80401 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
80402 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
80403
80404 #define MEMCPY_SKIP(dst, src, n) (n)
80405
80406 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
80407 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
80408
80409 #ifndef arch_perf_out_copy_user
80410 #define arch_perf_out_copy_user __copy_from_user_inatomic
80411 #endif
80412
80413 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
80414 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
80415
80416 /* Callchain handling */
80417 extern struct perf_callchain_entry *
80418 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
80419 index ad8e1bd..fed7ba9 100644
80420 --- a/kernel/events/uprobes.c
80421 +++ b/kernel/events/uprobes.c
80422 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
80423 {
80424 struct page *page;
80425 uprobe_opcode_t opcode;
80426 - int result;
80427 + long result;
80428
80429 pagefault_disable();
80430 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
80431 diff --git a/kernel/exit.c b/kernel/exit.c
80432 index a949819..a5f127d 100644
80433 --- a/kernel/exit.c
80434 +++ b/kernel/exit.c
80435 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
80436 struct task_struct *leader;
80437 int zap_leader;
80438 repeat:
80439 +#ifdef CONFIG_NET
80440 + gr_del_task_from_ip_table(p);
80441 +#endif
80442 +
80443 /* don't need to get the RCU readlock here - the process is dead and
80444 * can't be modifying its own credentials. But shut RCU-lockdep up */
80445 rcu_read_lock();
80446 @@ -329,7 +333,7 @@ int allow_signal(int sig)
80447 * know it'll be handled, so that they don't get converted to
80448 * SIGKILL or just silently dropped.
80449 */
80450 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
80451 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
80452 recalc_sigpending();
80453 spin_unlock_irq(&current->sighand->siglock);
80454 return 0;
80455 @@ -698,6 +702,8 @@ void do_exit(long code)
80456 struct task_struct *tsk = current;
80457 int group_dead;
80458
80459 + set_fs(USER_DS);
80460 +
80461 profile_task_exit(tsk);
80462
80463 WARN_ON(blk_needs_flush_plug(tsk));
80464 @@ -714,7 +720,6 @@ void do_exit(long code)
80465 * mm_release()->clear_child_tid() from writing to a user-controlled
80466 * kernel address.
80467 */
80468 - set_fs(USER_DS);
80469
80470 ptrace_event(PTRACE_EVENT_EXIT, code);
80471
80472 @@ -773,6 +778,9 @@ void do_exit(long code)
80473 tsk->exit_code = code;
80474 taskstats_exit(tsk, group_dead);
80475
80476 + gr_acl_handle_psacct(tsk, code);
80477 + gr_acl_handle_exit();
80478 +
80479 exit_mm(tsk);
80480
80481 if (group_dead)
80482 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
80483 * Take down every thread in the group. This is called by fatal signals
80484 * as well as by sys_exit_group (below).
80485 */
80486 -void
80487 +__noreturn void
80488 do_group_exit(int exit_code)
80489 {
80490 struct signal_struct *sig = current->signal;
80491 diff --git a/kernel/fork.c b/kernel/fork.c
80492 index 200a7a2..43e52da 100644
80493 --- a/kernel/fork.c
80494 +++ b/kernel/fork.c
80495 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
80496 *stackend = STACK_END_MAGIC; /* for overflow detection */
80497
80498 #ifdef CONFIG_CC_STACKPROTECTOR
80499 - tsk->stack_canary = get_random_int();
80500 + tsk->stack_canary = pax_get_random_long();
80501 #endif
80502
80503 /*
80504 @@ -345,13 +345,81 @@ free_tsk:
80505 }
80506
80507 #ifdef CONFIG_MMU
80508 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80509 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
80510 {
80511 - struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80512 - struct rb_node **rb_link, *rb_parent;
80513 - int retval;
80514 + struct vm_area_struct *tmp;
80515 unsigned long charge;
80516 struct mempolicy *pol;
80517 + struct file *file;
80518 +
80519 + charge = 0;
80520 + if (mpnt->vm_flags & VM_ACCOUNT) {
80521 + unsigned long len = vma_pages(mpnt);
80522 +
80523 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80524 + goto fail_nomem;
80525 + charge = len;
80526 + }
80527 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80528 + if (!tmp)
80529 + goto fail_nomem;
80530 + *tmp = *mpnt;
80531 + tmp->vm_mm = mm;
80532 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
80533 + pol = mpol_dup(vma_policy(mpnt));
80534 + if (IS_ERR(pol))
80535 + goto fail_nomem_policy;
80536 + vma_set_policy(tmp, pol);
80537 + if (anon_vma_fork(tmp, mpnt))
80538 + goto fail_nomem_anon_vma_fork;
80539 + tmp->vm_flags &= ~VM_LOCKED;
80540 + tmp->vm_next = tmp->vm_prev = NULL;
80541 + tmp->vm_mirror = NULL;
80542 + file = tmp->vm_file;
80543 + if (file) {
80544 + struct inode *inode = file_inode(file);
80545 + struct address_space *mapping = file->f_mapping;
80546 +
80547 + get_file(file);
80548 + if (tmp->vm_flags & VM_DENYWRITE)
80549 + atomic_dec(&inode->i_writecount);
80550 + mutex_lock(&mapping->i_mmap_mutex);
80551 + if (tmp->vm_flags & VM_SHARED)
80552 + mapping->i_mmap_writable++;
80553 + flush_dcache_mmap_lock(mapping);
80554 + /* insert tmp into the share list, just after mpnt */
80555 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80556 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
80557 + else
80558 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
80559 + flush_dcache_mmap_unlock(mapping);
80560 + mutex_unlock(&mapping->i_mmap_mutex);
80561 + }
80562 +
80563 + /*
80564 + * Clear hugetlb-related page reserves for children. This only
80565 + * affects MAP_PRIVATE mappings. Faults generated by the child
80566 + * are not guaranteed to succeed, even if read-only
80567 + */
80568 + if (is_vm_hugetlb_page(tmp))
80569 + reset_vma_resv_huge_pages(tmp);
80570 +
80571 + return tmp;
80572 +
80573 +fail_nomem_anon_vma_fork:
80574 + mpol_put(pol);
80575 +fail_nomem_policy:
80576 + kmem_cache_free(vm_area_cachep, tmp);
80577 +fail_nomem:
80578 + vm_unacct_memory(charge);
80579 + return NULL;
80580 +}
80581 +
80582 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80583 +{
80584 + struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
80585 + struct rb_node **rb_link, *rb_parent;
80586 + int retval;
80587
80588 uprobe_start_dup_mmap();
80589 down_write(&oldmm->mmap_sem);
80590 @@ -380,57 +448,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80591
80592 prev = NULL;
80593 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
80594 - struct file *file;
80595 -
80596 if (mpnt->vm_flags & VM_DONTCOPY) {
80597 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
80598 -vma_pages(mpnt));
80599 continue;
80600 }
80601 - charge = 0;
80602 - if (mpnt->vm_flags & VM_ACCOUNT) {
80603 - unsigned long len = vma_pages(mpnt);
80604 -
80605 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
80606 - goto fail_nomem;
80607 - charge = len;
80608 - }
80609 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
80610 - if (!tmp)
80611 - goto fail_nomem;
80612 - *tmp = *mpnt;
80613 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
80614 - pol = mpol_dup(vma_policy(mpnt));
80615 - retval = PTR_ERR(pol);
80616 - if (IS_ERR(pol))
80617 - goto fail_nomem_policy;
80618 - vma_set_policy(tmp, pol);
80619 - tmp->vm_mm = mm;
80620 - if (anon_vma_fork(tmp, mpnt))
80621 - goto fail_nomem_anon_vma_fork;
80622 - tmp->vm_flags &= ~VM_LOCKED;
80623 - tmp->vm_next = tmp->vm_prev = NULL;
80624 - file = tmp->vm_file;
80625 - if (file) {
80626 - struct inode *inode = file_inode(file);
80627 - struct address_space *mapping = file->f_mapping;
80628 -
80629 - get_file(file);
80630 - if (tmp->vm_flags & VM_DENYWRITE)
80631 - atomic_dec(&inode->i_writecount);
80632 - mutex_lock(&mapping->i_mmap_mutex);
80633 - if (tmp->vm_flags & VM_SHARED)
80634 - mapping->i_mmap_writable++;
80635 - flush_dcache_mmap_lock(mapping);
80636 - /* insert tmp into the share list, just after mpnt */
80637 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
80638 - vma_nonlinear_insert(tmp,
80639 - &mapping->i_mmap_nonlinear);
80640 - else
80641 - vma_interval_tree_insert_after(tmp, mpnt,
80642 - &mapping->i_mmap);
80643 - flush_dcache_mmap_unlock(mapping);
80644 - mutex_unlock(&mapping->i_mmap_mutex);
80645 + tmp = dup_vma(mm, oldmm, mpnt);
80646 + if (!tmp) {
80647 + retval = -ENOMEM;
80648 + goto out;
80649 }
80650
80651 /*
80652 @@ -462,6 +488,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
80653 if (retval)
80654 goto out;
80655 }
80656 +
80657 +#ifdef CONFIG_PAX_SEGMEXEC
80658 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
80659 + struct vm_area_struct *mpnt_m;
80660 +
80661 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
80662 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
80663 +
80664 + if (!mpnt->vm_mirror)
80665 + continue;
80666 +
80667 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
80668 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
80669 + mpnt->vm_mirror = mpnt_m;
80670 + } else {
80671 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
80672 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
80673 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
80674 + mpnt->vm_mirror->vm_mirror = mpnt;
80675 + }
80676 + }
80677 + BUG_ON(mpnt_m);
80678 + }
80679 +#endif
80680 +
80681 /* a new mm has just been created */
80682 arch_dup_mmap(oldmm, mm);
80683 retval = 0;
80684 @@ -471,14 +522,6 @@ out:
80685 up_write(&oldmm->mmap_sem);
80686 uprobe_end_dup_mmap();
80687 return retval;
80688 -fail_nomem_anon_vma_fork:
80689 - mpol_put(pol);
80690 -fail_nomem_policy:
80691 - kmem_cache_free(vm_area_cachep, tmp);
80692 -fail_nomem:
80693 - retval = -ENOMEM;
80694 - vm_unacct_memory(charge);
80695 - goto out;
80696 }
80697
80698 static inline int mm_alloc_pgd(struct mm_struct *mm)
80699 @@ -691,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
80700 return ERR_PTR(err);
80701
80702 mm = get_task_mm(task);
80703 - if (mm && mm != current->mm &&
80704 - !ptrace_may_access(task, mode)) {
80705 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
80706 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
80707 mmput(mm);
80708 mm = ERR_PTR(-EACCES);
80709 }
80710 @@ -914,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
80711 spin_unlock(&fs->lock);
80712 return -EAGAIN;
80713 }
80714 - fs->users++;
80715 + atomic_inc(&fs->users);
80716 spin_unlock(&fs->lock);
80717 return 0;
80718 }
80719 tsk->fs = copy_fs_struct(fs);
80720 if (!tsk->fs)
80721 return -ENOMEM;
80722 + /* Carry through gr_chroot_dentry and is_chrooted instead
80723 + of recomputing it here. Already copied when the task struct
80724 + is duplicated. This allows pivot_root to not be treated as
80725 + a chroot
80726 + */
80727 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
80728 +
80729 return 0;
80730 }
80731
80732 @@ -1131,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
80733 * parts of the process environment (as per the clone
80734 * flags). The actual kick-off is left to the caller.
80735 */
80736 -static struct task_struct *copy_process(unsigned long clone_flags,
80737 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
80738 unsigned long stack_start,
80739 unsigned long stack_size,
80740 int __user *child_tidptr,
80741 @@ -1201,6 +1251,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80742 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
80743 #endif
80744 retval = -EAGAIN;
80745 +
80746 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
80747 +
80748 if (atomic_read(&p->real_cred->user->processes) >=
80749 task_rlimit(p, RLIMIT_NPROC)) {
80750 if (p->real_cred->user != INIT_USER &&
80751 @@ -1450,6 +1503,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
80752 goto bad_fork_free_pid;
80753 }
80754
80755 + /* synchronizes with gr_set_acls()
80756 + we need to call this past the point of no return for fork()
80757 + */
80758 + gr_copy_label(p);
80759 +
80760 if (likely(p->pid)) {
80761 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
80762
80763 @@ -1535,6 +1593,8 @@ bad_fork_cleanup_count:
80764 bad_fork_free:
80765 free_task(p);
80766 fork_out:
80767 + gr_log_forkfail(retval);
80768 +
80769 return ERR_PTR(retval);
80770 }
80771
80772 @@ -1605,6 +1665,7 @@ long do_fork(unsigned long clone_flags,
80773
80774 p = copy_process(clone_flags, stack_start, stack_size,
80775 child_tidptr, NULL, trace);
80776 + add_latent_entropy();
80777 /*
80778 * Do this prior waking up the new thread - the thread pointer
80779 * might get invalid after that point, if the thread exits quickly.
80780 @@ -1619,6 +1680,8 @@ long do_fork(unsigned long clone_flags,
80781 if (clone_flags & CLONE_PARENT_SETTID)
80782 put_user(nr, parent_tidptr);
80783
80784 + gr_handle_brute_check();
80785 +
80786 if (clone_flags & CLONE_VFORK) {
80787 p->vfork_done = &vfork;
80788 init_completion(&vfork);
80789 @@ -1735,7 +1798,7 @@ void __init proc_caches_init(void)
80790 mm_cachep = kmem_cache_create("mm_struct",
80791 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
80792 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
80793 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
80794 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
80795 mmap_init();
80796 nsproxy_cache_init();
80797 }
80798 @@ -1775,7 +1838,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
80799 return 0;
80800
80801 /* don't need lock here; in the worst case we'll do useless copy */
80802 - if (fs->users == 1)
80803 + if (atomic_read(&fs->users) == 1)
80804 return 0;
80805
80806 *new_fsp = copy_fs_struct(fs);
80807 @@ -1887,7 +1950,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
80808 fs = current->fs;
80809 spin_lock(&fs->lock);
80810 current->fs = new_fs;
80811 - if (--fs->users)
80812 + gr_set_chroot_entries(current, &current->fs->root);
80813 + if (atomic_dec_return(&fs->users))
80814 new_fs = NULL;
80815 else
80816 new_fs = fs;
80817 diff --git a/kernel/futex.c b/kernel/futex.c
80818 index c3a1a55..e32b4a98 100644
80819 --- a/kernel/futex.c
80820 +++ b/kernel/futex.c
80821 @@ -54,6 +54,7 @@
80822 #include <linux/mount.h>
80823 #include <linux/pagemap.h>
80824 #include <linux/syscalls.h>
80825 +#include <linux/ptrace.h>
80826 #include <linux/signal.h>
80827 #include <linux/export.h>
80828 #include <linux/magic.h>
80829 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
80830 struct page *page, *page_head;
80831 int err, ro = 0;
80832
80833 +#ifdef CONFIG_PAX_SEGMEXEC
80834 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
80835 + return -EFAULT;
80836 +#endif
80837 +
80838 /*
80839 * The futex address must be "naturally" aligned.
80840 */
80841 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
80842
80843 static int get_futex_value_locked(u32 *dest, u32 __user *from)
80844 {
80845 - int ret;
80846 + unsigned long ret;
80847
80848 pagefault_disable();
80849 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
80850 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
80851 {
80852 u32 curval;
80853 int i;
80854 + mm_segment_t oldfs;
80855
80856 /*
80857 * This will fail and we want it. Some arch implementations do
80858 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
80859 * implementation, the non-functional ones will return
80860 * -ENOSYS.
80861 */
80862 + oldfs = get_fs();
80863 + set_fs(USER_DS);
80864 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
80865 futex_cmpxchg_enabled = 1;
80866 + set_fs(oldfs);
80867
80868 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
80869 plist_head_init(&futex_queues[i].chain);
80870 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
80871 index f9f44fd..29885e4 100644
80872 --- a/kernel/futex_compat.c
80873 +++ b/kernel/futex_compat.c
80874 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
80875 return 0;
80876 }
80877
80878 -static void __user *futex_uaddr(struct robust_list __user *entry,
80879 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
80880 compat_long_t futex_offset)
80881 {
80882 compat_uptr_t base = ptr_to_compat(entry);
80883 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
80884 index 9b22d03..6295b62 100644
80885 --- a/kernel/gcov/base.c
80886 +++ b/kernel/gcov/base.c
80887 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
80888 }
80889
80890 #ifdef CONFIG_MODULES
80891 -static inline int within(void *addr, void *start, unsigned long size)
80892 -{
80893 - return ((addr >= start) && (addr < start + size));
80894 -}
80895 -
80896 /* Update list and generate events when modules are unloaded. */
80897 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80898 void *data)
80899 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
80900 prev = NULL;
80901 /* Remove entries located in module from linked list. */
80902 for (info = gcov_info_head; info; info = info->next) {
80903 - if (within(info, mod->module_core, mod->core_size)) {
80904 + if (within_module_core_rw((unsigned long)info, mod)) {
80905 if (prev)
80906 prev->next = info->next;
80907 else
80908 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
80909 index 383319b..56ebb13 100644
80910 --- a/kernel/hrtimer.c
80911 +++ b/kernel/hrtimer.c
80912 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
80913 local_irq_restore(flags);
80914 }
80915
80916 -static void run_hrtimer_softirq(struct softirq_action *h)
80917 +static __latent_entropy void run_hrtimer_softirq(void)
80918 {
80919 hrtimer_peek_ahead_timers();
80920 }
80921 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
80922 index 55fcce6..0e4cf34 100644
80923 --- a/kernel/irq_work.c
80924 +++ b/kernel/irq_work.c
80925 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
80926 return NOTIFY_OK;
80927 }
80928
80929 -static struct notifier_block cpu_notify;
80930 +static struct notifier_block cpu_notify = {
80931 + .notifier_call = irq_work_cpu_notify,
80932 + .priority = 0,
80933 +};
80934
80935 static __init int irq_work_init_cpu_notifier(void)
80936 {
80937 - cpu_notify.notifier_call = irq_work_cpu_notify;
80938 - cpu_notify.priority = 0;
80939 register_cpu_notifier(&cpu_notify);
80940 return 0;
80941 }
80942 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
80943 index 60f48fa..7f3a770 100644
80944 --- a/kernel/jump_label.c
80945 +++ b/kernel/jump_label.c
80946 @@ -13,6 +13,7 @@
80947 #include <linux/sort.h>
80948 #include <linux/err.h>
80949 #include <linux/static_key.h>
80950 +#include <linux/mm.h>
80951
80952 #ifdef HAVE_JUMP_LABEL
80953
80954 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
80955
80956 size = (((unsigned long)stop - (unsigned long)start)
80957 / sizeof(struct jump_entry));
80958 + pax_open_kernel();
80959 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
80960 + pax_close_kernel();
80961 }
80962
80963 static void jump_label_update(struct static_key *key, int enable);
80964 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
80965 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
80966 struct jump_entry *iter;
80967
80968 + pax_open_kernel();
80969 for (iter = iter_start; iter < iter_stop; iter++) {
80970 if (within_module_init(iter->code, mod))
80971 iter->code = 0;
80972 }
80973 + pax_close_kernel();
80974 }
80975
80976 static int
80977 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
80978 index 3127ad5..159d880 100644
80979 --- a/kernel/kallsyms.c
80980 +++ b/kernel/kallsyms.c
80981 @@ -11,6 +11,9 @@
80982 * Changed the compression method from stem compression to "table lookup"
80983 * compression (see scripts/kallsyms.c for a more complete description)
80984 */
80985 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80986 +#define __INCLUDED_BY_HIDESYM 1
80987 +#endif
80988 #include <linux/kallsyms.h>
80989 #include <linux/module.h>
80990 #include <linux/init.h>
80991 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
80992
80993 static inline int is_kernel_inittext(unsigned long addr)
80994 {
80995 + if (system_state != SYSTEM_BOOTING)
80996 + return 0;
80997 +
80998 if (addr >= (unsigned long)_sinittext
80999 && addr <= (unsigned long)_einittext)
81000 return 1;
81001 return 0;
81002 }
81003
81004 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81005 +#ifdef CONFIG_MODULES
81006 +static inline int is_module_text(unsigned long addr)
81007 +{
81008 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
81009 + return 1;
81010 +
81011 + addr = ktla_ktva(addr);
81012 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
81013 +}
81014 +#else
81015 +static inline int is_module_text(unsigned long addr)
81016 +{
81017 + return 0;
81018 +}
81019 +#endif
81020 +#endif
81021 +
81022 static inline int is_kernel_text(unsigned long addr)
81023 {
81024 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
81025 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
81026
81027 static inline int is_kernel(unsigned long addr)
81028 {
81029 +
81030 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81031 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
81032 + return 1;
81033 +
81034 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
81035 +#else
81036 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
81037 +#endif
81038 +
81039 return 1;
81040 return in_gate_area_no_mm(addr);
81041 }
81042
81043 static int is_ksym_addr(unsigned long addr)
81044 {
81045 +
81046 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
81047 + if (is_module_text(addr))
81048 + return 0;
81049 +#endif
81050 +
81051 if (all_var)
81052 return is_kernel(addr);
81053
81054 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
81055
81056 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
81057 {
81058 - iter->name[0] = '\0';
81059 iter->nameoff = get_symbol_offset(new_pos);
81060 iter->pos = new_pos;
81061 }
81062 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
81063 {
81064 struct kallsym_iter *iter = m->private;
81065
81066 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81067 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
81068 + return 0;
81069 +#endif
81070 +
81071 /* Some debugging symbols have no name. Ignore them. */
81072 if (!iter->name[0])
81073 return 0;
81074 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
81075 */
81076 type = iter->exported ? toupper(iter->type) :
81077 tolower(iter->type);
81078 +
81079 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
81080 type, iter->name, iter->module_name);
81081 } else
81082 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
81083 struct kallsym_iter *iter;
81084 int ret;
81085
81086 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
81087 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
81088 if (!iter)
81089 return -ENOMEM;
81090 reset_iter(iter, 0);
81091 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
81092 index e30ac0f..3528cac 100644
81093 --- a/kernel/kcmp.c
81094 +++ b/kernel/kcmp.c
81095 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
81096 struct task_struct *task1, *task2;
81097 int ret;
81098
81099 +#ifdef CONFIG_GRKERNSEC
81100 + return -ENOSYS;
81101 +#endif
81102 +
81103 rcu_read_lock();
81104
81105 /*
81106 diff --git a/kernel/kexec.c b/kernel/kexec.c
81107 index 59f7b55..4022f65 100644
81108 --- a/kernel/kexec.c
81109 +++ b/kernel/kexec.c
81110 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
81111 unsigned long flags)
81112 {
81113 struct compat_kexec_segment in;
81114 - struct kexec_segment out, __user *ksegments;
81115 + struct kexec_segment out;
81116 + struct kexec_segment __user *ksegments;
81117 unsigned long i, result;
81118
81119 /* Don't allow clients that don't understand the native
81120 diff --git a/kernel/kmod.c b/kernel/kmod.c
81121 index b086006..a27913b 100644
81122 --- a/kernel/kmod.c
81123 +++ b/kernel/kmod.c
81124 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
81125 kfree(info->argv);
81126 }
81127
81128 -static int call_modprobe(char *module_name, int wait)
81129 +static int call_modprobe(char *module_name, char *module_param, int wait)
81130 {
81131 struct subprocess_info *info;
81132 static char *envp[] = {
81133 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
81134 NULL
81135 };
81136
81137 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
81138 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
81139 if (!argv)
81140 goto out;
81141
81142 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
81143 argv[1] = "-q";
81144 argv[2] = "--";
81145 argv[3] = module_name; /* check free_modprobe_argv() */
81146 - argv[4] = NULL;
81147 + argv[4] = module_param;
81148 + argv[5] = NULL;
81149
81150 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
81151 NULL, free_modprobe_argv, NULL);
81152 @@ -129,9 +130,8 @@ out:
81153 * If module auto-loading support is disabled then this function
81154 * becomes a no-operation.
81155 */
81156 -int __request_module(bool wait, const char *fmt, ...)
81157 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
81158 {
81159 - va_list args;
81160 char module_name[MODULE_NAME_LEN];
81161 unsigned int max_modprobes;
81162 int ret;
81163 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
81164 if (!modprobe_path[0])
81165 return 0;
81166
81167 - va_start(args, fmt);
81168 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
81169 - va_end(args);
81170 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
81171 if (ret >= MODULE_NAME_LEN)
81172 return -ENAMETOOLONG;
81173
81174 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
81175 if (ret)
81176 return ret;
81177
81178 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81179 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81180 + /* hack to workaround consolekit/udisks stupidity */
81181 + read_lock(&tasklist_lock);
81182 + if (!strcmp(current->comm, "mount") &&
81183 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
81184 + read_unlock(&tasklist_lock);
81185 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
81186 + return -EPERM;
81187 + }
81188 + read_unlock(&tasklist_lock);
81189 + }
81190 +#endif
81191 +
81192 /* If modprobe needs a service that is in a module, we get a recursive
81193 * loop. Limit the number of running kmod threads to max_threads/2 or
81194 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
81195 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
81196
81197 trace_module_request(module_name, wait, _RET_IP_);
81198
81199 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81200 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
81201
81202 atomic_dec(&kmod_concurrent);
81203 return ret;
81204 }
81205 +
81206 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
81207 +{
81208 + va_list args;
81209 + int ret;
81210 +
81211 + va_start(args, fmt);
81212 + ret = ____request_module(wait, module_param, fmt, args);
81213 + va_end(args);
81214 +
81215 + return ret;
81216 +}
81217 +
81218 +int __request_module(bool wait, const char *fmt, ...)
81219 +{
81220 + va_list args;
81221 + int ret;
81222 +
81223 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81224 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
81225 + char module_param[MODULE_NAME_LEN];
81226 +
81227 + memset(module_param, 0, sizeof(module_param));
81228 +
81229 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
81230 +
81231 + va_start(args, fmt);
81232 + ret = ____request_module(wait, module_param, fmt, args);
81233 + va_end(args);
81234 +
81235 + return ret;
81236 + }
81237 +#endif
81238 +
81239 + va_start(args, fmt);
81240 + ret = ____request_module(wait, NULL, fmt, args);
81241 + va_end(args);
81242 +
81243 + return ret;
81244 +}
81245 +
81246 EXPORT_SYMBOL(__request_module);
81247 #endif /* CONFIG_MODULES */
81248
81249 @@ -303,7 +356,7 @@ static int wait_for_helper(void *data)
81250 *
81251 * Thus the __user pointer cast is valid here.
81252 */
81253 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
81254 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
81255
81256 /*
81257 * If ret is 0, either ____call_usermodehelper failed and the
81258 @@ -650,7 +703,7 @@ EXPORT_SYMBOL(call_usermodehelper);
81259 static int proc_cap_handler(struct ctl_table *table, int write,
81260 void __user *buffer, size_t *lenp, loff_t *ppos)
81261 {
81262 - struct ctl_table t;
81263 + ctl_table_no_const t;
81264 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
81265 kernel_cap_t new_cap;
81266 int err, i;
81267 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
81268 index 6e33498..3133bd3 100644
81269 --- a/kernel/kprobes.c
81270 +++ b/kernel/kprobes.c
81271 @@ -31,6 +31,9 @@
81272 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
81273 * <prasanna@in.ibm.com> added function-return probes.
81274 */
81275 +#ifdef CONFIG_GRKERNSEC_HIDESYM
81276 +#define __INCLUDED_BY_HIDESYM 1
81277 +#endif
81278 #include <linux/kprobes.h>
81279 #include <linux/hash.h>
81280 #include <linux/init.h>
81281 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
81282 * kernel image and loaded module images reside. This is required
81283 * so x86_64 can correctly handle the %rip-relative fixups.
81284 */
81285 - kip->insns = module_alloc(PAGE_SIZE);
81286 + kip->insns = module_alloc_exec(PAGE_SIZE);
81287 if (!kip->insns) {
81288 kfree(kip);
81289 return NULL;
81290 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
81291 */
81292 if (!list_is_singular(&kip->list)) {
81293 list_del(&kip->list);
81294 - module_free(NULL, kip->insns);
81295 + module_free_exec(NULL, kip->insns);
81296 kfree(kip);
81297 }
81298 return 1;
81299 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
81300 {
81301 int i, err = 0;
81302 unsigned long offset = 0, size = 0;
81303 - char *modname, namebuf[128];
81304 + char *modname, namebuf[KSYM_NAME_LEN];
81305 const char *symbol_name;
81306 void *addr;
81307 struct kprobe_blackpoint *kb;
81308 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
81309 kprobe_type = "k";
81310
81311 if (sym)
81312 - seq_printf(pi, "%p %s %s+0x%x %s ",
81313 + seq_printf(pi, "%pK %s %s+0x%x %s ",
81314 p->addr, kprobe_type, sym, offset,
81315 (modname ? modname : " "));
81316 else
81317 - seq_printf(pi, "%p %s %p ",
81318 + seq_printf(pi, "%pK %s %pK ",
81319 p->addr, kprobe_type, p->addr);
81320
81321 if (!pp)
81322 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
81323 const char *sym = NULL;
81324 unsigned int i = *(loff_t *) v;
81325 unsigned long offset = 0;
81326 - char *modname, namebuf[128];
81327 + char *modname, namebuf[KSYM_NAME_LEN];
81328
81329 head = &kprobe_table[i];
81330 preempt_disable();
81331 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
81332 index 6ada93c..dce7d5d 100644
81333 --- a/kernel/ksysfs.c
81334 +++ b/kernel/ksysfs.c
81335 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
81336 {
81337 if (count+1 > UEVENT_HELPER_PATH_LEN)
81338 return -ENOENT;
81339 + if (!capable(CAP_SYS_ADMIN))
81340 + return -EPERM;
81341 memcpy(uevent_helper, buf, count);
81342 uevent_helper[count] = '\0';
81343 if (count && uevent_helper[count-1] == '\n')
81344 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
81345 return count;
81346 }
81347
81348 -static struct bin_attribute notes_attr = {
81349 +static bin_attribute_no_const notes_attr __read_only = {
81350 .attr = {
81351 .name = "notes",
81352 .mode = S_IRUGO,
81353 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
81354 index e16c45b..6f49c48 100644
81355 --- a/kernel/lockdep.c
81356 +++ b/kernel/lockdep.c
81357 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
81358 end = (unsigned long) &_end,
81359 addr = (unsigned long) obj;
81360
81361 +#ifdef CONFIG_PAX_KERNEXEC
81362 + start = ktla_ktva(start);
81363 +#endif
81364 +
81365 /*
81366 * static variable?
81367 */
81368 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
81369 if (!static_obj(lock->key)) {
81370 debug_locks_off();
81371 printk("INFO: trying to register non-static key.\n");
81372 + printk("lock:%pS key:%pS.\n", lock, lock->key);
81373 printk("the code is fine but needs lockdep annotation.\n");
81374 printk("turning off the locking correctness validator.\n");
81375 dump_stack();
81376 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
81377 if (!class)
81378 return 0;
81379 }
81380 - atomic_inc((atomic_t *)&class->ops);
81381 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
81382 if (very_verbose(class)) {
81383 printk("\nacquire class [%p] %s", class->key, class->name);
81384 if (class->name_version > 1)
81385 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
81386 index b2c71c5..7b88d63 100644
81387 --- a/kernel/lockdep_proc.c
81388 +++ b/kernel/lockdep_proc.c
81389 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
81390 return 0;
81391 }
81392
81393 - seq_printf(m, "%p", class->key);
81394 + seq_printf(m, "%pK", class->key);
81395 #ifdef CONFIG_DEBUG_LOCKDEP
81396 seq_printf(m, " OPS:%8ld", class->ops);
81397 #endif
81398 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
81399
81400 list_for_each_entry(entry, &class->locks_after, entry) {
81401 if (entry->distance == 1) {
81402 - seq_printf(m, " -> [%p] ", entry->class->key);
81403 + seq_printf(m, " -> [%pK] ", entry->class->key);
81404 print_name(m, entry->class);
81405 seq_puts(m, "\n");
81406 }
81407 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
81408 if (!class->key)
81409 continue;
81410
81411 - seq_printf(m, "[%p] ", class->key);
81412 + seq_printf(m, "[%pK] ", class->key);
81413 print_name(m, class);
81414 seq_puts(m, "\n");
81415 }
81416 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81417 if (!i)
81418 seq_line(m, '-', 40-namelen, namelen);
81419
81420 - snprintf(ip, sizeof(ip), "[<%p>]",
81421 + snprintf(ip, sizeof(ip), "[<%pK>]",
81422 (void *)class->contention_point[i]);
81423 seq_printf(m, "%40s %14lu %29s %pS\n",
81424 name, stats->contention_point[i],
81425 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
81426 if (!i)
81427 seq_line(m, '-', 40-namelen, namelen);
81428
81429 - snprintf(ip, sizeof(ip), "[<%p>]",
81430 + snprintf(ip, sizeof(ip), "[<%pK>]",
81431 (void *)class->contending_point[i]);
81432 seq_printf(m, "%40s %14lu %29s %pS\n",
81433 name, stats->contending_point[i],
81434 diff --git a/kernel/module.c b/kernel/module.c
81435 index 2069158..71101bb 100644
81436 --- a/kernel/module.c
81437 +++ b/kernel/module.c
81438 @@ -61,6 +61,7 @@
81439 #include <linux/pfn.h>
81440 #include <linux/bsearch.h>
81441 #include <linux/fips.h>
81442 +#include <linux/grsecurity.h>
81443 #include <uapi/linux/module.h>
81444 #include "module-internal.h"
81445
81446 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
81447
81448 /* Bounds of module allocation, for speeding __module_address.
81449 * Protected by module_mutex. */
81450 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
81451 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
81452 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
81453
81454 int register_module_notifier(struct notifier_block * nb)
81455 {
81456 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81457 return true;
81458
81459 list_for_each_entry_rcu(mod, &modules, list) {
81460 - struct symsearch arr[] = {
81461 + struct symsearch modarr[] = {
81462 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
81463 NOT_GPL_ONLY, false },
81464 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
81465 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
81466 if (mod->state == MODULE_STATE_UNFORMED)
81467 continue;
81468
81469 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
81470 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
81471 return true;
81472 }
81473 return false;
81474 @@ -490,7 +492,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
81475 if (!pcpusec->sh_size)
81476 return 0;
81477
81478 - if (align > PAGE_SIZE) {
81479 + if (align-1 >= PAGE_SIZE) {
81480 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
81481 mod->name, align, PAGE_SIZE);
81482 align = PAGE_SIZE;
81483 @@ -1096,7 +1098,7 @@ struct module_attribute module_uevent =
81484 static ssize_t show_coresize(struct module_attribute *mattr,
81485 struct module_kobject *mk, char *buffer)
81486 {
81487 - return sprintf(buffer, "%u\n", mk->mod->core_size);
81488 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
81489 }
81490
81491 static struct module_attribute modinfo_coresize =
81492 @@ -1105,7 +1107,7 @@ static struct module_attribute modinfo_coresize =
81493 static ssize_t show_initsize(struct module_attribute *mattr,
81494 struct module_kobject *mk, char *buffer)
81495 {
81496 - return sprintf(buffer, "%u\n", mk->mod->init_size);
81497 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
81498 }
81499
81500 static struct module_attribute modinfo_initsize =
81501 @@ -1320,7 +1322,7 @@ resolve_symbol_wait(struct module *mod,
81502 */
81503 #ifdef CONFIG_SYSFS
81504
81505 -#ifdef CONFIG_KALLSYMS
81506 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
81507 static inline bool sect_empty(const Elf_Shdr *sect)
81508 {
81509 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
81510 @@ -1460,7 +1462,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
81511 {
81512 unsigned int notes, loaded, i;
81513 struct module_notes_attrs *notes_attrs;
81514 - struct bin_attribute *nattr;
81515 + bin_attribute_no_const *nattr;
81516
81517 /* failed to create section attributes, so can't create notes */
81518 if (!mod->sect_attrs)
81519 @@ -1572,7 +1574,7 @@ static void del_usage_links(struct module *mod)
81520 static int module_add_modinfo_attrs(struct module *mod)
81521 {
81522 struct module_attribute *attr;
81523 - struct module_attribute *temp_attr;
81524 + module_attribute_no_const *temp_attr;
81525 int error = 0;
81526 int i;
81527
81528 @@ -1786,21 +1788,21 @@ static void set_section_ro_nx(void *base,
81529
81530 static void unset_module_core_ro_nx(struct module *mod)
81531 {
81532 - set_page_attributes(mod->module_core + mod->core_text_size,
81533 - mod->module_core + mod->core_size,
81534 + set_page_attributes(mod->module_core_rw,
81535 + mod->module_core_rw + mod->core_size_rw,
81536 set_memory_x);
81537 - set_page_attributes(mod->module_core,
81538 - mod->module_core + mod->core_ro_size,
81539 + set_page_attributes(mod->module_core_rx,
81540 + mod->module_core_rx + mod->core_size_rx,
81541 set_memory_rw);
81542 }
81543
81544 static void unset_module_init_ro_nx(struct module *mod)
81545 {
81546 - set_page_attributes(mod->module_init + mod->init_text_size,
81547 - mod->module_init + mod->init_size,
81548 + set_page_attributes(mod->module_init_rw,
81549 + mod->module_init_rw + mod->init_size_rw,
81550 set_memory_x);
81551 - set_page_attributes(mod->module_init,
81552 - mod->module_init + mod->init_ro_size,
81553 + set_page_attributes(mod->module_init_rx,
81554 + mod->module_init_rx + mod->init_size_rx,
81555 set_memory_rw);
81556 }
81557
81558 @@ -1813,14 +1815,14 @@ void set_all_modules_text_rw(void)
81559 list_for_each_entry_rcu(mod, &modules, list) {
81560 if (mod->state == MODULE_STATE_UNFORMED)
81561 continue;
81562 - if ((mod->module_core) && (mod->core_text_size)) {
81563 - set_page_attributes(mod->module_core,
81564 - mod->module_core + mod->core_text_size,
81565 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81566 + set_page_attributes(mod->module_core_rx,
81567 + mod->module_core_rx + mod->core_size_rx,
81568 set_memory_rw);
81569 }
81570 - if ((mod->module_init) && (mod->init_text_size)) {
81571 - set_page_attributes(mod->module_init,
81572 - mod->module_init + mod->init_text_size,
81573 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81574 + set_page_attributes(mod->module_init_rx,
81575 + mod->module_init_rx + mod->init_size_rx,
81576 set_memory_rw);
81577 }
81578 }
81579 @@ -1836,14 +1838,14 @@ void set_all_modules_text_ro(void)
81580 list_for_each_entry_rcu(mod, &modules, list) {
81581 if (mod->state == MODULE_STATE_UNFORMED)
81582 continue;
81583 - if ((mod->module_core) && (mod->core_text_size)) {
81584 - set_page_attributes(mod->module_core,
81585 - mod->module_core + mod->core_text_size,
81586 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
81587 + set_page_attributes(mod->module_core_rx,
81588 + mod->module_core_rx + mod->core_size_rx,
81589 set_memory_ro);
81590 }
81591 - if ((mod->module_init) && (mod->init_text_size)) {
81592 - set_page_attributes(mod->module_init,
81593 - mod->module_init + mod->init_text_size,
81594 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
81595 + set_page_attributes(mod->module_init_rx,
81596 + mod->module_init_rx + mod->init_size_rx,
81597 set_memory_ro);
81598 }
81599 }
81600 @@ -1894,16 +1896,19 @@ static void free_module(struct module *mod)
81601
81602 /* This may be NULL, but that's OK */
81603 unset_module_init_ro_nx(mod);
81604 - module_free(mod, mod->module_init);
81605 + module_free(mod, mod->module_init_rw);
81606 + module_free_exec(mod, mod->module_init_rx);
81607 kfree(mod->args);
81608 percpu_modfree(mod);
81609
81610 /* Free lock-classes: */
81611 - lockdep_free_key_range(mod->module_core, mod->core_size);
81612 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
81613 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
81614
81615 /* Finally, free the core (containing the module structure) */
81616 unset_module_core_ro_nx(mod);
81617 - module_free(mod, mod->module_core);
81618 + module_free_exec(mod, mod->module_core_rx);
81619 + module_free(mod, mod->module_core_rw);
81620
81621 #ifdef CONFIG_MPU
81622 update_protections(current->mm);
81623 @@ -1973,9 +1978,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81624 int ret = 0;
81625 const struct kernel_symbol *ksym;
81626
81627 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81628 + int is_fs_load = 0;
81629 + int register_filesystem_found = 0;
81630 + char *p;
81631 +
81632 + p = strstr(mod->args, "grsec_modharden_fs");
81633 + if (p) {
81634 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
81635 + /* copy \0 as well */
81636 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
81637 + is_fs_load = 1;
81638 + }
81639 +#endif
81640 +
81641 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
81642 const char *name = info->strtab + sym[i].st_name;
81643
81644 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81645 + /* it's a real shame this will never get ripped and copied
81646 + upstream! ;(
81647 + */
81648 + if (is_fs_load && !strcmp(name, "register_filesystem"))
81649 + register_filesystem_found = 1;
81650 +#endif
81651 +
81652 switch (sym[i].st_shndx) {
81653 case SHN_COMMON:
81654 /* We compiled with -fno-common. These are not
81655 @@ -1996,7 +2023,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81656 ksym = resolve_symbol_wait(mod, info, name);
81657 /* Ok if resolved. */
81658 if (ksym && !IS_ERR(ksym)) {
81659 + pax_open_kernel();
81660 sym[i].st_value = ksym->value;
81661 + pax_close_kernel();
81662 break;
81663 }
81664
81665 @@ -2015,11 +2044,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
81666 secbase = (unsigned long)mod_percpu(mod);
81667 else
81668 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
81669 + pax_open_kernel();
81670 sym[i].st_value += secbase;
81671 + pax_close_kernel();
81672 break;
81673 }
81674 }
81675
81676 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
81677 + if (is_fs_load && !register_filesystem_found) {
81678 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
81679 + ret = -EPERM;
81680 + }
81681 +#endif
81682 +
81683 return ret;
81684 }
81685
81686 @@ -2103,22 +2141,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
81687 || s->sh_entsize != ~0UL
81688 || strstarts(sname, ".init"))
81689 continue;
81690 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
81691 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81692 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
81693 + else
81694 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
81695 pr_debug("\t%s\n", sname);
81696 }
81697 - switch (m) {
81698 - case 0: /* executable */
81699 - mod->core_size = debug_align(mod->core_size);
81700 - mod->core_text_size = mod->core_size;
81701 - break;
81702 - case 1: /* RO: text and ro-data */
81703 - mod->core_size = debug_align(mod->core_size);
81704 - mod->core_ro_size = mod->core_size;
81705 - break;
81706 - case 3: /* whole core */
81707 - mod->core_size = debug_align(mod->core_size);
81708 - break;
81709 - }
81710 }
81711
81712 pr_debug("Init section allocation order:\n");
81713 @@ -2132,23 +2160,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
81714 || s->sh_entsize != ~0UL
81715 || !strstarts(sname, ".init"))
81716 continue;
81717 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
81718 - | INIT_OFFSET_MASK);
81719 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
81720 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
81721 + else
81722 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
81723 + s->sh_entsize |= INIT_OFFSET_MASK;
81724 pr_debug("\t%s\n", sname);
81725 }
81726 - switch (m) {
81727 - case 0: /* executable */
81728 - mod->init_size = debug_align(mod->init_size);
81729 - mod->init_text_size = mod->init_size;
81730 - break;
81731 - case 1: /* RO: text and ro-data */
81732 - mod->init_size = debug_align(mod->init_size);
81733 - mod->init_ro_size = mod->init_size;
81734 - break;
81735 - case 3: /* whole init */
81736 - mod->init_size = debug_align(mod->init_size);
81737 - break;
81738 - }
81739 }
81740 }
81741
81742 @@ -2321,7 +2339,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81743
81744 /* Put symbol section at end of init part of module. */
81745 symsect->sh_flags |= SHF_ALLOC;
81746 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
81747 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
81748 info->index.sym) | INIT_OFFSET_MASK;
81749 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
81750
81751 @@ -2338,13 +2356,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
81752 }
81753
81754 /* Append room for core symbols at end of core part. */
81755 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
81756 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
81757 - mod->core_size += strtab_size;
81758 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
81759 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
81760 + mod->core_size_rx += strtab_size;
81761
81762 /* Put string table section at end of init part of module. */
81763 strsect->sh_flags |= SHF_ALLOC;
81764 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
81765 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
81766 info->index.str) | INIT_OFFSET_MASK;
81767 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
81768 }
81769 @@ -2362,12 +2380,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81770 /* Make sure we get permanent strtab: don't use info->strtab. */
81771 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
81772
81773 + pax_open_kernel();
81774 +
81775 /* Set types up while we still have access to sections. */
81776 for (i = 0; i < mod->num_symtab; i++)
81777 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
81778
81779 - mod->core_symtab = dst = mod->module_core + info->symoffs;
81780 - mod->core_strtab = s = mod->module_core + info->stroffs;
81781 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
81782 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
81783 src = mod->symtab;
81784 for (ndst = i = 0; i < mod->num_symtab; i++) {
81785 if (i == 0 ||
81786 @@ -2379,6 +2399,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
81787 }
81788 }
81789 mod->core_num_syms = ndst;
81790 +
81791 + pax_close_kernel();
81792 }
81793 #else
81794 static inline void layout_symtab(struct module *mod, struct load_info *info)
81795 @@ -2412,17 +2434,33 @@ void * __weak module_alloc(unsigned long size)
81796 return vmalloc_exec(size);
81797 }
81798
81799 -static void *module_alloc_update_bounds(unsigned long size)
81800 +static void *module_alloc_update_bounds_rw(unsigned long size)
81801 {
81802 void *ret = module_alloc(size);
81803
81804 if (ret) {
81805 mutex_lock(&module_mutex);
81806 /* Update module bounds. */
81807 - if ((unsigned long)ret < module_addr_min)
81808 - module_addr_min = (unsigned long)ret;
81809 - if ((unsigned long)ret + size > module_addr_max)
81810 - module_addr_max = (unsigned long)ret + size;
81811 + if ((unsigned long)ret < module_addr_min_rw)
81812 + module_addr_min_rw = (unsigned long)ret;
81813 + if ((unsigned long)ret + size > module_addr_max_rw)
81814 + module_addr_max_rw = (unsigned long)ret + size;
81815 + mutex_unlock(&module_mutex);
81816 + }
81817 + return ret;
81818 +}
81819 +
81820 +static void *module_alloc_update_bounds_rx(unsigned long size)
81821 +{
81822 + void *ret = module_alloc_exec(size);
81823 +
81824 + if (ret) {
81825 + mutex_lock(&module_mutex);
81826 + /* Update module bounds. */
81827 + if ((unsigned long)ret < module_addr_min_rx)
81828 + module_addr_min_rx = (unsigned long)ret;
81829 + if ((unsigned long)ret + size > module_addr_max_rx)
81830 + module_addr_max_rx = (unsigned long)ret + size;
81831 mutex_unlock(&module_mutex);
81832 }
81833 return ret;
81834 @@ -2698,8 +2736,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
81835 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81836 {
81837 const char *modmagic = get_modinfo(info, "vermagic");
81838 + const char *license = get_modinfo(info, "license");
81839 int err;
81840
81841 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
81842 + if (!license || !license_is_gpl_compatible(license))
81843 + return -ENOEXEC;
81844 +#endif
81845 +
81846 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
81847 modmagic = NULL;
81848
81849 @@ -2725,7 +2769,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
81850 }
81851
81852 /* Set up license info based on the info section */
81853 - set_license(mod, get_modinfo(info, "license"));
81854 + set_license(mod, license);
81855
81856 return 0;
81857 }
81858 @@ -2806,7 +2850,7 @@ static int move_module(struct module *mod, struct load_info *info)
81859 void *ptr;
81860
81861 /* Do the allocs. */
81862 - ptr = module_alloc_update_bounds(mod->core_size);
81863 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
81864 /*
81865 * The pointer to this block is stored in the module structure
81866 * which is inside the block. Just mark it as not being a
81867 @@ -2816,11 +2860,11 @@ static int move_module(struct module *mod, struct load_info *info)
81868 if (!ptr)
81869 return -ENOMEM;
81870
81871 - memset(ptr, 0, mod->core_size);
81872 - mod->module_core = ptr;
81873 + memset(ptr, 0, mod->core_size_rw);
81874 + mod->module_core_rw = ptr;
81875
81876 - if (mod->init_size) {
81877 - ptr = module_alloc_update_bounds(mod->init_size);
81878 + if (mod->init_size_rw) {
81879 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
81880 /*
81881 * The pointer to this block is stored in the module structure
81882 * which is inside the block. This block doesn't need to be
81883 @@ -2829,13 +2873,45 @@ static int move_module(struct module *mod, struct load_info *info)
81884 */
81885 kmemleak_ignore(ptr);
81886 if (!ptr) {
81887 - module_free(mod, mod->module_core);
81888 + module_free(mod, mod->module_core_rw);
81889 return -ENOMEM;
81890 }
81891 - memset(ptr, 0, mod->init_size);
81892 - mod->module_init = ptr;
81893 + memset(ptr, 0, mod->init_size_rw);
81894 + mod->module_init_rw = ptr;
81895 } else
81896 - mod->module_init = NULL;
81897 + mod->module_init_rw = NULL;
81898 +
81899 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
81900 + kmemleak_not_leak(ptr);
81901 + if (!ptr) {
81902 + if (mod->module_init_rw)
81903 + module_free(mod, mod->module_init_rw);
81904 + module_free(mod, mod->module_core_rw);
81905 + return -ENOMEM;
81906 + }
81907 +
81908 + pax_open_kernel();
81909 + memset(ptr, 0, mod->core_size_rx);
81910 + pax_close_kernel();
81911 + mod->module_core_rx = ptr;
81912 +
81913 + if (mod->init_size_rx) {
81914 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
81915 + kmemleak_ignore(ptr);
81916 + if (!ptr && mod->init_size_rx) {
81917 + module_free_exec(mod, mod->module_core_rx);
81918 + if (mod->module_init_rw)
81919 + module_free(mod, mod->module_init_rw);
81920 + module_free(mod, mod->module_core_rw);
81921 + return -ENOMEM;
81922 + }
81923 +
81924 + pax_open_kernel();
81925 + memset(ptr, 0, mod->init_size_rx);
81926 + pax_close_kernel();
81927 + mod->module_init_rx = ptr;
81928 + } else
81929 + mod->module_init_rx = NULL;
81930
81931 /* Transfer each section which specifies SHF_ALLOC */
81932 pr_debug("final section addresses:\n");
81933 @@ -2846,16 +2922,45 @@ static int move_module(struct module *mod, struct load_info *info)
81934 if (!(shdr->sh_flags & SHF_ALLOC))
81935 continue;
81936
81937 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
81938 - dest = mod->module_init
81939 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81940 - else
81941 - dest = mod->module_core + shdr->sh_entsize;
81942 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
81943 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81944 + dest = mod->module_init_rw
81945 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81946 + else
81947 + dest = mod->module_init_rx
81948 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
81949 + } else {
81950 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
81951 + dest = mod->module_core_rw + shdr->sh_entsize;
81952 + else
81953 + dest = mod->module_core_rx + shdr->sh_entsize;
81954 + }
81955 +
81956 + if (shdr->sh_type != SHT_NOBITS) {
81957 +
81958 +#ifdef CONFIG_PAX_KERNEXEC
81959 +#ifdef CONFIG_X86_64
81960 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
81961 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
81962 +#endif
81963 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
81964 + pax_open_kernel();
81965 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81966 + pax_close_kernel();
81967 + } else
81968 +#endif
81969
81970 - if (shdr->sh_type != SHT_NOBITS)
81971 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
81972 + }
81973 /* Update sh_addr to point to copy in image. */
81974 - shdr->sh_addr = (unsigned long)dest;
81975 +
81976 +#ifdef CONFIG_PAX_KERNEXEC
81977 + if (shdr->sh_flags & SHF_EXECINSTR)
81978 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
81979 + else
81980 +#endif
81981 +
81982 + shdr->sh_addr = (unsigned long)dest;
81983 pr_debug("\t0x%lx %s\n",
81984 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
81985 }
81986 @@ -2912,12 +3017,12 @@ static void flush_module_icache(const struct module *mod)
81987 * Do it before processing of module parameters, so the module
81988 * can provide parameter accessor functions of its own.
81989 */
81990 - if (mod->module_init)
81991 - flush_icache_range((unsigned long)mod->module_init,
81992 - (unsigned long)mod->module_init
81993 - + mod->init_size);
81994 - flush_icache_range((unsigned long)mod->module_core,
81995 - (unsigned long)mod->module_core + mod->core_size);
81996 + if (mod->module_init_rx)
81997 + flush_icache_range((unsigned long)mod->module_init_rx,
81998 + (unsigned long)mod->module_init_rx
81999 + + mod->init_size_rx);
82000 + flush_icache_range((unsigned long)mod->module_core_rx,
82001 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
82002
82003 set_fs(old_fs);
82004 }
82005 @@ -2974,8 +3079,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
82006 static void module_deallocate(struct module *mod, struct load_info *info)
82007 {
82008 percpu_modfree(mod);
82009 - module_free(mod, mod->module_init);
82010 - module_free(mod, mod->module_core);
82011 + module_free_exec(mod, mod->module_init_rx);
82012 + module_free_exec(mod, mod->module_core_rx);
82013 + module_free(mod, mod->module_init_rw);
82014 + module_free(mod, mod->module_core_rw);
82015 }
82016
82017 int __weak module_finalize(const Elf_Ehdr *hdr,
82018 @@ -2988,7 +3095,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
82019 static int post_relocation(struct module *mod, const struct load_info *info)
82020 {
82021 /* Sort exception table now relocations are done. */
82022 + pax_open_kernel();
82023 sort_extable(mod->extable, mod->extable + mod->num_exentries);
82024 + pax_close_kernel();
82025
82026 /* Copy relocated percpu area over. */
82027 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
82028 @@ -3042,16 +3151,16 @@ static int do_init_module(struct module *mod)
82029 MODULE_STATE_COMING, mod);
82030
82031 /* Set RO and NX regions for core */
82032 - set_section_ro_nx(mod->module_core,
82033 - mod->core_text_size,
82034 - mod->core_ro_size,
82035 - mod->core_size);
82036 + set_section_ro_nx(mod->module_core_rx,
82037 + mod->core_size_rx,
82038 + mod->core_size_rx,
82039 + mod->core_size_rx);
82040
82041 /* Set RO and NX regions for init */
82042 - set_section_ro_nx(mod->module_init,
82043 - mod->init_text_size,
82044 - mod->init_ro_size,
82045 - mod->init_size);
82046 + set_section_ro_nx(mod->module_init_rx,
82047 + mod->init_size_rx,
82048 + mod->init_size_rx,
82049 + mod->init_size_rx);
82050
82051 do_mod_ctors(mod);
82052 /* Start the module */
82053 @@ -3113,11 +3222,12 @@ static int do_init_module(struct module *mod)
82054 mod->strtab = mod->core_strtab;
82055 #endif
82056 unset_module_init_ro_nx(mod);
82057 - module_free(mod, mod->module_init);
82058 - mod->module_init = NULL;
82059 - mod->init_size = 0;
82060 - mod->init_ro_size = 0;
82061 - mod->init_text_size = 0;
82062 + module_free(mod, mod->module_init_rw);
82063 + module_free_exec(mod, mod->module_init_rx);
82064 + mod->module_init_rw = NULL;
82065 + mod->module_init_rx = NULL;
82066 + mod->init_size_rw = 0;
82067 + mod->init_size_rx = 0;
82068 mutex_unlock(&module_mutex);
82069 wake_up_all(&module_wq);
82070
82071 @@ -3261,9 +3371,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
82072 if (err)
82073 goto free_unload;
82074
82075 + /* Now copy in args */
82076 + mod->args = strndup_user(uargs, ~0UL >> 1);
82077 + if (IS_ERR(mod->args)) {
82078 + err = PTR_ERR(mod->args);
82079 + goto free_unload;
82080 + }
82081 +
82082 /* Set up MODINFO_ATTR fields */
82083 setup_modinfo(mod, info);
82084
82085 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
82086 + {
82087 + char *p, *p2;
82088 +
82089 + if (strstr(mod->args, "grsec_modharden_netdev")) {
82090 + 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);
82091 + err = -EPERM;
82092 + goto free_modinfo;
82093 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
82094 + p += sizeof("grsec_modharden_normal") - 1;
82095 + p2 = strstr(p, "_");
82096 + if (p2) {
82097 + *p2 = '\0';
82098 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
82099 + *p2 = '_';
82100 + }
82101 + err = -EPERM;
82102 + goto free_modinfo;
82103 + }
82104 + }
82105 +#endif
82106 +
82107 /* Fix up syms, so that st_value is a pointer to location. */
82108 err = simplify_symbols(mod, info);
82109 if (err < 0)
82110 @@ -3279,13 +3418,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
82111
82112 flush_module_icache(mod);
82113
82114 - /* Now copy in args */
82115 - mod->args = strndup_user(uargs, ~0UL >> 1);
82116 - if (IS_ERR(mod->args)) {
82117 - err = PTR_ERR(mod->args);
82118 - goto free_arch_cleanup;
82119 - }
82120 -
82121 dynamic_debug_setup(info->debug, info->num_debug);
82122
82123 /* Finally it's fully formed, ready to start executing. */
82124 @@ -3320,11 +3452,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
82125 ddebug_cleanup:
82126 dynamic_debug_remove(info->debug);
82127 synchronize_sched();
82128 - kfree(mod->args);
82129 - free_arch_cleanup:
82130 module_arch_cleanup(mod);
82131 free_modinfo:
82132 free_modinfo(mod);
82133 + kfree(mod->args);
82134 free_unload:
82135 module_unload_free(mod);
82136 unlink_mod:
82137 @@ -3407,10 +3538,16 @@ static const char *get_ksymbol(struct module *mod,
82138 unsigned long nextval;
82139
82140 /* At worse, next value is at end of module */
82141 - if (within_module_init(addr, mod))
82142 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
82143 + if (within_module_init_rx(addr, mod))
82144 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
82145 + else if (within_module_init_rw(addr, mod))
82146 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
82147 + else if (within_module_core_rx(addr, mod))
82148 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
82149 + else if (within_module_core_rw(addr, mod))
82150 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
82151 else
82152 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
82153 + return NULL;
82154
82155 /* Scan for closest preceding symbol, and next symbol. (ELF
82156 starts real symbols at 1). */
82157 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
82158 return 0;
82159
82160 seq_printf(m, "%s %u",
82161 - mod->name, mod->init_size + mod->core_size);
82162 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
82163 print_unload_info(m, mod);
82164
82165 /* Informative for users. */
82166 @@ -3670,7 +3807,7 @@ static int m_show(struct seq_file *m, void *p)
82167 mod->state == MODULE_STATE_COMING ? "Loading":
82168 "Live");
82169 /* Used by oprofile and other similar tools. */
82170 - seq_printf(m, " 0x%pK", mod->module_core);
82171 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
82172
82173 /* Taints info */
82174 if (mod->taints)
82175 @@ -3706,7 +3843,17 @@ static const struct file_operations proc_modules_operations = {
82176
82177 static int __init proc_modules_init(void)
82178 {
82179 +#ifndef CONFIG_GRKERNSEC_HIDESYM
82180 +#ifdef CONFIG_GRKERNSEC_PROC_USER
82181 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82182 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
82183 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
82184 +#else
82185 proc_create("modules", 0, NULL, &proc_modules_operations);
82186 +#endif
82187 +#else
82188 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
82189 +#endif
82190 return 0;
82191 }
82192 module_init(proc_modules_init);
82193 @@ -3767,14 +3914,14 @@ struct module *__module_address(unsigned long addr)
82194 {
82195 struct module *mod;
82196
82197 - if (addr < module_addr_min || addr > module_addr_max)
82198 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
82199 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
82200 return NULL;
82201
82202 list_for_each_entry_rcu(mod, &modules, list) {
82203 if (mod->state == MODULE_STATE_UNFORMED)
82204 continue;
82205 - if (within_module_core(addr, mod)
82206 - || within_module_init(addr, mod))
82207 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
82208 return mod;
82209 }
82210 return NULL;
82211 @@ -3809,11 +3956,20 @@ bool is_module_text_address(unsigned long addr)
82212 */
82213 struct module *__module_text_address(unsigned long addr)
82214 {
82215 - struct module *mod = __module_address(addr);
82216 + struct module *mod;
82217 +
82218 +#ifdef CONFIG_X86_32
82219 + addr = ktla_ktva(addr);
82220 +#endif
82221 +
82222 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
82223 + return NULL;
82224 +
82225 + mod = __module_address(addr);
82226 +
82227 if (mod) {
82228 /* Make sure it's within the text section. */
82229 - if (!within(addr, mod->module_init, mod->init_text_size)
82230 - && !within(addr, mod->module_core, mod->core_text_size))
82231 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
82232 mod = NULL;
82233 }
82234 return mod;
82235 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
82236 index 7e3443f..b2a1e6b 100644
82237 --- a/kernel/mutex-debug.c
82238 +++ b/kernel/mutex-debug.c
82239 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
82240 }
82241
82242 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82243 - struct thread_info *ti)
82244 + struct task_struct *task)
82245 {
82246 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
82247
82248 /* Mark the current thread as blocked on the lock: */
82249 - ti->task->blocked_on = waiter;
82250 + task->blocked_on = waiter;
82251 }
82252
82253 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82254 - struct thread_info *ti)
82255 + struct task_struct *task)
82256 {
82257 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
82258 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
82259 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
82260 - ti->task->blocked_on = NULL;
82261 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
82262 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
82263 + task->blocked_on = NULL;
82264
82265 list_del_init(&waiter->list);
82266 waiter->task = NULL;
82267 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
82268 index 0799fd3..d06ae3b 100644
82269 --- a/kernel/mutex-debug.h
82270 +++ b/kernel/mutex-debug.h
82271 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
82272 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
82273 extern void debug_mutex_add_waiter(struct mutex *lock,
82274 struct mutex_waiter *waiter,
82275 - struct thread_info *ti);
82276 + struct task_struct *task);
82277 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
82278 - struct thread_info *ti);
82279 + struct task_struct *task);
82280 extern void debug_mutex_unlock(struct mutex *lock);
82281 extern void debug_mutex_init(struct mutex *lock, const char *name,
82282 struct lock_class_key *key);
82283 diff --git a/kernel/mutex.c b/kernel/mutex.c
82284 index a52ee7bb..f361f16 100644
82285 --- a/kernel/mutex.c
82286 +++ b/kernel/mutex.c
82287 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
82288 node->locked = 1;
82289 return;
82290 }
82291 - ACCESS_ONCE(prev->next) = node;
82292 + ACCESS_ONCE_RW(prev->next) = node;
82293 smp_wmb();
82294 /* Wait until the lock holder passes the lock down */
82295 while (!ACCESS_ONCE(node->locked))
82296 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
82297 while (!(next = ACCESS_ONCE(node->next)))
82298 arch_mutex_cpu_relax();
82299 }
82300 - ACCESS_ONCE(next->locked) = 1;
82301 + ACCESS_ONCE_RW(next->locked) = 1;
82302 smp_wmb();
82303 }
82304
82305 @@ -514,7 +514,7 @@ slowpath:
82306 spin_lock_mutex(&lock->wait_lock, flags);
82307
82308 debug_mutex_lock_common(lock, &waiter);
82309 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
82310 + debug_mutex_add_waiter(lock, &waiter, task);
82311
82312 /* add waiting tasks to the end of the waitqueue (FIFO): */
82313 list_add_tail(&waiter.list, &lock->wait_list);
82314 @@ -565,7 +565,7 @@ slowpath:
82315 done:
82316 lock_acquired(&lock->dep_map, ip);
82317 /* got the lock - rejoice! */
82318 - mutex_remove_waiter(lock, &waiter, current_thread_info());
82319 + mutex_remove_waiter(lock, &waiter, task);
82320 mutex_set_owner(lock);
82321
82322 if (!__builtin_constant_p(ww_ctx == NULL)) {
82323 @@ -604,7 +604,7 @@ done:
82324 return 0;
82325
82326 err:
82327 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
82328 + mutex_remove_waiter(lock, &waiter, task);
82329 spin_unlock_mutex(&lock->wait_lock, flags);
82330 debug_mutex_free_waiter(&waiter);
82331 mutex_release(&lock->dep_map, 1, ip);
82332 diff --git a/kernel/notifier.c b/kernel/notifier.c
82333 index 2d5cc4c..d9ea600 100644
82334 --- a/kernel/notifier.c
82335 +++ b/kernel/notifier.c
82336 @@ -5,6 +5,7 @@
82337 #include <linux/rcupdate.h>
82338 #include <linux/vmalloc.h>
82339 #include <linux/reboot.h>
82340 +#include <linux/mm.h>
82341
82342 /*
82343 * Notifier list for kernel code which wants to be called
82344 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
82345 while ((*nl) != NULL) {
82346 if (n->priority > (*nl)->priority)
82347 break;
82348 - nl = &((*nl)->next);
82349 + nl = (struct notifier_block **)&((*nl)->next);
82350 }
82351 - n->next = *nl;
82352 + pax_open_kernel();
82353 + *(const void **)&n->next = *nl;
82354 rcu_assign_pointer(*nl, n);
82355 + pax_close_kernel();
82356 return 0;
82357 }
82358
82359 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
82360 return 0;
82361 if (n->priority > (*nl)->priority)
82362 break;
82363 - nl = &((*nl)->next);
82364 + nl = (struct notifier_block **)&((*nl)->next);
82365 }
82366 - n->next = *nl;
82367 + pax_open_kernel();
82368 + *(const void **)&n->next = *nl;
82369 rcu_assign_pointer(*nl, n);
82370 + pax_close_kernel();
82371 return 0;
82372 }
82373
82374 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
82375 {
82376 while ((*nl) != NULL) {
82377 if ((*nl) == n) {
82378 + pax_open_kernel();
82379 rcu_assign_pointer(*nl, n->next);
82380 + pax_close_kernel();
82381 return 0;
82382 }
82383 - nl = &((*nl)->next);
82384 + nl = (struct notifier_block **)&((*nl)->next);
82385 }
82386 return -ENOENT;
82387 }
82388 diff --git a/kernel/panic.c b/kernel/panic.c
82389 index 8018646..b6a5b4f 100644
82390 --- a/kernel/panic.c
82391 +++ b/kernel/panic.c
82392 @@ -403,7 +403,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
82393 disable_trace_on_warning();
82394
82395 pr_warn("------------[ cut here ]------------\n");
82396 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
82397 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
82398 raw_smp_processor_id(), current->pid, file, line, caller);
82399
82400 if (args)
82401 @@ -457,7 +457,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
82402 */
82403 void __stack_chk_fail(void)
82404 {
82405 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
82406 + dump_stack();
82407 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
82408 __builtin_return_address(0));
82409 }
82410 EXPORT_SYMBOL(__stack_chk_fail);
82411 diff --git a/kernel/pid.c b/kernel/pid.c
82412 index ebe5e80..5d6d634 100644
82413 --- a/kernel/pid.c
82414 +++ b/kernel/pid.c
82415 @@ -33,6 +33,7 @@
82416 #include <linux/rculist.h>
82417 #include <linux/bootmem.h>
82418 #include <linux/hash.h>
82419 +#include <linux/security.h>
82420 #include <linux/pid_namespace.h>
82421 #include <linux/init_task.h>
82422 #include <linux/syscalls.h>
82423 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
82424
82425 int pid_max = PID_MAX_DEFAULT;
82426
82427 -#define RESERVED_PIDS 300
82428 +#define RESERVED_PIDS 500
82429
82430 int pid_max_min = RESERVED_PIDS + 1;
82431 int pid_max_max = PID_MAX_LIMIT;
82432 @@ -440,10 +441,18 @@ EXPORT_SYMBOL(pid_task);
82433 */
82434 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
82435 {
82436 + struct task_struct *task;
82437 +
82438 rcu_lockdep_assert(rcu_read_lock_held(),
82439 "find_task_by_pid_ns() needs rcu_read_lock()"
82440 " protection");
82441 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82442 +
82443 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
82444 +
82445 + if (gr_pid_is_chrooted(task))
82446 + return NULL;
82447 +
82448 + return task;
82449 }
82450
82451 struct task_struct *find_task_by_vpid(pid_t vnr)
82452 @@ -451,6 +460,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
82453 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
82454 }
82455
82456 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
82457 +{
82458 + rcu_lockdep_assert(rcu_read_lock_held(),
82459 + "find_task_by_pid_ns() needs rcu_read_lock()"
82460 + " protection");
82461 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
82462 +}
82463 +
82464 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
82465 {
82466 struct pid *pid;
82467 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
82468 index 601bb36..f7e6f34 100644
82469 --- a/kernel/pid_namespace.c
82470 +++ b/kernel/pid_namespace.c
82471 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
82472 void __user *buffer, size_t *lenp, loff_t *ppos)
82473 {
82474 struct pid_namespace *pid_ns = task_active_pid_ns(current);
82475 - struct ctl_table tmp = *table;
82476 + ctl_table_no_const tmp = *table;
82477
82478 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
82479 return -EPERM;
82480 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
82481 index c7f31aa..2b44977 100644
82482 --- a/kernel/posix-cpu-timers.c
82483 +++ b/kernel/posix-cpu-timers.c
82484 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
82485
82486 static __init int init_posix_cpu_timers(void)
82487 {
82488 - struct k_clock process = {
82489 + static struct k_clock process = {
82490 .clock_getres = process_cpu_clock_getres,
82491 .clock_get = process_cpu_clock_get,
82492 .timer_create = process_cpu_timer_create,
82493 .nsleep = process_cpu_nsleep,
82494 .nsleep_restart = process_cpu_nsleep_restart,
82495 };
82496 - struct k_clock thread = {
82497 + static struct k_clock thread = {
82498 .clock_getres = thread_cpu_clock_getres,
82499 .clock_get = thread_cpu_clock_get,
82500 .timer_create = thread_cpu_timer_create,
82501 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
82502 index 424c2d4..679242f 100644
82503 --- a/kernel/posix-timers.c
82504 +++ b/kernel/posix-timers.c
82505 @@ -43,6 +43,7 @@
82506 #include <linux/hash.h>
82507 #include <linux/posix-clock.h>
82508 #include <linux/posix-timers.h>
82509 +#include <linux/grsecurity.h>
82510 #include <linux/syscalls.h>
82511 #include <linux/wait.h>
82512 #include <linux/workqueue.h>
82513 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
82514 * which we beg off on and pass to do_sys_settimeofday().
82515 */
82516
82517 -static struct k_clock posix_clocks[MAX_CLOCKS];
82518 +static struct k_clock *posix_clocks[MAX_CLOCKS];
82519
82520 /*
82521 * These ones are defined below.
82522 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
82523 */
82524 static __init int init_posix_timers(void)
82525 {
82526 - struct k_clock clock_realtime = {
82527 + static struct k_clock clock_realtime = {
82528 .clock_getres = hrtimer_get_res,
82529 .clock_get = posix_clock_realtime_get,
82530 .clock_set = posix_clock_realtime_set,
82531 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
82532 .timer_get = common_timer_get,
82533 .timer_del = common_timer_del,
82534 };
82535 - struct k_clock clock_monotonic = {
82536 + static struct k_clock clock_monotonic = {
82537 .clock_getres = hrtimer_get_res,
82538 .clock_get = posix_ktime_get_ts,
82539 .nsleep = common_nsleep,
82540 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
82541 .timer_get = common_timer_get,
82542 .timer_del = common_timer_del,
82543 };
82544 - struct k_clock clock_monotonic_raw = {
82545 + static struct k_clock clock_monotonic_raw = {
82546 .clock_getres = hrtimer_get_res,
82547 .clock_get = posix_get_monotonic_raw,
82548 };
82549 - struct k_clock clock_realtime_coarse = {
82550 + static struct k_clock clock_realtime_coarse = {
82551 .clock_getres = posix_get_coarse_res,
82552 .clock_get = posix_get_realtime_coarse,
82553 };
82554 - struct k_clock clock_monotonic_coarse = {
82555 + static struct k_clock clock_monotonic_coarse = {
82556 .clock_getres = posix_get_coarse_res,
82557 .clock_get = posix_get_monotonic_coarse,
82558 };
82559 - struct k_clock clock_tai = {
82560 + static struct k_clock clock_tai = {
82561 .clock_getres = hrtimer_get_res,
82562 .clock_get = posix_get_tai,
82563 .nsleep = common_nsleep,
82564 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
82565 .timer_get = common_timer_get,
82566 .timer_del = common_timer_del,
82567 };
82568 - struct k_clock clock_boottime = {
82569 + static struct k_clock clock_boottime = {
82570 .clock_getres = hrtimer_get_res,
82571 .clock_get = posix_get_boottime,
82572 .nsleep = common_nsleep,
82573 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
82574 return;
82575 }
82576
82577 - posix_clocks[clock_id] = *new_clock;
82578 + posix_clocks[clock_id] = new_clock;
82579 }
82580 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
82581
82582 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
82583 return (id & CLOCKFD_MASK) == CLOCKFD ?
82584 &clock_posix_dynamic : &clock_posix_cpu;
82585
82586 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
82587 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
82588 return NULL;
82589 - return &posix_clocks[id];
82590 + return posix_clocks[id];
82591 }
82592
82593 static int common_timer_create(struct k_itimer *new_timer)
82594 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
82595 struct k_clock *kc = clockid_to_kclock(which_clock);
82596 struct k_itimer *new_timer;
82597 int error, new_timer_id;
82598 - sigevent_t event;
82599 + sigevent_t event = { };
82600 int it_id_set = IT_ID_NOT_SET;
82601
82602 if (!kc)
82603 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
82604 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
82605 return -EFAULT;
82606
82607 + /* only the CLOCK_REALTIME clock can be set, all other clocks
82608 + have their clock_set fptr set to a nosettime dummy function
82609 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
82610 + call common_clock_set, which calls do_sys_settimeofday, which
82611 + we hook
82612 + */
82613 +
82614 return kc->clock_set(which_clock, &new_tp);
82615 }
82616
82617 diff --git a/kernel/power/process.c b/kernel/power/process.c
82618 index 06ec886..9dba35e 100644
82619 --- a/kernel/power/process.c
82620 +++ b/kernel/power/process.c
82621 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
82622 unsigned int elapsed_msecs;
82623 bool wakeup = false;
82624 int sleep_usecs = USEC_PER_MSEC;
82625 + bool timedout = false;
82626
82627 do_gettimeofday(&start);
82628
82629 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
82630
82631 while (true) {
82632 todo = 0;
82633 + if (time_after(jiffies, end_time))
82634 + timedout = true;
82635 read_lock(&tasklist_lock);
82636 do_each_thread(g, p) {
82637 if (p == current || !freeze_task(p))
82638 continue;
82639
82640 - if (!freezer_should_skip(p))
82641 + if (!freezer_should_skip(p)) {
82642 todo++;
82643 + if (timedout) {
82644 + printk(KERN_ERR "Task refusing to freeze:\n");
82645 + sched_show_task(p);
82646 + }
82647 + }
82648 } while_each_thread(g, p);
82649 read_unlock(&tasklist_lock);
82650
82651 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
82652 todo += wq_busy;
82653 }
82654
82655 - if (!todo || time_after(jiffies, end_time))
82656 + if (!todo || timedout)
82657 break;
82658
82659 if (pm_wakeup_pending()) {
82660 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
82661 index 5b5a708..ec7637e 100644
82662 --- a/kernel/printk/printk.c
82663 +++ b/kernel/printk/printk.c
82664 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
82665 if (from_file && type != SYSLOG_ACTION_OPEN)
82666 return 0;
82667
82668 +#ifdef CONFIG_GRKERNSEC_DMESG
82669 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
82670 + return -EPERM;
82671 +#endif
82672 +
82673 if (syslog_action_restricted(type)) {
82674 if (capable(CAP_SYSLOG))
82675 return 0;
82676 diff --git a/kernel/profile.c b/kernel/profile.c
82677 index 6631e1e..310c266 100644
82678 --- a/kernel/profile.c
82679 +++ b/kernel/profile.c
82680 @@ -37,7 +37,7 @@ struct profile_hit {
82681 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
82682 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
82683
82684 -static atomic_t *prof_buffer;
82685 +static atomic_unchecked_t *prof_buffer;
82686 static unsigned long prof_len, prof_shift;
82687
82688 int prof_on __read_mostly;
82689 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
82690 hits[i].pc = 0;
82691 continue;
82692 }
82693 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82694 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82695 hits[i].hits = hits[i].pc = 0;
82696 }
82697 }
82698 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82699 * Add the current hit(s) and flush the write-queue out
82700 * to the global buffer:
82701 */
82702 - atomic_add(nr_hits, &prof_buffer[pc]);
82703 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
82704 for (i = 0; i < NR_PROFILE_HIT; ++i) {
82705 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
82706 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
82707 hits[i].pc = hits[i].hits = 0;
82708 }
82709 out:
82710 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
82711 {
82712 unsigned long pc;
82713 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
82714 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82715 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
82716 }
82717 #endif /* !CONFIG_SMP */
82718
82719 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
82720 return -EFAULT;
82721 buf++; p++; count--; read++;
82722 }
82723 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
82724 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
82725 if (copy_to_user(buf, (void *)pnt, count))
82726 return -EFAULT;
82727 read += count;
82728 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
82729 }
82730 #endif
82731 profile_discard_flip_buffers();
82732 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
82733 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
82734 return count;
82735 }
82736
82737 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
82738 index a146ee3..ffed4c3 100644
82739 --- a/kernel/ptrace.c
82740 +++ b/kernel/ptrace.c
82741 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
82742 if (seize)
82743 flags |= PT_SEIZED;
82744 rcu_read_lock();
82745 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82746 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
82747 flags |= PT_PTRACE_CAP;
82748 rcu_read_unlock();
82749 task->ptrace = flags;
82750 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
82751 break;
82752 return -EIO;
82753 }
82754 - if (copy_to_user(dst, buf, retval))
82755 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
82756 return -EFAULT;
82757 copied += retval;
82758 src += retval;
82759 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
82760 bool seized = child->ptrace & PT_SEIZED;
82761 int ret = -EIO;
82762 siginfo_t siginfo, *si;
82763 - void __user *datavp = (void __user *) data;
82764 + void __user *datavp = (__force void __user *) data;
82765 unsigned long __user *datalp = datavp;
82766 unsigned long flags;
82767
82768 @@ -1051,14 +1051,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
82769 goto out;
82770 }
82771
82772 + if (gr_handle_ptrace(child, request)) {
82773 + ret = -EPERM;
82774 + goto out_put_task_struct;
82775 + }
82776 +
82777 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82778 ret = ptrace_attach(child, request, addr, data);
82779 /*
82780 * Some architectures need to do book-keeping after
82781 * a ptrace attach.
82782 */
82783 - if (!ret)
82784 + if (!ret) {
82785 arch_ptrace_attach(child);
82786 + gr_audit_ptrace(child);
82787 + }
82788 goto out_put_task_struct;
82789 }
82790
82791 @@ -1086,7 +1093,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
82792 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
82793 if (copied != sizeof(tmp))
82794 return -EIO;
82795 - return put_user(tmp, (unsigned long __user *)data);
82796 + return put_user(tmp, (__force unsigned long __user *)data);
82797 }
82798
82799 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
82800 @@ -1180,7 +1187,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
82801 }
82802
82803 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82804 - compat_long_t addr, compat_long_t data)
82805 + compat_ulong_t addr, compat_ulong_t data)
82806 {
82807 struct task_struct *child;
82808 long ret;
82809 @@ -1196,14 +1203,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
82810 goto out;
82811 }
82812
82813 + if (gr_handle_ptrace(child, request)) {
82814 + ret = -EPERM;
82815 + goto out_put_task_struct;
82816 + }
82817 +
82818 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
82819 ret = ptrace_attach(child, request, addr, data);
82820 /*
82821 * Some architectures need to do book-keeping after
82822 * a ptrace attach.
82823 */
82824 - if (!ret)
82825 + if (!ret) {
82826 arch_ptrace_attach(child);
82827 + gr_audit_ptrace(child);
82828 + }
82829 goto out_put_task_struct;
82830 }
82831
82832 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
82833 index cce6ba8..7c758b1f 100644
82834 --- a/kernel/rcupdate.c
82835 +++ b/kernel/rcupdate.c
82836 @@ -412,10 +412,10 @@ int rcu_jiffies_till_stall_check(void)
82837 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
82838 */
82839 if (till_stall_check < 3) {
82840 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
82841 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
82842 till_stall_check = 3;
82843 } else if (till_stall_check > 300) {
82844 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
82845 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
82846 till_stall_check = 300;
82847 }
82848 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
82849 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
82850 index aa34411..4832cd4 100644
82851 --- a/kernel/rcutiny.c
82852 +++ b/kernel/rcutiny.c
82853 @@ -45,7 +45,7 @@
82854 /* Forward declarations for rcutiny_plugin.h. */
82855 struct rcu_ctrlblk;
82856 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
82857 -static void rcu_process_callbacks(struct softirq_action *unused);
82858 +static void rcu_process_callbacks(void);
82859 static void __call_rcu(struct rcu_head *head,
82860 void (*func)(struct rcu_head *rcu),
82861 struct rcu_ctrlblk *rcp);
82862 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
82863 false));
82864 }
82865
82866 -static void rcu_process_callbacks(struct softirq_action *unused)
82867 +static __latent_entropy void rcu_process_callbacks(void)
82868 {
82869 __rcu_process_callbacks(&rcu_sched_ctrlblk);
82870 __rcu_process_callbacks(&rcu_bh_ctrlblk);
82871 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
82872 index f4871e5..8ef5741 100644
82873 --- a/kernel/rcutorture.c
82874 +++ b/kernel/rcutorture.c
82875 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
82876 { 0 };
82877 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
82878 { 0 };
82879 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82880 -static atomic_t n_rcu_torture_alloc;
82881 -static atomic_t n_rcu_torture_alloc_fail;
82882 -static atomic_t n_rcu_torture_free;
82883 -static atomic_t n_rcu_torture_mberror;
82884 -static atomic_t n_rcu_torture_error;
82885 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
82886 +static atomic_unchecked_t n_rcu_torture_alloc;
82887 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
82888 +static atomic_unchecked_t n_rcu_torture_free;
82889 +static atomic_unchecked_t n_rcu_torture_mberror;
82890 +static atomic_unchecked_t n_rcu_torture_error;
82891 static long n_rcu_torture_barrier_error;
82892 static long n_rcu_torture_boost_ktrerror;
82893 static long n_rcu_torture_boost_rterror;
82894 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
82895
82896 spin_lock_bh(&rcu_torture_lock);
82897 if (list_empty(&rcu_torture_freelist)) {
82898 - atomic_inc(&n_rcu_torture_alloc_fail);
82899 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
82900 spin_unlock_bh(&rcu_torture_lock);
82901 return NULL;
82902 }
82903 - atomic_inc(&n_rcu_torture_alloc);
82904 + atomic_inc_unchecked(&n_rcu_torture_alloc);
82905 p = rcu_torture_freelist.next;
82906 list_del_init(p);
82907 spin_unlock_bh(&rcu_torture_lock);
82908 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
82909 static void
82910 rcu_torture_free(struct rcu_torture *p)
82911 {
82912 - atomic_inc(&n_rcu_torture_free);
82913 + atomic_inc_unchecked(&n_rcu_torture_free);
82914 spin_lock_bh(&rcu_torture_lock);
82915 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
82916 spin_unlock_bh(&rcu_torture_lock);
82917 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
82918 i = rp->rtort_pipe_count;
82919 if (i > RCU_TORTURE_PIPE_LEN)
82920 i = RCU_TORTURE_PIPE_LEN;
82921 - atomic_inc(&rcu_torture_wcount[i]);
82922 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82923 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82924 rp->rtort_mbtest = 0;
82925 rcu_torture_free(rp);
82926 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
82927 i = rp->rtort_pipe_count;
82928 if (i > RCU_TORTURE_PIPE_LEN)
82929 i = RCU_TORTURE_PIPE_LEN;
82930 - atomic_inc(&rcu_torture_wcount[i]);
82931 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82932 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
82933 rp->rtort_mbtest = 0;
82934 list_del(&rp->rtort_free);
82935 @@ -952,7 +952,7 @@ rcu_torture_writer(void *arg)
82936 i = old_rp->rtort_pipe_count;
82937 if (i > RCU_TORTURE_PIPE_LEN)
82938 i = RCU_TORTURE_PIPE_LEN;
82939 - atomic_inc(&rcu_torture_wcount[i]);
82940 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
82941 old_rp->rtort_pipe_count++;
82942 cur_ops->deferred_free(old_rp);
82943 }
82944 @@ -1038,7 +1038,7 @@ static void rcu_torture_timer(unsigned long unused)
82945 return;
82946 }
82947 if (p->rtort_mbtest == 0)
82948 - atomic_inc(&n_rcu_torture_mberror);
82949 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82950 spin_lock(&rand_lock);
82951 cur_ops->read_delay(&rand);
82952 n_rcu_torture_timers++;
82953 @@ -1108,7 +1108,7 @@ rcu_torture_reader(void *arg)
82954 continue;
82955 }
82956 if (p->rtort_mbtest == 0)
82957 - atomic_inc(&n_rcu_torture_mberror);
82958 + atomic_inc_unchecked(&n_rcu_torture_mberror);
82959 cur_ops->read_delay(&rand);
82960 preempt_disable();
82961 pipe_count = p->rtort_pipe_count;
82962 @@ -1171,11 +1171,11 @@ rcu_torture_printk(char *page)
82963 rcu_torture_current,
82964 rcu_torture_current_version,
82965 list_empty(&rcu_torture_freelist),
82966 - atomic_read(&n_rcu_torture_alloc),
82967 - atomic_read(&n_rcu_torture_alloc_fail),
82968 - atomic_read(&n_rcu_torture_free));
82969 + atomic_read_unchecked(&n_rcu_torture_alloc),
82970 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
82971 + atomic_read_unchecked(&n_rcu_torture_free));
82972 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
82973 - atomic_read(&n_rcu_torture_mberror),
82974 + atomic_read_unchecked(&n_rcu_torture_mberror),
82975 n_rcu_torture_boost_ktrerror,
82976 n_rcu_torture_boost_rterror);
82977 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
82978 @@ -1194,14 +1194,14 @@ rcu_torture_printk(char *page)
82979 n_barrier_attempts,
82980 n_rcu_torture_barrier_error);
82981 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
82982 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
82983 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
82984 n_rcu_torture_barrier_error != 0 ||
82985 n_rcu_torture_boost_ktrerror != 0 ||
82986 n_rcu_torture_boost_rterror != 0 ||
82987 n_rcu_torture_boost_failure != 0 ||
82988 i > 1) {
82989 cnt += sprintf(&page[cnt], "!!! ");
82990 - atomic_inc(&n_rcu_torture_error);
82991 + atomic_inc_unchecked(&n_rcu_torture_error);
82992 WARN_ON_ONCE(1);
82993 }
82994 cnt += sprintf(&page[cnt], "Reader Pipe: ");
82995 @@ -1215,7 +1215,7 @@ rcu_torture_printk(char *page)
82996 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
82997 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
82998 cnt += sprintf(&page[cnt], " %d",
82999 - atomic_read(&rcu_torture_wcount[i]));
83000 + atomic_read_unchecked(&rcu_torture_wcount[i]));
83001 }
83002 cnt += sprintf(&page[cnt], "\n");
83003 if (cur_ops->stats)
83004 @@ -1924,7 +1924,7 @@ rcu_torture_cleanup(void)
83005
83006 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
83007
83008 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83009 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
83010 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
83011 else if (n_online_successes != n_online_attempts ||
83012 n_offline_successes != n_offline_attempts)
83013 @@ -1992,18 +1992,18 @@ rcu_torture_init(void)
83014
83015 rcu_torture_current = NULL;
83016 rcu_torture_current_version = 0;
83017 - atomic_set(&n_rcu_torture_alloc, 0);
83018 - atomic_set(&n_rcu_torture_alloc_fail, 0);
83019 - atomic_set(&n_rcu_torture_free, 0);
83020 - atomic_set(&n_rcu_torture_mberror, 0);
83021 - atomic_set(&n_rcu_torture_error, 0);
83022 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
83023 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
83024 + atomic_set_unchecked(&n_rcu_torture_free, 0);
83025 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
83026 + atomic_set_unchecked(&n_rcu_torture_error, 0);
83027 n_rcu_torture_barrier_error = 0;
83028 n_rcu_torture_boost_ktrerror = 0;
83029 n_rcu_torture_boost_rterror = 0;
83030 n_rcu_torture_boost_failure = 0;
83031 n_rcu_torture_boosts = 0;
83032 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
83033 - atomic_set(&rcu_torture_wcount[i], 0);
83034 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
83035 for_each_possible_cpu(cpu) {
83036 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
83037 per_cpu(rcu_torture_count, cpu)[i] = 0;
83038 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
83039 index 068de3a..5e7db2f 100644
83040 --- a/kernel/rcutree.c
83041 +++ b/kernel/rcutree.c
83042 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
83043 rcu_prepare_for_idle(smp_processor_id());
83044 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83045 smp_mb__before_atomic_inc(); /* See above. */
83046 - atomic_inc(&rdtp->dynticks);
83047 + atomic_inc_unchecked(&rdtp->dynticks);
83048 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
83049 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83050 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83051
83052 /*
83053 * It is illegal to enter an extended quiescent state while
83054 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
83055 int user)
83056 {
83057 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
83058 - atomic_inc(&rdtp->dynticks);
83059 + atomic_inc_unchecked(&rdtp->dynticks);
83060 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83061 smp_mb__after_atomic_inc(); /* See above. */
83062 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83063 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83064 rcu_cleanup_after_idle(smp_processor_id());
83065 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
83066 if (!user && !is_idle_task(current)) {
83067 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
83068 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
83069
83070 if (rdtp->dynticks_nmi_nesting == 0 &&
83071 - (atomic_read(&rdtp->dynticks) & 0x1))
83072 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
83073 return;
83074 rdtp->dynticks_nmi_nesting++;
83075 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
83076 - atomic_inc(&rdtp->dynticks);
83077 + atomic_inc_unchecked(&rdtp->dynticks);
83078 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
83079 smp_mb__after_atomic_inc(); /* See above. */
83080 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
83081 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
83082 }
83083
83084 /**
83085 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
83086 return;
83087 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
83088 smp_mb__before_atomic_inc(); /* See above. */
83089 - atomic_inc(&rdtp->dynticks);
83090 + atomic_inc_unchecked(&rdtp->dynticks);
83091 smp_mb__after_atomic_inc(); /* Force delay to next write. */
83092 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
83093 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
83094 }
83095
83096 /**
83097 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
83098 int ret;
83099
83100 preempt_disable();
83101 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83102 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
83103 preempt_enable();
83104 return ret;
83105 }
83106 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
83107 */
83108 static int dyntick_save_progress_counter(struct rcu_data *rdp)
83109 {
83110 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
83111 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83112 return (rdp->dynticks_snap & 0x1) == 0;
83113 }
83114
83115 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
83116 unsigned int curr;
83117 unsigned int snap;
83118
83119 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
83120 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
83121 snap = (unsigned int)rdp->dynticks_snap;
83122
83123 /*
83124 @@ -1351,9 +1351,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
83125 rdp = this_cpu_ptr(rsp->rda);
83126 rcu_preempt_check_blocked_tasks(rnp);
83127 rnp->qsmask = rnp->qsmaskinit;
83128 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
83129 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
83130 WARN_ON_ONCE(rnp->completed != rsp->completed);
83131 - ACCESS_ONCE(rnp->completed) = rsp->completed;
83132 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
83133 if (rnp == rdp->mynode)
83134 __note_gp_changes(rsp, rnp, rdp);
83135 rcu_preempt_boost_start_gp(rnp);
83136 @@ -1435,7 +1435,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
83137 */
83138 rcu_for_each_node_breadth_first(rsp, rnp) {
83139 raw_spin_lock_irq(&rnp->lock);
83140 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
83141 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
83142 rdp = this_cpu_ptr(rsp->rda);
83143 if (rnp == rdp->mynode)
83144 __note_gp_changes(rsp, rnp, rdp);
83145 @@ -1765,7 +1765,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
83146 rsp->qlen += rdp->qlen;
83147 rdp->n_cbs_orphaned += rdp->qlen;
83148 rdp->qlen_lazy = 0;
83149 - ACCESS_ONCE(rdp->qlen) = 0;
83150 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83151 }
83152
83153 /*
83154 @@ -2011,7 +2011,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
83155 }
83156 smp_mb(); /* List handling before counting for rcu_barrier(). */
83157 rdp->qlen_lazy -= count_lazy;
83158 - ACCESS_ONCE(rdp->qlen) -= count;
83159 + ACCESS_ONCE_RW(rdp->qlen) -= count;
83160 rdp->n_cbs_invoked += count;
83161
83162 /* Reinstate batch limit if we have worked down the excess. */
83163 @@ -2202,7 +2202,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
83164 /*
83165 * Do RCU core processing for the current CPU.
83166 */
83167 -static void rcu_process_callbacks(struct softirq_action *unused)
83168 +static __latent_entropy void rcu_process_callbacks(void)
83169 {
83170 struct rcu_state *rsp;
83171
83172 @@ -2325,7 +2325,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
83173 local_irq_restore(flags);
83174 return;
83175 }
83176 - ACCESS_ONCE(rdp->qlen)++;
83177 + ACCESS_ONCE_RW(rdp->qlen)++;
83178 if (lazy)
83179 rdp->qlen_lazy++;
83180 else
83181 @@ -2534,11 +2534,11 @@ void synchronize_sched_expedited(void)
83182 * counter wrap on a 32-bit system. Quite a few more CPUs would of
83183 * course be required on a 64-bit system.
83184 */
83185 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
83186 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
83187 (ulong)atomic_long_read(&rsp->expedited_done) +
83188 ULONG_MAX / 8)) {
83189 synchronize_sched();
83190 - atomic_long_inc(&rsp->expedited_wrap);
83191 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
83192 return;
83193 }
83194
83195 @@ -2546,7 +2546,7 @@ void synchronize_sched_expedited(void)
83196 * Take a ticket. Note that atomic_inc_return() implies a
83197 * full memory barrier.
83198 */
83199 - snap = atomic_long_inc_return(&rsp->expedited_start);
83200 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
83201 firstsnap = snap;
83202 get_online_cpus();
83203 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
83204 @@ -2559,14 +2559,14 @@ void synchronize_sched_expedited(void)
83205 synchronize_sched_expedited_cpu_stop,
83206 NULL) == -EAGAIN) {
83207 put_online_cpus();
83208 - atomic_long_inc(&rsp->expedited_tryfail);
83209 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
83210
83211 /* Check to see if someone else did our work for us. */
83212 s = atomic_long_read(&rsp->expedited_done);
83213 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83214 /* ensure test happens before caller kfree */
83215 smp_mb__before_atomic_inc(); /* ^^^ */
83216 - atomic_long_inc(&rsp->expedited_workdone1);
83217 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
83218 return;
83219 }
83220
83221 @@ -2575,7 +2575,7 @@ void synchronize_sched_expedited(void)
83222 udelay(trycount * num_online_cpus());
83223 } else {
83224 wait_rcu_gp(call_rcu_sched);
83225 - atomic_long_inc(&rsp->expedited_normal);
83226 + atomic_long_inc_unchecked(&rsp->expedited_normal);
83227 return;
83228 }
83229
83230 @@ -2584,7 +2584,7 @@ void synchronize_sched_expedited(void)
83231 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
83232 /* ensure test happens before caller kfree */
83233 smp_mb__before_atomic_inc(); /* ^^^ */
83234 - atomic_long_inc(&rsp->expedited_workdone2);
83235 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
83236 return;
83237 }
83238
83239 @@ -2596,10 +2596,10 @@ void synchronize_sched_expedited(void)
83240 * period works for us.
83241 */
83242 get_online_cpus();
83243 - snap = atomic_long_read(&rsp->expedited_start);
83244 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
83245 smp_mb(); /* ensure read is before try_stop_cpus(). */
83246 }
83247 - atomic_long_inc(&rsp->expedited_stoppedcpus);
83248 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
83249
83250 /*
83251 * Everyone up to our most recent fetch is covered by our grace
83252 @@ -2608,16 +2608,16 @@ void synchronize_sched_expedited(void)
83253 * than we did already did their update.
83254 */
83255 do {
83256 - atomic_long_inc(&rsp->expedited_done_tries);
83257 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
83258 s = atomic_long_read(&rsp->expedited_done);
83259 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
83260 /* ensure test happens before caller kfree */
83261 smp_mb__before_atomic_inc(); /* ^^^ */
83262 - atomic_long_inc(&rsp->expedited_done_lost);
83263 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
83264 break;
83265 }
83266 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
83267 - atomic_long_inc(&rsp->expedited_done_exit);
83268 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
83269
83270 put_online_cpus();
83271 }
83272 @@ -2799,7 +2799,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83273 * ACCESS_ONCE() to prevent the compiler from speculating
83274 * the increment to precede the early-exit check.
83275 */
83276 - ACCESS_ONCE(rsp->n_barrier_done)++;
83277 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83278 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
83279 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
83280 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
83281 @@ -2849,7 +2849,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
83282
83283 /* Increment ->n_barrier_done to prevent duplicate work. */
83284 smp_mb(); /* Keep increment after above mechanism. */
83285 - ACCESS_ONCE(rsp->n_barrier_done)++;
83286 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
83287 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
83288 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
83289 smp_mb(); /* Keep increment before caller's subsequent code. */
83290 @@ -2894,10 +2894,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
83291 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
83292 init_callback_list(rdp);
83293 rdp->qlen_lazy = 0;
83294 - ACCESS_ONCE(rdp->qlen) = 0;
83295 + ACCESS_ONCE_RW(rdp->qlen) = 0;
83296 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
83297 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
83298 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
83299 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
83300 rdp->cpu = cpu;
83301 rdp->rsp = rsp;
83302 rcu_boot_init_nocb_percpu_data(rdp);
83303 @@ -2930,8 +2930,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
83304 rdp->blimit = blimit;
83305 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
83306 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
83307 - atomic_set(&rdp->dynticks->dynticks,
83308 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
83309 + atomic_set_unchecked(&rdp->dynticks->dynticks,
83310 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
83311 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
83312
83313 /* Add CPU to rcu_node bitmasks. */
83314 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
83315 index b383258..2440c1e 100644
83316 --- a/kernel/rcutree.h
83317 +++ b/kernel/rcutree.h
83318 @@ -87,7 +87,7 @@ struct rcu_dynticks {
83319 long long dynticks_nesting; /* Track irq/process nesting level. */
83320 /* Process level is worth LLONG_MAX/2. */
83321 int dynticks_nmi_nesting; /* Track NMI nesting level. */
83322 - atomic_t dynticks; /* Even value for idle, else odd. */
83323 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
83324 #ifdef CONFIG_RCU_FAST_NO_HZ
83325 bool all_lazy; /* Are all CPU's CBs lazy? */
83326 unsigned long nonlazy_posted;
83327 @@ -419,17 +419,17 @@ struct rcu_state {
83328 /* _rcu_barrier(). */
83329 /* End of fields guarded by barrier_mutex. */
83330
83331 - atomic_long_t expedited_start; /* Starting ticket. */
83332 - atomic_long_t expedited_done; /* Done ticket. */
83333 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
83334 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
83335 - atomic_long_t expedited_workdone1; /* # done by others #1. */
83336 - atomic_long_t expedited_workdone2; /* # done by others #2. */
83337 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
83338 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
83339 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
83340 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
83341 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
83342 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
83343 + atomic_long_t expedited_done; /* Done ticket. */
83344 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
83345 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
83346 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
83347 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
83348 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
83349 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
83350 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
83351 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
83352 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
83353
83354 unsigned long jiffies_force_qs; /* Time at which to invoke */
83355 /* force_quiescent_state(). */
83356 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
83357 index 769e12e..7b2139b 100644
83358 --- a/kernel/rcutree_plugin.h
83359 +++ b/kernel/rcutree_plugin.h
83360 @@ -902,7 +902,7 @@ void synchronize_rcu_expedited(void)
83361
83362 /* Clean up and exit. */
83363 smp_mb(); /* ensure expedited GP seen before counter increment. */
83364 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
83365 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
83366 unlock_mb_ret:
83367 mutex_unlock(&sync_rcu_preempt_exp_mutex);
83368 mb_ret:
83369 @@ -1476,7 +1476,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
83370 free_cpumask_var(cm);
83371 }
83372
83373 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
83374 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
83375 .store = &rcu_cpu_kthread_task,
83376 .thread_should_run = rcu_cpu_kthread_should_run,
83377 .thread_fn = rcu_cpu_kthread,
83378 @@ -1941,7 +1941,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
83379 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
83380 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
83381 cpu, ticks_value, ticks_title,
83382 - atomic_read(&rdtp->dynticks) & 0xfff,
83383 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
83384 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
83385 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
83386 fast_no_hz);
83387 @@ -2104,7 +2104,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
83388
83389 /* Enqueue the callback on the nocb list and update counts. */
83390 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
83391 - ACCESS_ONCE(*old_rhpp) = rhp;
83392 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
83393 atomic_long_add(rhcount, &rdp->nocb_q_count);
83394 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
83395
83396 @@ -2244,12 +2244,12 @@ static int rcu_nocb_kthread(void *arg)
83397 * Extract queued callbacks, update counts, and wait
83398 * for a grace period to elapse.
83399 */
83400 - ACCESS_ONCE(rdp->nocb_head) = NULL;
83401 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
83402 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
83403 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
83404 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
83405 - ACCESS_ONCE(rdp->nocb_p_count) += c;
83406 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
83407 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
83408 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
83409 rcu_nocb_wait_gp(rdp);
83410
83411 /* Each pass through the following loop invokes a callback. */
83412 @@ -2271,8 +2271,8 @@ static int rcu_nocb_kthread(void *arg)
83413 list = next;
83414 }
83415 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
83416 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
83417 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
83418 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
83419 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
83420 rdp->n_nocbs_invoked += c;
83421 }
83422 return 0;
83423 @@ -2299,7 +2299,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
83424 t = kthread_run(rcu_nocb_kthread, rdp,
83425 "rcuo%c/%d", rsp->abbr, cpu);
83426 BUG_ON(IS_ERR(t));
83427 - ACCESS_ONCE(rdp->nocb_kthread) = t;
83428 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
83429 }
83430 }
83431
83432 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
83433 index cf6c174..a8f4b50 100644
83434 --- a/kernel/rcutree_trace.c
83435 +++ b/kernel/rcutree_trace.c
83436 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
83437 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
83438 rdp->passed_quiesce, rdp->qs_pending);
83439 seq_printf(m, " dt=%d/%llx/%d df=%lu",
83440 - atomic_read(&rdp->dynticks->dynticks),
83441 + atomic_read_unchecked(&rdp->dynticks->dynticks),
83442 rdp->dynticks->dynticks_nesting,
83443 rdp->dynticks->dynticks_nmi_nesting,
83444 rdp->dynticks_fqs);
83445 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
83446 struct rcu_state *rsp = (struct rcu_state *)m->private;
83447
83448 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",
83449 - atomic_long_read(&rsp->expedited_start),
83450 + atomic_long_read_unchecked(&rsp->expedited_start),
83451 atomic_long_read(&rsp->expedited_done),
83452 - atomic_long_read(&rsp->expedited_wrap),
83453 - atomic_long_read(&rsp->expedited_tryfail),
83454 - atomic_long_read(&rsp->expedited_workdone1),
83455 - atomic_long_read(&rsp->expedited_workdone2),
83456 - atomic_long_read(&rsp->expedited_normal),
83457 - atomic_long_read(&rsp->expedited_stoppedcpus),
83458 - atomic_long_read(&rsp->expedited_done_tries),
83459 - atomic_long_read(&rsp->expedited_done_lost),
83460 - atomic_long_read(&rsp->expedited_done_exit));
83461 + atomic_long_read_unchecked(&rsp->expedited_wrap),
83462 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
83463 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
83464 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
83465 + atomic_long_read_unchecked(&rsp->expedited_normal),
83466 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
83467 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
83468 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
83469 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
83470 return 0;
83471 }
83472
83473 diff --git a/kernel/resource.c b/kernel/resource.c
83474 index 3f285dc..5755f62 100644
83475 --- a/kernel/resource.c
83476 +++ b/kernel/resource.c
83477 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
83478
83479 static int __init ioresources_init(void)
83480 {
83481 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
83482 +#ifdef CONFIG_GRKERNSEC_PROC_USER
83483 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
83484 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
83485 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
83486 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
83487 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
83488 +#endif
83489 +#else
83490 proc_create("ioports", 0, NULL, &proc_ioports_operations);
83491 proc_create("iomem", 0, NULL, &proc_iomem_operations);
83492 +#endif
83493 return 0;
83494 }
83495 __initcall(ioresources_init);
83496 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
83497 index 1d96dd0..994ff19 100644
83498 --- a/kernel/rtmutex-tester.c
83499 +++ b/kernel/rtmutex-tester.c
83500 @@ -22,7 +22,7 @@
83501 #define MAX_RT_TEST_MUTEXES 8
83502
83503 static spinlock_t rttest_lock;
83504 -static atomic_t rttest_event;
83505 +static atomic_unchecked_t rttest_event;
83506
83507 struct test_thread_data {
83508 int opcode;
83509 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83510
83511 case RTTEST_LOCKCONT:
83512 td->mutexes[td->opdata] = 1;
83513 - td->event = atomic_add_return(1, &rttest_event);
83514 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83515 return 0;
83516
83517 case RTTEST_RESET:
83518 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83519 return 0;
83520
83521 case RTTEST_RESETEVENT:
83522 - atomic_set(&rttest_event, 0);
83523 + atomic_set_unchecked(&rttest_event, 0);
83524 return 0;
83525
83526 default:
83527 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83528 return ret;
83529
83530 td->mutexes[id] = 1;
83531 - td->event = atomic_add_return(1, &rttest_event);
83532 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83533 rt_mutex_lock(&mutexes[id]);
83534 - td->event = atomic_add_return(1, &rttest_event);
83535 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83536 td->mutexes[id] = 4;
83537 return 0;
83538
83539 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83540 return ret;
83541
83542 td->mutexes[id] = 1;
83543 - td->event = atomic_add_return(1, &rttest_event);
83544 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83545 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
83546 - td->event = atomic_add_return(1, &rttest_event);
83547 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83548 td->mutexes[id] = ret ? 0 : 4;
83549 return ret ? -EINTR : 0;
83550
83551 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
83552 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
83553 return ret;
83554
83555 - td->event = atomic_add_return(1, &rttest_event);
83556 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83557 rt_mutex_unlock(&mutexes[id]);
83558 - td->event = atomic_add_return(1, &rttest_event);
83559 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83560 td->mutexes[id] = 0;
83561 return 0;
83562
83563 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83564 break;
83565
83566 td->mutexes[dat] = 2;
83567 - td->event = atomic_add_return(1, &rttest_event);
83568 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83569 break;
83570
83571 default:
83572 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83573 return;
83574
83575 td->mutexes[dat] = 3;
83576 - td->event = atomic_add_return(1, &rttest_event);
83577 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83578 break;
83579
83580 case RTTEST_LOCKNOWAIT:
83581 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
83582 return;
83583
83584 td->mutexes[dat] = 1;
83585 - td->event = atomic_add_return(1, &rttest_event);
83586 + td->event = atomic_add_return_unchecked(1, &rttest_event);
83587 return;
83588
83589 default:
83590 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
83591 index 4a07353..66b5291 100644
83592 --- a/kernel/sched/auto_group.c
83593 +++ b/kernel/sched/auto_group.c
83594 @@ -11,7 +11,7 @@
83595
83596 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
83597 static struct autogroup autogroup_default;
83598 -static atomic_t autogroup_seq_nr;
83599 +static atomic_unchecked_t autogroup_seq_nr;
83600
83601 void __init autogroup_init(struct task_struct *init_task)
83602 {
83603 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
83604
83605 kref_init(&ag->kref);
83606 init_rwsem(&ag->lock);
83607 - ag->id = atomic_inc_return(&autogroup_seq_nr);
83608 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
83609 ag->tg = tg;
83610 #ifdef CONFIG_RT_GROUP_SCHED
83611 /*
83612 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
83613 index 05c39f0..442e6fe 100644
83614 --- a/kernel/sched/core.c
83615 +++ b/kernel/sched/core.c
83616 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
83617 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83618 * or number of jiffies left till timeout) if completed.
83619 */
83620 -long __sched
83621 +long __sched __intentional_overflow(-1)
83622 wait_for_completion_interruptible_timeout(struct completion *x,
83623 unsigned long timeout)
83624 {
83625 @@ -2902,7 +2902,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
83626 *
83627 * Return: -ERESTARTSYS if interrupted, 0 if completed.
83628 */
83629 -int __sched wait_for_completion_killable(struct completion *x)
83630 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
83631 {
83632 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
83633 if (t == -ERESTARTSYS)
83634 @@ -2923,7 +2923,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
83635 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
83636 * or number of jiffies left till timeout) if completed.
83637 */
83638 -long __sched
83639 +long __sched __intentional_overflow(-1)
83640 wait_for_completion_killable_timeout(struct completion *x,
83641 unsigned long timeout)
83642 {
83643 @@ -3149,6 +3149,8 @@ int can_nice(const struct task_struct *p, const int nice)
83644 /* convert nice value [19,-20] to rlimit style value [1,40] */
83645 int nice_rlim = 20 - nice;
83646
83647 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
83648 +
83649 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
83650 capable(CAP_SYS_NICE));
83651 }
83652 @@ -3182,7 +3184,8 @@ SYSCALL_DEFINE1(nice, int, increment)
83653 if (nice > 19)
83654 nice = 19;
83655
83656 - if (increment < 0 && !can_nice(current, nice))
83657 + if (increment < 0 && (!can_nice(current, nice) ||
83658 + gr_handle_chroot_nice()))
83659 return -EPERM;
83660
83661 retval = security_task_setnice(current, nice);
83662 @@ -3344,6 +3347,7 @@ recheck:
83663 unsigned long rlim_rtprio =
83664 task_rlimit(p, RLIMIT_RTPRIO);
83665
83666 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
83667 /* can't set/change the rt policy */
83668 if (policy != p->policy && !rlim_rtprio)
83669 return -EPERM;
83670 @@ -4473,7 +4477,7 @@ static void migrate_tasks(unsigned int dead_cpu)
83671
83672 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
83673
83674 -static struct ctl_table sd_ctl_dir[] = {
83675 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
83676 {
83677 .procname = "sched_domain",
83678 .mode = 0555,
83679 @@ -4490,17 +4494,17 @@ static struct ctl_table sd_ctl_root[] = {
83680 {}
83681 };
83682
83683 -static struct ctl_table *sd_alloc_ctl_entry(int n)
83684 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
83685 {
83686 - struct ctl_table *entry =
83687 + ctl_table_no_const *entry =
83688 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
83689
83690 return entry;
83691 }
83692
83693 -static void sd_free_ctl_entry(struct ctl_table **tablep)
83694 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
83695 {
83696 - struct ctl_table *entry;
83697 + ctl_table_no_const *entry;
83698
83699 /*
83700 * In the intermediate directories, both the child directory and
83701 @@ -4508,22 +4512,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
83702 * will always be set. In the lowest directory the names are
83703 * static strings and all have proc handlers.
83704 */
83705 - for (entry = *tablep; entry->mode; entry++) {
83706 - if (entry->child)
83707 - sd_free_ctl_entry(&entry->child);
83708 + for (entry = tablep; entry->mode; entry++) {
83709 + if (entry->child) {
83710 + sd_free_ctl_entry(entry->child);
83711 + pax_open_kernel();
83712 + entry->child = NULL;
83713 + pax_close_kernel();
83714 + }
83715 if (entry->proc_handler == NULL)
83716 kfree(entry->procname);
83717 }
83718
83719 - kfree(*tablep);
83720 - *tablep = NULL;
83721 + kfree(tablep);
83722 }
83723
83724 static int min_load_idx = 0;
83725 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
83726
83727 static void
83728 -set_table_entry(struct ctl_table *entry,
83729 +set_table_entry(ctl_table_no_const *entry,
83730 const char *procname, void *data, int maxlen,
83731 umode_t mode, proc_handler *proc_handler,
83732 bool load_idx)
83733 @@ -4543,7 +4550,7 @@ set_table_entry(struct ctl_table *entry,
83734 static struct ctl_table *
83735 sd_alloc_ctl_domain_table(struct sched_domain *sd)
83736 {
83737 - struct ctl_table *table = sd_alloc_ctl_entry(13);
83738 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
83739
83740 if (table == NULL)
83741 return NULL;
83742 @@ -4578,9 +4585,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
83743 return table;
83744 }
83745
83746 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
83747 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
83748 {
83749 - struct ctl_table *entry, *table;
83750 + ctl_table_no_const *entry, *table;
83751 struct sched_domain *sd;
83752 int domain_num = 0, i;
83753 char buf[32];
83754 @@ -4607,11 +4614,13 @@ static struct ctl_table_header *sd_sysctl_header;
83755 static void register_sched_domain_sysctl(void)
83756 {
83757 int i, cpu_num = num_possible_cpus();
83758 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
83759 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
83760 char buf[32];
83761
83762 WARN_ON(sd_ctl_dir[0].child);
83763 + pax_open_kernel();
83764 sd_ctl_dir[0].child = entry;
83765 + pax_close_kernel();
83766
83767 if (entry == NULL)
83768 return;
83769 @@ -4634,8 +4643,12 @@ static void unregister_sched_domain_sysctl(void)
83770 if (sd_sysctl_header)
83771 unregister_sysctl_table(sd_sysctl_header);
83772 sd_sysctl_header = NULL;
83773 - if (sd_ctl_dir[0].child)
83774 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
83775 + if (sd_ctl_dir[0].child) {
83776 + sd_free_ctl_entry(sd_ctl_dir[0].child);
83777 + pax_open_kernel();
83778 + sd_ctl_dir[0].child = NULL;
83779 + pax_close_kernel();
83780 + }
83781 }
83782 #else
83783 static void register_sched_domain_sysctl(void)
83784 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
83785 index 31cbc15..ba68c15 100644
83786 --- a/kernel/sched/fair.c
83787 +++ b/kernel/sched/fair.c
83788 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
83789
83790 static void reset_ptenuma_scan(struct task_struct *p)
83791 {
83792 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
83793 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
83794 p->mm->numa_scan_offset = 0;
83795 }
83796
83797 @@ -5727,7 +5727,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
83798 * run_rebalance_domains is triggered when needed from the scheduler tick.
83799 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
83800 */
83801 -static void run_rebalance_domains(struct softirq_action *h)
83802 +static __latent_entropy void run_rebalance_domains(void)
83803 {
83804 int this_cpu = smp_processor_id();
83805 struct rq *this_rq = cpu_rq(this_cpu);
83806 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
83807 index ef0a7b2..1b728c1 100644
83808 --- a/kernel/sched/sched.h
83809 +++ b/kernel/sched/sched.h
83810 @@ -1004,7 +1004,7 @@ struct sched_class {
83811 #ifdef CONFIG_FAIR_GROUP_SCHED
83812 void (*task_move_group) (struct task_struct *p, int on_rq);
83813 #endif
83814 -};
83815 +} __do_const;
83816
83817 #define sched_class_highest (&stop_sched_class)
83818 #define for_each_class(class) \
83819 diff --git a/kernel/signal.c b/kernel/signal.c
83820 index 50e4107..9409983 100644
83821 --- a/kernel/signal.c
83822 +++ b/kernel/signal.c
83823 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
83824
83825 int print_fatal_signals __read_mostly;
83826
83827 -static void __user *sig_handler(struct task_struct *t, int sig)
83828 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
83829 {
83830 return t->sighand->action[sig - 1].sa.sa_handler;
83831 }
83832
83833 -static int sig_handler_ignored(void __user *handler, int sig)
83834 +static int sig_handler_ignored(__sighandler_t handler, int sig)
83835 {
83836 /* Is it explicitly or implicitly ignored? */
83837 return handler == SIG_IGN ||
83838 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
83839
83840 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
83841 {
83842 - void __user *handler;
83843 + __sighandler_t handler;
83844
83845 handler = sig_handler(t, sig);
83846
83847 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
83848 atomic_inc(&user->sigpending);
83849 rcu_read_unlock();
83850
83851 + if (!override_rlimit)
83852 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
83853 +
83854 if (override_rlimit ||
83855 atomic_read(&user->sigpending) <=
83856 task_rlimit(t, RLIMIT_SIGPENDING)) {
83857 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
83858
83859 int unhandled_signal(struct task_struct *tsk, int sig)
83860 {
83861 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
83862 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
83863 if (is_global_init(tsk))
83864 return 1;
83865 if (handler != SIG_IGN && handler != SIG_DFL)
83866 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
83867 }
83868 }
83869
83870 + /* allow glibc communication via tgkill to other threads in our
83871 + thread group */
83872 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
83873 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
83874 + && gr_handle_signal(t, sig))
83875 + return -EPERM;
83876 +
83877 return security_task_kill(t, info, sig, 0);
83878 }
83879
83880 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83881 return send_signal(sig, info, p, 1);
83882 }
83883
83884 -static int
83885 +int
83886 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83887 {
83888 return send_signal(sig, info, t, 0);
83889 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83890 unsigned long int flags;
83891 int ret, blocked, ignored;
83892 struct k_sigaction *action;
83893 + int is_unhandled = 0;
83894
83895 spin_lock_irqsave(&t->sighand->siglock, flags);
83896 action = &t->sighand->action[sig-1];
83897 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
83898 }
83899 if (action->sa.sa_handler == SIG_DFL)
83900 t->signal->flags &= ~SIGNAL_UNKILLABLE;
83901 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
83902 + is_unhandled = 1;
83903 ret = specific_send_sig_info(sig, info, t);
83904 spin_unlock_irqrestore(&t->sighand->siglock, flags);
83905
83906 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
83907 + normal operation */
83908 + if (is_unhandled) {
83909 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
83910 + gr_handle_crash(t, sig);
83911 + }
83912 +
83913 return ret;
83914 }
83915
83916 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
83917 ret = check_kill_permission(sig, info, p);
83918 rcu_read_unlock();
83919
83920 - if (!ret && sig)
83921 + if (!ret && sig) {
83922 ret = do_send_sig_info(sig, info, p, true);
83923 + if (!ret)
83924 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
83925 + }
83926
83927 return ret;
83928 }
83929 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
83930 int error = -ESRCH;
83931
83932 rcu_read_lock();
83933 - p = find_task_by_vpid(pid);
83934 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
83935 + /* allow glibc communication via tgkill to other threads in our
83936 + thread group */
83937 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
83938 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
83939 + p = find_task_by_vpid_unrestricted(pid);
83940 + else
83941 +#endif
83942 + p = find_task_by_vpid(pid);
83943 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
83944 error = check_kill_permission(sig, info, p);
83945 /*
83946 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
83947 }
83948 seg = get_fs();
83949 set_fs(KERNEL_DS);
83950 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
83951 - (stack_t __force __user *) &uoss,
83952 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
83953 + (stack_t __force_user *) &uoss,
83954 compat_user_stack_pointer());
83955 set_fs(seg);
83956 if (ret >= 0 && uoss_ptr) {
83957 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
83958 index eb89e18..a4e6792 100644
83959 --- a/kernel/smpboot.c
83960 +++ b/kernel/smpboot.c
83961 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
83962 }
83963 smpboot_unpark_thread(plug_thread, cpu);
83964 }
83965 - list_add(&plug_thread->list, &hotplug_threads);
83966 + pax_list_add(&plug_thread->list, &hotplug_threads);
83967 out:
83968 mutex_unlock(&smpboot_threads_lock);
83969 return ret;
83970 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
83971 {
83972 get_online_cpus();
83973 mutex_lock(&smpboot_threads_lock);
83974 - list_del(&plug_thread->list);
83975 + pax_list_del(&plug_thread->list);
83976 smpboot_destroy_threads(plug_thread);
83977 mutex_unlock(&smpboot_threads_lock);
83978 put_online_cpus();
83979 diff --git a/kernel/softirq.c b/kernel/softirq.c
83980 index adf6c00..5d89b73 100644
83981 --- a/kernel/softirq.c
83982 +++ b/kernel/softirq.c
83983 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
83984 EXPORT_SYMBOL(irq_stat);
83985 #endif
83986
83987 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
83988 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
83989
83990 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
83991
83992 -char *softirq_to_name[NR_SOFTIRQS] = {
83993 +const char * const softirq_to_name[NR_SOFTIRQS] = {
83994 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
83995 "TASKLET", "SCHED", "HRTIMER", "RCU"
83996 };
83997 @@ -248,7 +248,7 @@ restart:
83998 kstat_incr_softirqs_this_cpu(vec_nr);
83999
84000 trace_softirq_entry(vec_nr);
84001 - h->action(h);
84002 + h->action();
84003 trace_softirq_exit(vec_nr);
84004 if (unlikely(prev_count != preempt_count())) {
84005 printk(KERN_ERR "huh, entered softirq %u %s %p"
84006 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
84007 or_softirq_pending(1UL << nr);
84008 }
84009
84010 -void open_softirq(int nr, void (*action)(struct softirq_action *))
84011 +void __init open_softirq(int nr, void (*action)(void))
84012 {
84013 softirq_vec[nr].action = action;
84014 }
84015 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
84016
84017 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
84018
84019 -static void tasklet_action(struct softirq_action *a)
84020 +static __latent_entropy void tasklet_action(void)
84021 {
84022 struct tasklet_struct *list;
84023
84024 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
84025 }
84026 }
84027
84028 -static void tasklet_hi_action(struct softirq_action *a)
84029 +static __latent_entropy void tasklet_hi_action(void)
84030 {
84031 struct tasklet_struct *list;
84032
84033 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
84034 .notifier_call = cpu_callback
84035 };
84036
84037 -static struct smp_hotplug_thread softirq_threads = {
84038 +static struct smp_hotplug_thread softirq_threads __read_only = {
84039 .store = &ksoftirqd,
84040 .thread_should_run = ksoftirqd_should_run,
84041 .thread_fn = run_ksoftirqd,
84042 diff --git a/kernel/srcu.c b/kernel/srcu.c
84043 index 01d5ccb..cdcbee6 100644
84044 --- a/kernel/srcu.c
84045 +++ b/kernel/srcu.c
84046 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
84047
84048 idx = ACCESS_ONCE(sp->completed) & 0x1;
84049 preempt_disable();
84050 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84051 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
84052 smp_mb(); /* B */ /* Avoid leaking the critical section. */
84053 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
84054 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
84055 preempt_enable();
84056 return idx;
84057 }
84058 diff --git a/kernel/sys.c b/kernel/sys.c
84059 index 771129b..dc0c7e3 100644
84060 --- a/kernel/sys.c
84061 +++ b/kernel/sys.c
84062 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
84063 error = -EACCES;
84064 goto out;
84065 }
84066 +
84067 + if (gr_handle_chroot_setpriority(p, niceval)) {
84068 + error = -EACCES;
84069 + goto out;
84070 + }
84071 +
84072 no_nice = security_task_setnice(p, niceval);
84073 if (no_nice) {
84074 error = no_nice;
84075 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
84076 goto error;
84077 }
84078
84079 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
84080 + goto error;
84081 +
84082 if (rgid != (gid_t) -1 ||
84083 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
84084 new->sgid = new->egid;
84085 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
84086 old = current_cred();
84087
84088 retval = -EPERM;
84089 +
84090 + if (gr_check_group_change(kgid, kgid, kgid))
84091 + goto error;
84092 +
84093 if (nsown_capable(CAP_SETGID))
84094 new->gid = new->egid = new->sgid = new->fsgid = kgid;
84095 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
84096 @@ -404,7 +417,7 @@ error:
84097 /*
84098 * change the user struct in a credentials set to match the new UID
84099 */
84100 -static int set_user(struct cred *new)
84101 +int set_user(struct cred *new)
84102 {
84103 struct user_struct *new_user;
84104
84105 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
84106 goto error;
84107 }
84108
84109 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
84110 + goto error;
84111 +
84112 if (!uid_eq(new->uid, old->uid)) {
84113 retval = set_user(new);
84114 if (retval < 0)
84115 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
84116 old = current_cred();
84117
84118 retval = -EPERM;
84119 +
84120 + if (gr_check_crash_uid(kuid))
84121 + goto error;
84122 + if (gr_check_user_change(kuid, kuid, kuid))
84123 + goto error;
84124 +
84125 if (nsown_capable(CAP_SETUID)) {
84126 new->suid = new->uid = kuid;
84127 if (!uid_eq(kuid, old->uid)) {
84128 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
84129 goto error;
84130 }
84131
84132 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
84133 + goto error;
84134 +
84135 if (ruid != (uid_t) -1) {
84136 new->uid = kruid;
84137 if (!uid_eq(kruid, old->uid)) {
84138 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
84139 goto error;
84140 }
84141
84142 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
84143 + goto error;
84144 +
84145 if (rgid != (gid_t) -1)
84146 new->gid = krgid;
84147 if (egid != (gid_t) -1)
84148 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
84149 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
84150 nsown_capable(CAP_SETUID)) {
84151 if (!uid_eq(kuid, old->fsuid)) {
84152 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
84153 + goto error;
84154 +
84155 new->fsuid = kuid;
84156 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
84157 goto change_okay;
84158 }
84159 }
84160
84161 +error:
84162 abort_creds(new);
84163 return old_fsuid;
84164
84165 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
84166 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
84167 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
84168 nsown_capable(CAP_SETGID)) {
84169 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
84170 + goto error;
84171 +
84172 if (!gid_eq(kgid, old->fsgid)) {
84173 new->fsgid = kgid;
84174 goto change_okay;
84175 }
84176 }
84177
84178 +error:
84179 abort_creds(new);
84180 return old_fsgid;
84181
84182 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
84183 return -EFAULT;
84184
84185 down_read(&uts_sem);
84186 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
84187 + error = __copy_to_user(name->sysname, &utsname()->sysname,
84188 __OLD_UTS_LEN);
84189 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
84190 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
84191 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
84192 __OLD_UTS_LEN);
84193 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
84194 - error |= __copy_to_user(&name->release, &utsname()->release,
84195 + error |= __copy_to_user(name->release, &utsname()->release,
84196 __OLD_UTS_LEN);
84197 error |= __put_user(0, name->release + __OLD_UTS_LEN);
84198 - error |= __copy_to_user(&name->version, &utsname()->version,
84199 + error |= __copy_to_user(name->version, &utsname()->version,
84200 __OLD_UTS_LEN);
84201 error |= __put_user(0, name->version + __OLD_UTS_LEN);
84202 - error |= __copy_to_user(&name->machine, &utsname()->machine,
84203 + error |= __copy_to_user(name->machine, &utsname()->machine,
84204 __OLD_UTS_LEN);
84205 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
84206 up_read(&uts_sem);
84207 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
84208 */
84209 new_rlim->rlim_cur = 1;
84210 }
84211 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
84212 + is changed to a lower value. Since tasks can be created by the same
84213 + user in between this limit change and an execve by this task, force
84214 + a recheck only for this task by setting PF_NPROC_EXCEEDED
84215 + */
84216 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
84217 + tsk->flags |= PF_NPROC_EXCEEDED;
84218 }
84219 if (!retval) {
84220 if (old_rlim)
84221 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
84222 index 07f6fc4..65fb3d4 100644
84223 --- a/kernel/sysctl.c
84224 +++ b/kernel/sysctl.c
84225 @@ -93,7 +93,6 @@
84226
84227
84228 #if defined(CONFIG_SYSCTL)
84229 -
84230 /* External variables not in a header file. */
84231 extern int sysctl_overcommit_memory;
84232 extern int sysctl_overcommit_ratio;
84233 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
84234
84235 /* Constants used for minimum and maximum */
84236 #ifdef CONFIG_LOCKUP_DETECTOR
84237 -static int sixty = 60;
84238 +static int sixty __read_only = 60;
84239 #endif
84240
84241 -static int zero;
84242 -static int __maybe_unused one = 1;
84243 -static int __maybe_unused two = 2;
84244 -static int __maybe_unused three = 3;
84245 -static unsigned long one_ul = 1;
84246 -static int one_hundred = 100;
84247 +static int neg_one __read_only = -1;
84248 +static int zero __read_only = 0;
84249 +static int __maybe_unused one __read_only = 1;
84250 +static int __maybe_unused two __read_only = 2;
84251 +static int __maybe_unused three __read_only = 3;
84252 +static unsigned long one_ul __read_only = 1;
84253 +static int one_hundred __read_only = 100;
84254 #ifdef CONFIG_PRINTK
84255 -static int ten_thousand = 10000;
84256 +static int ten_thousand __read_only = 10000;
84257 #endif
84258
84259 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
84260 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
84261 void __user *buffer, size_t *lenp, loff_t *ppos);
84262 #endif
84263
84264 -#ifdef CONFIG_PRINTK
84265 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84266 void __user *buffer, size_t *lenp, loff_t *ppos);
84267 -#endif
84268
84269 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
84270 void __user *buffer, size_t *lenp, loff_t *ppos);
84271 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
84272
84273 #endif
84274
84275 +extern struct ctl_table grsecurity_table[];
84276 +
84277 static struct ctl_table kern_table[];
84278 static struct ctl_table vm_table[];
84279 static struct ctl_table fs_table[];
84280 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
84281 int sysctl_legacy_va_layout;
84282 #endif
84283
84284 +#ifdef CONFIG_PAX_SOFTMODE
84285 +static ctl_table pax_table[] = {
84286 + {
84287 + .procname = "softmode",
84288 + .data = &pax_softmode,
84289 + .maxlen = sizeof(unsigned int),
84290 + .mode = 0600,
84291 + .proc_handler = &proc_dointvec,
84292 + },
84293 +
84294 + { }
84295 +};
84296 +#endif
84297 +
84298 /* The default sysctl tables: */
84299
84300 static struct ctl_table sysctl_base_table[] = {
84301 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
84302 #endif
84303
84304 static struct ctl_table kern_table[] = {
84305 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
84306 + {
84307 + .procname = "grsecurity",
84308 + .mode = 0500,
84309 + .child = grsecurity_table,
84310 + },
84311 +#endif
84312 +
84313 +#ifdef CONFIG_PAX_SOFTMODE
84314 + {
84315 + .procname = "pax",
84316 + .mode = 0500,
84317 + .child = pax_table,
84318 + },
84319 +#endif
84320 +
84321 {
84322 .procname = "sched_child_runs_first",
84323 .data = &sysctl_sched_child_runs_first,
84324 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
84325 .data = &modprobe_path,
84326 .maxlen = KMOD_PATH_LEN,
84327 .mode = 0644,
84328 - .proc_handler = proc_dostring,
84329 + .proc_handler = proc_dostring_modpriv,
84330 },
84331 {
84332 .procname = "modules_disabled",
84333 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
84334 .extra1 = &zero,
84335 .extra2 = &one,
84336 },
84337 +#endif
84338 {
84339 .procname = "kptr_restrict",
84340 .data = &kptr_restrict,
84341 .maxlen = sizeof(int),
84342 .mode = 0644,
84343 .proc_handler = proc_dointvec_minmax_sysadmin,
84344 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84345 + .extra1 = &two,
84346 +#else
84347 .extra1 = &zero,
84348 +#endif
84349 .extra2 = &two,
84350 },
84351 -#endif
84352 {
84353 .procname = "ngroups_max",
84354 .data = &ngroups_max,
84355 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
84356 */
84357 {
84358 .procname = "perf_event_paranoid",
84359 - .data = &sysctl_perf_event_paranoid,
84360 - .maxlen = sizeof(sysctl_perf_event_paranoid),
84361 + .data = &sysctl_perf_event_legitimately_concerned,
84362 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
84363 .mode = 0644,
84364 - .proc_handler = proc_dointvec,
84365 + /* go ahead, be a hero */
84366 + .proc_handler = proc_dointvec_minmax_sysadmin,
84367 + .extra1 = &neg_one,
84368 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
84369 + .extra2 = &three,
84370 +#else
84371 + .extra2 = &two,
84372 +#endif
84373 },
84374 {
84375 .procname = "perf_event_mlock_kb",
84376 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
84377 .proc_handler = proc_dointvec_minmax,
84378 .extra1 = &zero,
84379 },
84380 + {
84381 + .procname = "heap_stack_gap",
84382 + .data = &sysctl_heap_stack_gap,
84383 + .maxlen = sizeof(sysctl_heap_stack_gap),
84384 + .mode = 0644,
84385 + .proc_handler = proc_doulongvec_minmax,
84386 + },
84387 #else
84388 {
84389 .procname = "nr_trim_pages",
84390 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
84391 buffer, lenp, ppos);
84392 }
84393
84394 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84395 + void __user *buffer, size_t *lenp, loff_t *ppos)
84396 +{
84397 + if (write && !capable(CAP_SYS_MODULE))
84398 + return -EPERM;
84399 +
84400 + return _proc_do_string(table->data, table->maxlen, write,
84401 + buffer, lenp, ppos);
84402 +}
84403 +
84404 static size_t proc_skip_spaces(char **buf)
84405 {
84406 size_t ret;
84407 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
84408 len = strlen(tmp);
84409 if (len > *size)
84410 len = *size;
84411 + if (len > sizeof(tmp))
84412 + len = sizeof(tmp);
84413 if (copy_to_user(*buf, tmp, len))
84414 return -EFAULT;
84415 *size -= len;
84416 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
84417 static int proc_taint(struct ctl_table *table, int write,
84418 void __user *buffer, size_t *lenp, loff_t *ppos)
84419 {
84420 - struct ctl_table t;
84421 + ctl_table_no_const t;
84422 unsigned long tmptaint = get_taint();
84423 int err;
84424
84425 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
84426 return err;
84427 }
84428
84429 -#ifdef CONFIG_PRINTK
84430 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84431 void __user *buffer, size_t *lenp, loff_t *ppos)
84432 {
84433 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
84434
84435 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
84436 }
84437 -#endif
84438
84439 struct do_proc_dointvec_minmax_conv_param {
84440 int *min;
84441 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
84442 *i = val;
84443 } else {
84444 val = convdiv * (*i) / convmul;
84445 - if (!first)
84446 + if (!first) {
84447 err = proc_put_char(&buffer, &left, '\t');
84448 + if (err)
84449 + break;
84450 + }
84451 err = proc_put_long(&buffer, &left, val, false);
84452 if (err)
84453 break;
84454 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
84455 return -ENOSYS;
84456 }
84457
84458 +int proc_dostring_modpriv(struct ctl_table *table, int write,
84459 + void __user *buffer, size_t *lenp, loff_t *ppos)
84460 +{
84461 + return -ENOSYS;
84462 +}
84463 +
84464 int proc_dointvec(struct ctl_table *table, int write,
84465 void __user *buffer, size_t *lenp, loff_t *ppos)
84466 {
84467 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
84468 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
84469 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
84470 EXPORT_SYMBOL(proc_dostring);
84471 +EXPORT_SYMBOL(proc_dostring_modpriv);
84472 EXPORT_SYMBOL(proc_doulongvec_minmax);
84473 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
84474 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
84475 index 145bb4d..b2aa969 100644
84476 --- a/kernel/taskstats.c
84477 +++ b/kernel/taskstats.c
84478 @@ -28,9 +28,12 @@
84479 #include <linux/fs.h>
84480 #include <linux/file.h>
84481 #include <linux/pid_namespace.h>
84482 +#include <linux/grsecurity.h>
84483 #include <net/genetlink.h>
84484 #include <linux/atomic.h>
84485
84486 +extern int gr_is_taskstats_denied(int pid);
84487 +
84488 /*
84489 * Maximum length of a cpumask that can be specified in
84490 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
84491 @@ -570,6 +573,9 @@ err:
84492
84493 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
84494 {
84495 + if (gr_is_taskstats_denied(current->pid))
84496 + return -EACCES;
84497 +
84498 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
84499 return cmd_attr_register_cpumask(info);
84500 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
84501 diff --git a/kernel/time.c b/kernel/time.c
84502 index 7c7964c..784a599 100644
84503 --- a/kernel/time.c
84504 +++ b/kernel/time.c
84505 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
84506 return error;
84507
84508 if (tz) {
84509 + /* we log in do_settimeofday called below, so don't log twice
84510 + */
84511 + if (!tv)
84512 + gr_log_timechange();
84513 +
84514 sys_tz = *tz;
84515 update_vsyscall_tz();
84516 if (firsttime) {
84517 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
84518 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
84519 * value to a scaled second value.
84520 */
84521 -unsigned long
84522 +unsigned long __intentional_overflow(-1)
84523 timespec_to_jiffies(const struct timespec *value)
84524 {
84525 unsigned long sec = value->tv_sec;
84526 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
84527 index eec50fc..65e5df6 100644
84528 --- a/kernel/time/alarmtimer.c
84529 +++ b/kernel/time/alarmtimer.c
84530 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
84531 struct platform_device *pdev;
84532 int error = 0;
84533 int i;
84534 - struct k_clock alarm_clock = {
84535 + static struct k_clock alarm_clock = {
84536 .clock_getres = alarm_clock_getres,
84537 .clock_get = alarm_clock_get,
84538 .timer_create = alarm_timer_create,
84539 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
84540 index 947ba25..20cbade 100644
84541 --- a/kernel/time/timekeeping.c
84542 +++ b/kernel/time/timekeeping.c
84543 @@ -15,6 +15,7 @@
84544 #include <linux/init.h>
84545 #include <linux/mm.h>
84546 #include <linux/sched.h>
84547 +#include <linux/grsecurity.h>
84548 #include <linux/syscore_ops.h>
84549 #include <linux/clocksource.h>
84550 #include <linux/jiffies.h>
84551 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
84552 if (!timespec_valid_strict(tv))
84553 return -EINVAL;
84554
84555 + gr_log_timechange();
84556 +
84557 raw_spin_lock_irqsave(&timekeeper_lock, flags);
84558 write_seqcount_begin(&timekeeper_seq);
84559
84560 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
84561 index 61ed862..3b52c65 100644
84562 --- a/kernel/time/timer_list.c
84563 +++ b/kernel/time/timer_list.c
84564 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
84565
84566 static void print_name_offset(struct seq_file *m, void *sym)
84567 {
84568 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84569 + SEQ_printf(m, "<%p>", NULL);
84570 +#else
84571 char symname[KSYM_NAME_LEN];
84572
84573 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
84574 SEQ_printf(m, "<%pK>", sym);
84575 else
84576 SEQ_printf(m, "%s", symname);
84577 +#endif
84578 }
84579
84580 static void
84581 @@ -119,7 +123,11 @@ next_one:
84582 static void
84583 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
84584 {
84585 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84586 + SEQ_printf(m, " .base: %p\n", NULL);
84587 +#else
84588 SEQ_printf(m, " .base: %pK\n", base);
84589 +#endif
84590 SEQ_printf(m, " .index: %d\n",
84591 base->index);
84592 SEQ_printf(m, " .resolution: %Lu nsecs\n",
84593 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
84594 {
84595 struct proc_dir_entry *pe;
84596
84597 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84598 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
84599 +#else
84600 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
84601 +#endif
84602 if (!pe)
84603 return -ENOMEM;
84604 return 0;
84605 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
84606 index 0b537f2..40d6c20 100644
84607 --- a/kernel/time/timer_stats.c
84608 +++ b/kernel/time/timer_stats.c
84609 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
84610 static unsigned long nr_entries;
84611 static struct entry entries[MAX_ENTRIES];
84612
84613 -static atomic_t overflow_count;
84614 +static atomic_unchecked_t overflow_count;
84615
84616 /*
84617 * The entries are in a hash-table, for fast lookup:
84618 @@ -140,7 +140,7 @@ static void reset_entries(void)
84619 nr_entries = 0;
84620 memset(entries, 0, sizeof(entries));
84621 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
84622 - atomic_set(&overflow_count, 0);
84623 + atomic_set_unchecked(&overflow_count, 0);
84624 }
84625
84626 static struct entry *alloc_entry(void)
84627 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84628 if (likely(entry))
84629 entry->count++;
84630 else
84631 - atomic_inc(&overflow_count);
84632 + atomic_inc_unchecked(&overflow_count);
84633
84634 out_unlock:
84635 raw_spin_unlock_irqrestore(lock, flags);
84636 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
84637
84638 static void print_name_offset(struct seq_file *m, unsigned long addr)
84639 {
84640 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84641 + seq_printf(m, "<%p>", NULL);
84642 +#else
84643 char symname[KSYM_NAME_LEN];
84644
84645 if (lookup_symbol_name(addr, symname) < 0)
84646 - seq_printf(m, "<%p>", (void *)addr);
84647 + seq_printf(m, "<%pK>", (void *)addr);
84648 else
84649 seq_printf(m, "%s", symname);
84650 +#endif
84651 }
84652
84653 static int tstats_show(struct seq_file *m, void *v)
84654 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
84655
84656 seq_puts(m, "Timer Stats Version: v0.2\n");
84657 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
84658 - if (atomic_read(&overflow_count))
84659 + if (atomic_read_unchecked(&overflow_count))
84660 seq_printf(m, "Overflow: %d entries\n",
84661 - atomic_read(&overflow_count));
84662 + atomic_read_unchecked(&overflow_count));
84663
84664 for (i = 0; i < nr_entries; i++) {
84665 entry = entries + i;
84666 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
84667 {
84668 struct proc_dir_entry *pe;
84669
84670 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
84671 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
84672 +#else
84673 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
84674 +#endif
84675 if (!pe)
84676 return -ENOMEM;
84677 return 0;
84678 diff --git a/kernel/timer.c b/kernel/timer.c
84679 index 4296d13..0164b04 100644
84680 --- a/kernel/timer.c
84681 +++ b/kernel/timer.c
84682 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
84683 /*
84684 * This function runs timers and the timer-tq in bottom half context.
84685 */
84686 -static void run_timer_softirq(struct softirq_action *h)
84687 +static __latent_entropy void run_timer_softirq(void)
84688 {
84689 struct tvec_base *base = __this_cpu_read(tvec_bases);
84690
84691 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
84692 *
84693 * In all cases the return value is guaranteed to be non-negative.
84694 */
84695 -signed long __sched schedule_timeout(signed long timeout)
84696 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
84697 {
84698 struct timer_list timer;
84699 unsigned long expire;
84700 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
84701 index b8b8560..75b1a09 100644
84702 --- a/kernel/trace/blktrace.c
84703 +++ b/kernel/trace/blktrace.c
84704 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
84705 struct blk_trace *bt = filp->private_data;
84706 char buf[16];
84707
84708 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
84709 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
84710
84711 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
84712 }
84713 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
84714 return 1;
84715
84716 bt = buf->chan->private_data;
84717 - atomic_inc(&bt->dropped);
84718 + atomic_inc_unchecked(&bt->dropped);
84719 return 0;
84720 }
84721
84722 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
84723
84724 bt->dir = dir;
84725 bt->dev = dev;
84726 - atomic_set(&bt->dropped, 0);
84727 + atomic_set_unchecked(&bt->dropped, 0);
84728
84729 ret = -EIO;
84730 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
84731 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
84732 index a6d098c..bb8cf65 100644
84733 --- a/kernel/trace/ftrace.c
84734 +++ b/kernel/trace/ftrace.c
84735 @@ -1950,12 +1950,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
84736 if (unlikely(ftrace_disabled))
84737 return 0;
84738
84739 + ret = ftrace_arch_code_modify_prepare();
84740 + FTRACE_WARN_ON(ret);
84741 + if (ret)
84742 + return 0;
84743 +
84744 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
84745 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
84746 if (ret) {
84747 ftrace_bug(ret, ip);
84748 - return 0;
84749 }
84750 - return 1;
84751 + return ret ? 0 : 1;
84752 }
84753
84754 /*
84755 @@ -4028,8 +4033,10 @@ static int ftrace_process_locs(struct module *mod,
84756 if (!count)
84757 return 0;
84758
84759 + pax_open_kernel();
84760 sort(start, count, sizeof(*start),
84761 ftrace_cmp_ips, ftrace_swap_ips);
84762 + pax_close_kernel();
84763
84764 start_pg = ftrace_allocate_pages(count);
84765 if (!start_pg)
84766 @@ -4752,8 +4759,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
84767 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
84768
84769 static int ftrace_graph_active;
84770 -static struct notifier_block ftrace_suspend_notifier;
84771 -
84772 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
84773 {
84774 return 0;
84775 @@ -4897,6 +4902,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
84776 return NOTIFY_DONE;
84777 }
84778
84779 +static struct notifier_block ftrace_suspend_notifier = {
84780 + .notifier_call = ftrace_suspend_notifier_call
84781 +};
84782 +
84783 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84784 trace_func_graph_ent_t entryfunc)
84785 {
84786 @@ -4910,7 +4919,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
84787 goto out;
84788 }
84789
84790 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
84791 register_pm_notifier(&ftrace_suspend_notifier);
84792
84793 ftrace_graph_active++;
84794 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
84795 index cc2f66f..05edd54 100644
84796 --- a/kernel/trace/ring_buffer.c
84797 +++ b/kernel/trace/ring_buffer.c
84798 @@ -352,9 +352,9 @@ struct buffer_data_page {
84799 */
84800 struct buffer_page {
84801 struct list_head list; /* list of buffer pages */
84802 - local_t write; /* index for next write */
84803 + local_unchecked_t write; /* index for next write */
84804 unsigned read; /* index for next read */
84805 - local_t entries; /* entries on this page */
84806 + local_unchecked_t entries; /* entries on this page */
84807 unsigned long real_end; /* real end of data */
84808 struct buffer_data_page *page; /* Actual data page */
84809 };
84810 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
84811 unsigned long last_overrun;
84812 local_t entries_bytes;
84813 local_t entries;
84814 - local_t overrun;
84815 - local_t commit_overrun;
84816 + local_unchecked_t overrun;
84817 + local_unchecked_t commit_overrun;
84818 local_t dropped_events;
84819 local_t committing;
84820 local_t commits;
84821 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84822 *
84823 * We add a counter to the write field to denote this.
84824 */
84825 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
84826 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
84827 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
84828 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
84829
84830 /*
84831 * Just make sure we have seen our old_write and synchronize
84832 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
84833 * cmpxchg to only update if an interrupt did not already
84834 * do it for us. If the cmpxchg fails, we don't care.
84835 */
84836 - (void)local_cmpxchg(&next_page->write, old_write, val);
84837 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
84838 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
84839 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
84840
84841 /*
84842 * No need to worry about races with clearing out the commit.
84843 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
84844
84845 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
84846 {
84847 - return local_read(&bpage->entries) & RB_WRITE_MASK;
84848 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
84849 }
84850
84851 static inline unsigned long rb_page_write(struct buffer_page *bpage)
84852 {
84853 - return local_read(&bpage->write) & RB_WRITE_MASK;
84854 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
84855 }
84856
84857 static int
84858 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
84859 * bytes consumed in ring buffer from here.
84860 * Increment overrun to account for the lost events.
84861 */
84862 - local_add(page_entries, &cpu_buffer->overrun);
84863 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
84864 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84865 }
84866
84867 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
84868 * it is our responsibility to update
84869 * the counters.
84870 */
84871 - local_add(entries, &cpu_buffer->overrun);
84872 + local_add_unchecked(entries, &cpu_buffer->overrun);
84873 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
84874
84875 /*
84876 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84877 if (tail == BUF_PAGE_SIZE)
84878 tail_page->real_end = 0;
84879
84880 - local_sub(length, &tail_page->write);
84881 + local_sub_unchecked(length, &tail_page->write);
84882 return;
84883 }
84884
84885 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84886 rb_event_set_padding(event);
84887
84888 /* Set the write back to the previous setting */
84889 - local_sub(length, &tail_page->write);
84890 + local_sub_unchecked(length, &tail_page->write);
84891 return;
84892 }
84893
84894 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
84895
84896 /* Set write to end of buffer */
84897 length = (tail + length) - BUF_PAGE_SIZE;
84898 - local_sub(length, &tail_page->write);
84899 + local_sub_unchecked(length, &tail_page->write);
84900 }
84901
84902 /*
84903 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84904 * about it.
84905 */
84906 if (unlikely(next_page == commit_page)) {
84907 - local_inc(&cpu_buffer->commit_overrun);
84908 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84909 goto out_reset;
84910 }
84911
84912 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
84913 cpu_buffer->tail_page) &&
84914 (cpu_buffer->commit_page ==
84915 cpu_buffer->reader_page))) {
84916 - local_inc(&cpu_buffer->commit_overrun);
84917 + local_inc_unchecked(&cpu_buffer->commit_overrun);
84918 goto out_reset;
84919 }
84920 }
84921 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84922 length += RB_LEN_TIME_EXTEND;
84923
84924 tail_page = cpu_buffer->tail_page;
84925 - write = local_add_return(length, &tail_page->write);
84926 + write = local_add_return_unchecked(length, &tail_page->write);
84927
84928 /* set write to only the index of the write */
84929 write &= RB_WRITE_MASK;
84930 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
84931 kmemcheck_annotate_bitfield(event, bitfield);
84932 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
84933
84934 - local_inc(&tail_page->entries);
84935 + local_inc_unchecked(&tail_page->entries);
84936
84937 /*
84938 * If this is the first commit on the page, then update
84939 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84940
84941 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
84942 unsigned long write_mask =
84943 - local_read(&bpage->write) & ~RB_WRITE_MASK;
84944 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
84945 unsigned long event_length = rb_event_length(event);
84946 /*
84947 * This is on the tail page. It is possible that
84948 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
84949 */
84950 old_index += write_mask;
84951 new_index += write_mask;
84952 - index = local_cmpxchg(&bpage->write, old_index, new_index);
84953 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
84954 if (index == old_index) {
84955 /* update counters */
84956 local_sub(event_length, &cpu_buffer->entries_bytes);
84957 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84958
84959 /* Do the likely case first */
84960 if (likely(bpage->page == (void *)addr)) {
84961 - local_dec(&bpage->entries);
84962 + local_dec_unchecked(&bpage->entries);
84963 return;
84964 }
84965
84966 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
84967 start = bpage;
84968 do {
84969 if (bpage->page == (void *)addr) {
84970 - local_dec(&bpage->entries);
84971 + local_dec_unchecked(&bpage->entries);
84972 return;
84973 }
84974 rb_inc_page(cpu_buffer, &bpage);
84975 @@ -3139,7 +3139,7 @@ static inline unsigned long
84976 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
84977 {
84978 return local_read(&cpu_buffer->entries) -
84979 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
84980 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
84981 }
84982
84983 /**
84984 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
84985 return 0;
84986
84987 cpu_buffer = buffer->buffers[cpu];
84988 - ret = local_read(&cpu_buffer->overrun);
84989 + ret = local_read_unchecked(&cpu_buffer->overrun);
84990
84991 return ret;
84992 }
84993 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
84994 return 0;
84995
84996 cpu_buffer = buffer->buffers[cpu];
84997 - ret = local_read(&cpu_buffer->commit_overrun);
84998 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
84999
85000 return ret;
85001 }
85002 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
85003 /* if you care about this being correct, lock the buffer */
85004 for_each_buffer_cpu(buffer, cpu) {
85005 cpu_buffer = buffer->buffers[cpu];
85006 - overruns += local_read(&cpu_buffer->overrun);
85007 + overruns += local_read_unchecked(&cpu_buffer->overrun);
85008 }
85009
85010 return overruns;
85011 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85012 /*
85013 * Reset the reader page to size zero.
85014 */
85015 - local_set(&cpu_buffer->reader_page->write, 0);
85016 - local_set(&cpu_buffer->reader_page->entries, 0);
85017 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85018 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85019 local_set(&cpu_buffer->reader_page->page->commit, 0);
85020 cpu_buffer->reader_page->real_end = 0;
85021
85022 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
85023 * want to compare with the last_overrun.
85024 */
85025 smp_mb();
85026 - overwrite = local_read(&(cpu_buffer->overrun));
85027 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
85028
85029 /*
85030 * Here's the tricky part.
85031 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85032
85033 cpu_buffer->head_page
85034 = list_entry(cpu_buffer->pages, struct buffer_page, list);
85035 - local_set(&cpu_buffer->head_page->write, 0);
85036 - local_set(&cpu_buffer->head_page->entries, 0);
85037 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
85038 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
85039 local_set(&cpu_buffer->head_page->page->commit, 0);
85040
85041 cpu_buffer->head_page->read = 0;
85042 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
85043
85044 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
85045 INIT_LIST_HEAD(&cpu_buffer->new_pages);
85046 - local_set(&cpu_buffer->reader_page->write, 0);
85047 - local_set(&cpu_buffer->reader_page->entries, 0);
85048 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
85049 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
85050 local_set(&cpu_buffer->reader_page->page->commit, 0);
85051 cpu_buffer->reader_page->read = 0;
85052
85053 local_set(&cpu_buffer->entries_bytes, 0);
85054 - local_set(&cpu_buffer->overrun, 0);
85055 - local_set(&cpu_buffer->commit_overrun, 0);
85056 + local_set_unchecked(&cpu_buffer->overrun, 0);
85057 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
85058 local_set(&cpu_buffer->dropped_events, 0);
85059 local_set(&cpu_buffer->entries, 0);
85060 local_set(&cpu_buffer->committing, 0);
85061 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
85062 rb_init_page(bpage);
85063 bpage = reader->page;
85064 reader->page = *data_page;
85065 - local_set(&reader->write, 0);
85066 - local_set(&reader->entries, 0);
85067 + local_set_unchecked(&reader->write, 0);
85068 + local_set_unchecked(&reader->entries, 0);
85069 reader->read = 0;
85070 *data_page = bpage;
85071
85072 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
85073 index 496f94d..754aeea 100644
85074 --- a/kernel/trace/trace.c
85075 +++ b/kernel/trace/trace.c
85076 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
85077 return 0;
85078 }
85079
85080 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
85081 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
85082 {
85083 /* do nothing if flag is already set */
85084 if (!!(trace_flags & mask) == !!enabled)
85085 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
85086 index afaae41..64871f8 100644
85087 --- a/kernel/trace/trace.h
85088 +++ b/kernel/trace/trace.h
85089 @@ -1025,7 +1025,7 @@ extern const char *__stop___trace_bprintk_fmt[];
85090 void trace_printk_init_buffers(void);
85091 void trace_printk_start_comm(void);
85092 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
85093 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
85094 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
85095
85096 /*
85097 * Normal trace_printk() and friends allocates special buffers
85098 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
85099 index 26dc348..8708ca7 100644
85100 --- a/kernel/trace/trace_clock.c
85101 +++ b/kernel/trace/trace_clock.c
85102 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
85103 return now;
85104 }
85105
85106 -static atomic64_t trace_counter;
85107 +static atomic64_unchecked_t trace_counter;
85108
85109 /*
85110 * trace_clock_counter(): simply an atomic counter.
85111 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
85112 */
85113 u64 notrace trace_clock_counter(void)
85114 {
85115 - return atomic64_add_return(1, &trace_counter);
85116 + return atomic64_inc_return_unchecked(&trace_counter);
85117 }
85118 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
85119 index 29a7ebc..eb473cf 100644
85120 --- a/kernel/trace/trace_events.c
85121 +++ b/kernel/trace/trace_events.c
85122 @@ -1778,10 +1778,6 @@ static LIST_HEAD(ftrace_module_file_list);
85123 struct ftrace_module_file_ops {
85124 struct list_head list;
85125 struct module *mod;
85126 - struct file_operations id;
85127 - struct file_operations enable;
85128 - struct file_operations format;
85129 - struct file_operations filter;
85130 };
85131
85132 static struct ftrace_module_file_ops *
85133 @@ -1822,17 +1818,12 @@ trace_create_file_ops(struct module *mod)
85134
85135 file_ops->mod = mod;
85136
85137 - file_ops->id = ftrace_event_id_fops;
85138 - file_ops->id.owner = mod;
85139 -
85140 - file_ops->enable = ftrace_enable_fops;
85141 - file_ops->enable.owner = mod;
85142 -
85143 - file_ops->filter = ftrace_event_filter_fops;
85144 - file_ops->filter.owner = mod;
85145 -
85146 - file_ops->format = ftrace_event_format_fops;
85147 - file_ops->format.owner = mod;
85148 + pax_open_kernel();
85149 + mod->trace_id.owner = mod;
85150 + mod->trace_enable.owner = mod;
85151 + mod->trace_filter.owner = mod;
85152 + mod->trace_format.owner = mod;
85153 + pax_close_kernel();
85154
85155 list_add(&file_ops->list, &ftrace_module_file_list);
85156
85157 @@ -1925,8 +1916,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
85158 struct ftrace_module_file_ops *file_ops)
85159 {
85160 return __trace_add_new_event(call, tr,
85161 - &file_ops->id, &file_ops->enable,
85162 - &file_ops->filter, &file_ops->format);
85163 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
85164 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
85165 }
85166
85167 #else
85168 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
85169 index b3dcfb2..ebee344 100644
85170 --- a/kernel/trace/trace_mmiotrace.c
85171 +++ b/kernel/trace/trace_mmiotrace.c
85172 @@ -24,7 +24,7 @@ struct header_iter {
85173 static struct trace_array *mmio_trace_array;
85174 static bool overrun_detected;
85175 static unsigned long prev_overruns;
85176 -static atomic_t dropped_count;
85177 +static atomic_unchecked_t dropped_count;
85178
85179 static void mmio_reset_data(struct trace_array *tr)
85180 {
85181 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
85182
85183 static unsigned long count_overruns(struct trace_iterator *iter)
85184 {
85185 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
85186 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
85187 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
85188
85189 if (over > prev_overruns)
85190 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
85191 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
85192 sizeof(*entry), 0, pc);
85193 if (!event) {
85194 - atomic_inc(&dropped_count);
85195 + atomic_inc_unchecked(&dropped_count);
85196 return;
85197 }
85198 entry = ring_buffer_event_data(event);
85199 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
85200 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
85201 sizeof(*entry), 0, pc);
85202 if (!event) {
85203 - atomic_inc(&dropped_count);
85204 + atomic_inc_unchecked(&dropped_count);
85205 return;
85206 }
85207 entry = ring_buffer_event_data(event);
85208 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
85209 index 34e7cba..6f9a729 100644
85210 --- a/kernel/trace/trace_output.c
85211 +++ b/kernel/trace/trace_output.c
85212 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
85213
85214 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
85215 if (!IS_ERR(p)) {
85216 - p = mangle_path(s->buffer + s->len, p, "\n");
85217 + p = mangle_path(s->buffer + s->len, p, "\n\\");
85218 if (p) {
85219 s->len = p - s->buffer;
85220 return 1;
85221 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
85222 goto out;
85223 }
85224
85225 + pax_open_kernel();
85226 if (event->funcs->trace == NULL)
85227 - event->funcs->trace = trace_nop_print;
85228 + *(void **)&event->funcs->trace = trace_nop_print;
85229 if (event->funcs->raw == NULL)
85230 - event->funcs->raw = trace_nop_print;
85231 + *(void **)&event->funcs->raw = trace_nop_print;
85232 if (event->funcs->hex == NULL)
85233 - event->funcs->hex = trace_nop_print;
85234 + *(void **)&event->funcs->hex = trace_nop_print;
85235 if (event->funcs->binary == NULL)
85236 - event->funcs->binary = trace_nop_print;
85237 + *(void **)&event->funcs->binary = trace_nop_print;
85238 + pax_close_kernel();
85239
85240 key = event->type & (EVENT_HASHSIZE - 1);
85241
85242 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
85243 index b20428c..4845a10 100644
85244 --- a/kernel/trace/trace_stack.c
85245 +++ b/kernel/trace/trace_stack.c
85246 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
85247 return;
85248
85249 /* we do not handle interrupt stacks yet */
85250 - if (!object_is_on_stack(stack))
85251 + if (!object_starts_on_stack(stack))
85252 return;
85253
85254 local_irq_save(flags);
85255 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
85256 index 9064b91..1f5d2f8 100644
85257 --- a/kernel/user_namespace.c
85258 +++ b/kernel/user_namespace.c
85259 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
85260 !kgid_has_mapping(parent_ns, group))
85261 return -EPERM;
85262
85263 +#ifdef CONFIG_GRKERNSEC
85264 + /*
85265 + * This doesn't really inspire confidence:
85266 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
85267 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
85268 + * Increases kernel attack surface in areas developers
85269 + * previously cared little about ("low importance due
85270 + * to requiring "root" capability")
85271 + * To be removed when this code receives *proper* review
85272 + */
85273 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
85274 + !capable(CAP_SETGID))
85275 + return -EPERM;
85276 +#endif
85277 +
85278 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
85279 if (!ns)
85280 return -ENOMEM;
85281 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
85282 if (atomic_read(&current->mm->mm_users) > 1)
85283 return -EINVAL;
85284
85285 - if (current->fs->users != 1)
85286 + if (atomic_read(&current->fs->users) != 1)
85287 return -EINVAL;
85288
85289 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
85290 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
85291 index 4f69f9a..7c6f8f8 100644
85292 --- a/kernel/utsname_sysctl.c
85293 +++ b/kernel/utsname_sysctl.c
85294 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
85295 static int proc_do_uts_string(ctl_table *table, int write,
85296 void __user *buffer, size_t *lenp, loff_t *ppos)
85297 {
85298 - struct ctl_table uts_table;
85299 + ctl_table_no_const uts_table;
85300 int r;
85301 memcpy(&uts_table, table, sizeof(uts_table));
85302 uts_table.data = get_uts(table, write);
85303 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
85304 index 1241d8c..d5cfc28 100644
85305 --- a/kernel/watchdog.c
85306 +++ b/kernel/watchdog.c
85307 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
85308 static void watchdog_nmi_disable(unsigned int cpu) { return; }
85309 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
85310
85311 -static struct smp_hotplug_thread watchdog_threads = {
85312 +static struct smp_hotplug_thread watchdog_threads __read_only = {
85313 .store = &softlockup_watchdog,
85314 .thread_should_run = watchdog_should_run,
85315 .thread_fn = watchdog,
85316 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
85317 index e93f7b9..989fcd7 100644
85318 --- a/kernel/workqueue.c
85319 +++ b/kernel/workqueue.c
85320 @@ -4627,7 +4627,7 @@ static void rebind_workers(struct worker_pool *pool)
85321 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
85322 worker_flags |= WORKER_REBOUND;
85323 worker_flags &= ~WORKER_UNBOUND;
85324 - ACCESS_ONCE(worker->flags) = worker_flags;
85325 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
85326 }
85327
85328 spin_unlock_irq(&pool->lock);
85329 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
85330 index 1501aa5..e771896 100644
85331 --- a/lib/Kconfig.debug
85332 +++ b/lib/Kconfig.debug
85333 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
85334
85335 config DEBUG_WW_MUTEX_SLOWPATH
85336 bool "Wait/wound mutex debugging: Slowpath testing"
85337 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85338 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85339 select DEBUG_LOCK_ALLOC
85340 select DEBUG_SPINLOCK
85341 select DEBUG_MUTEXES
85342 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
85343
85344 config DEBUG_LOCK_ALLOC
85345 bool "Lock debugging: detect incorrect freeing of live locks"
85346 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85347 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85348 select DEBUG_SPINLOCK
85349 select DEBUG_MUTEXES
85350 select LOCKDEP
85351 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
85352
85353 config PROVE_LOCKING
85354 bool "Lock debugging: prove locking correctness"
85355 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85356 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85357 select LOCKDEP
85358 select DEBUG_SPINLOCK
85359 select DEBUG_MUTEXES
85360 @@ -914,7 +914,7 @@ config LOCKDEP
85361
85362 config LOCK_STAT
85363 bool "Lock usage statistics"
85364 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
85365 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
85366 select LOCKDEP
85367 select DEBUG_SPINLOCK
85368 select DEBUG_MUTEXES
85369 @@ -1357,6 +1357,7 @@ config LATENCYTOP
85370 depends on DEBUG_KERNEL
85371 depends on STACKTRACE_SUPPORT
85372 depends on PROC_FS
85373 + depends on !GRKERNSEC_HIDESYM
85374 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
85375 select KALLSYMS
85376 select KALLSYMS_ALL
85377 @@ -1373,7 +1374,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85378 config DEBUG_STRICT_USER_COPY_CHECKS
85379 bool "Strict user copy size checks"
85380 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
85381 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
85382 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
85383 help
85384 Enabling this option turns a certain set of sanity checks for user
85385 copy operations into compile time failures.
85386 @@ -1483,7 +1484,7 @@ endmenu # runtime tests
85387
85388 config PROVIDE_OHCI1394_DMA_INIT
85389 bool "Remote debugging over FireWire early on boot"
85390 - depends on PCI && X86
85391 + depends on PCI && X86 && !GRKERNSEC
85392 help
85393 If you want to debug problems which hang or crash the kernel early
85394 on boot and the crashing machine has a FireWire port, you can use
85395 @@ -1512,7 +1513,7 @@ config PROVIDE_OHCI1394_DMA_INIT
85396
85397 config FIREWIRE_OHCI_REMOTE_DMA
85398 bool "Remote debugging over FireWire with firewire-ohci"
85399 - depends on FIREWIRE_OHCI
85400 + depends on FIREWIRE_OHCI && !GRKERNSEC
85401 help
85402 This option lets you use the FireWire bus for remote debugging
85403 with help of the firewire-ohci driver. It enables unfiltered
85404 diff --git a/lib/Makefile b/lib/Makefile
85405 index 7baccfd..3ceb95f 100644
85406 --- a/lib/Makefile
85407 +++ b/lib/Makefile
85408 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
85409
85410 obj-$(CONFIG_BTREE) += btree.o
85411 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
85412 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
85413 +obj-y += list_debug.o
85414 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
85415
85416 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
85417 diff --git a/lib/bitmap.c b/lib/bitmap.c
85418 index 06f7e4f..f3cf2b0 100644
85419 --- a/lib/bitmap.c
85420 +++ b/lib/bitmap.c
85421 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
85422 {
85423 int c, old_c, totaldigits, ndigits, nchunks, nbits;
85424 u32 chunk;
85425 - const char __user __force *ubuf = (const char __user __force *)buf;
85426 + const char __user *ubuf = (const char __force_user *)buf;
85427
85428 bitmap_zero(maskp, nmaskbits);
85429
85430 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
85431 {
85432 if (!access_ok(VERIFY_READ, ubuf, ulen))
85433 return -EFAULT;
85434 - return __bitmap_parse((const char __force *)ubuf,
85435 + return __bitmap_parse((const char __force_kernel *)ubuf,
85436 ulen, 1, maskp, nmaskbits);
85437
85438 }
85439 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
85440 {
85441 unsigned a, b;
85442 int c, old_c, totaldigits;
85443 - const char __user __force *ubuf = (const char __user __force *)buf;
85444 + const char __user *ubuf = (const char __force_user *)buf;
85445 int exp_digit, in_range;
85446
85447 totaldigits = c = 0;
85448 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
85449 {
85450 if (!access_ok(VERIFY_READ, ubuf, ulen))
85451 return -EFAULT;
85452 - return __bitmap_parselist((const char __force *)ubuf,
85453 + return __bitmap_parselist((const char __force_kernel *)ubuf,
85454 ulen, 1, maskp, nmaskbits);
85455 }
85456 EXPORT_SYMBOL(bitmap_parselist_user);
85457 diff --git a/lib/bug.c b/lib/bug.c
85458 index 1686034..a9c00c8 100644
85459 --- a/lib/bug.c
85460 +++ b/lib/bug.c
85461 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
85462 return BUG_TRAP_TYPE_NONE;
85463
85464 bug = find_bug(bugaddr);
85465 + if (!bug)
85466 + return BUG_TRAP_TYPE_NONE;
85467
85468 file = NULL;
85469 line = 0;
85470 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
85471 index 37061ed..da83f48 100644
85472 --- a/lib/debugobjects.c
85473 +++ b/lib/debugobjects.c
85474 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
85475 if (limit > 4)
85476 return;
85477
85478 - is_on_stack = object_is_on_stack(addr);
85479 + is_on_stack = object_starts_on_stack(addr);
85480 if (is_on_stack == onstack)
85481 return;
85482
85483 diff --git a/lib/devres.c b/lib/devres.c
85484 index 8235331..5881053 100644
85485 --- a/lib/devres.c
85486 +++ b/lib/devres.c
85487 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
85488 void devm_iounmap(struct device *dev, void __iomem *addr)
85489 {
85490 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
85491 - (void *)addr));
85492 + (void __force *)addr));
85493 iounmap(addr);
85494 }
85495 EXPORT_SYMBOL(devm_iounmap);
85496 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
85497 {
85498 ioport_unmap(addr);
85499 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
85500 - devm_ioport_map_match, (void *)addr));
85501 + devm_ioport_map_match, (void __force *)addr));
85502 }
85503 EXPORT_SYMBOL(devm_ioport_unmap);
85504 #endif /* CONFIG_HAS_IOPORT */
85505 diff --git a/lib/div64.c b/lib/div64.c
85506 index a163b6c..9618fa5 100644
85507 --- a/lib/div64.c
85508 +++ b/lib/div64.c
85509 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
85510 EXPORT_SYMBOL(__div64_32);
85511
85512 #ifndef div_s64_rem
85513 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85514 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
85515 {
85516 u64 quotient;
85517
85518 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
85519 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
85520 */
85521 #ifndef div64_u64
85522 -u64 div64_u64(u64 dividend, u64 divisor)
85523 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
85524 {
85525 u32 high = divisor >> 32;
85526 u64 quot;
85527 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
85528 index d87a17a..ac0d79a 100644
85529 --- a/lib/dma-debug.c
85530 +++ b/lib/dma-debug.c
85531 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
85532
85533 void dma_debug_add_bus(struct bus_type *bus)
85534 {
85535 - struct notifier_block *nb;
85536 + notifier_block_no_const *nb;
85537
85538 if (global_disable)
85539 return;
85540 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
85541
85542 static void check_for_stack(struct device *dev, void *addr)
85543 {
85544 - if (object_is_on_stack(addr))
85545 + if (object_starts_on_stack(addr))
85546 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
85547 "stack [addr=%p]\n", addr);
85548 }
85549 diff --git a/lib/inflate.c b/lib/inflate.c
85550 index 013a761..c28f3fc 100644
85551 --- a/lib/inflate.c
85552 +++ b/lib/inflate.c
85553 @@ -269,7 +269,7 @@ static void free(void *where)
85554 malloc_ptr = free_mem_ptr;
85555 }
85556 #else
85557 -#define malloc(a) kmalloc(a, GFP_KERNEL)
85558 +#define malloc(a) kmalloc((a), GFP_KERNEL)
85559 #define free(a) kfree(a)
85560 #endif
85561
85562 diff --git a/lib/ioremap.c b/lib/ioremap.c
85563 index 0c9216c..863bd89 100644
85564 --- a/lib/ioremap.c
85565 +++ b/lib/ioremap.c
85566 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
85567 unsigned long next;
85568
85569 phys_addr -= addr;
85570 - pmd = pmd_alloc(&init_mm, pud, addr);
85571 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85572 if (!pmd)
85573 return -ENOMEM;
85574 do {
85575 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
85576 unsigned long next;
85577
85578 phys_addr -= addr;
85579 - pud = pud_alloc(&init_mm, pgd, addr);
85580 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85581 if (!pud)
85582 return -ENOMEM;
85583 do {
85584 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
85585 index bd2bea9..6b3c95e 100644
85586 --- a/lib/is_single_threaded.c
85587 +++ b/lib/is_single_threaded.c
85588 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
85589 struct task_struct *p, *t;
85590 bool ret;
85591
85592 + if (!mm)
85593 + return true;
85594 +
85595 if (atomic_read(&task->signal->live) != 1)
85596 return false;
85597
85598 diff --git a/lib/kobject.c b/lib/kobject.c
85599 index 4a1f33d..2f3ca75 100644
85600 --- a/lib/kobject.c
85601 +++ b/lib/kobject.c
85602 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
85603
85604
85605 static DEFINE_SPINLOCK(kobj_ns_type_lock);
85606 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
85607 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
85608
85609 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85610 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
85611 {
85612 enum kobj_ns_type type = ops->type;
85613 int error;
85614 diff --git a/lib/list_debug.c b/lib/list_debug.c
85615 index c24c2f7..06e070b 100644
85616 --- a/lib/list_debug.c
85617 +++ b/lib/list_debug.c
85618 @@ -11,7 +11,9 @@
85619 #include <linux/bug.h>
85620 #include <linux/kernel.h>
85621 #include <linux/rculist.h>
85622 +#include <linux/mm.h>
85623
85624 +#ifdef CONFIG_DEBUG_LIST
85625 /*
85626 * Insert a new entry between two known consecutive entries.
85627 *
85628 @@ -19,21 +21,32 @@
85629 * the prev/next entries already!
85630 */
85631
85632 -void __list_add(struct list_head *new,
85633 - struct list_head *prev,
85634 - struct list_head *next)
85635 +static bool __list_add_debug(struct list_head *new,
85636 + struct list_head *prev,
85637 + struct list_head *next)
85638 {
85639 - WARN(next->prev != prev,
85640 + if (WARN(next->prev != prev,
85641 "list_add corruption. next->prev should be "
85642 "prev (%p), but was %p. (next=%p).\n",
85643 - prev, next->prev, next);
85644 - WARN(prev->next != next,
85645 + prev, next->prev, next) ||
85646 + WARN(prev->next != next,
85647 "list_add corruption. prev->next should be "
85648 "next (%p), but was %p. (prev=%p).\n",
85649 - next, prev->next, prev);
85650 - WARN(new == prev || new == next,
85651 - "list_add double add: new=%p, prev=%p, next=%p.\n",
85652 - new, prev, next);
85653 + next, prev->next, prev) ||
85654 + WARN(new == prev || new == next,
85655 + "list_add double add: new=%p, prev=%p, next=%p.\n",
85656 + new, prev, next))
85657 + return false;
85658 + return true;
85659 +}
85660 +
85661 +void __list_add(struct list_head *new,
85662 + struct list_head *prev,
85663 + struct list_head *next)
85664 +{
85665 + if (!__list_add_debug(new, prev, next))
85666 + return;
85667 +
85668 next->prev = new;
85669 new->next = next;
85670 new->prev = prev;
85671 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
85672 }
85673 EXPORT_SYMBOL(__list_add);
85674
85675 -void __list_del_entry(struct list_head *entry)
85676 +static bool __list_del_entry_debug(struct list_head *entry)
85677 {
85678 struct list_head *prev, *next;
85679
85680 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
85681 WARN(next->prev != entry,
85682 "list_del corruption. next->prev should be %p, "
85683 "but was %p\n", entry, next->prev))
85684 + return false;
85685 + return true;
85686 +}
85687 +
85688 +void __list_del_entry(struct list_head *entry)
85689 +{
85690 + if (!__list_del_entry_debug(entry))
85691 return;
85692
85693 - __list_del(prev, next);
85694 + __list_del(entry->prev, entry->next);
85695 }
85696 EXPORT_SYMBOL(__list_del_entry);
85697
85698 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
85699 void __list_add_rcu(struct list_head *new,
85700 struct list_head *prev, struct list_head *next)
85701 {
85702 - WARN(next->prev != prev,
85703 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
85704 - prev, next->prev, next);
85705 - WARN(prev->next != next,
85706 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
85707 - next, prev->next, prev);
85708 + if (!__list_add_debug(new, prev, next))
85709 + return;
85710 +
85711 new->next = next;
85712 new->prev = prev;
85713 rcu_assign_pointer(list_next_rcu(prev), new);
85714 next->prev = new;
85715 }
85716 EXPORT_SYMBOL(__list_add_rcu);
85717 +#endif
85718 +
85719 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
85720 +{
85721 +#ifdef CONFIG_DEBUG_LIST
85722 + if (!__list_add_debug(new, prev, next))
85723 + return;
85724 +#endif
85725 +
85726 + pax_open_kernel();
85727 + next->prev = new;
85728 + new->next = next;
85729 + new->prev = prev;
85730 + prev->next = new;
85731 + pax_close_kernel();
85732 +}
85733 +EXPORT_SYMBOL(__pax_list_add);
85734 +
85735 +void pax_list_del(struct list_head *entry)
85736 +{
85737 +#ifdef CONFIG_DEBUG_LIST
85738 + if (!__list_del_entry_debug(entry))
85739 + return;
85740 +#endif
85741 +
85742 + pax_open_kernel();
85743 + __list_del(entry->prev, entry->next);
85744 + entry->next = LIST_POISON1;
85745 + entry->prev = LIST_POISON2;
85746 + pax_close_kernel();
85747 +}
85748 +EXPORT_SYMBOL(pax_list_del);
85749 +
85750 +void pax_list_del_init(struct list_head *entry)
85751 +{
85752 + pax_open_kernel();
85753 + __list_del(entry->prev, entry->next);
85754 + INIT_LIST_HEAD(entry);
85755 + pax_close_kernel();
85756 +}
85757 +EXPORT_SYMBOL(pax_list_del_init);
85758 +
85759 +void __pax_list_add_rcu(struct list_head *new,
85760 + struct list_head *prev, struct list_head *next)
85761 +{
85762 +#ifdef CONFIG_DEBUG_LIST
85763 + if (!__list_add_debug(new, prev, next))
85764 + return;
85765 +#endif
85766 +
85767 + pax_open_kernel();
85768 + new->next = next;
85769 + new->prev = prev;
85770 + rcu_assign_pointer(list_next_rcu(prev), new);
85771 + next->prev = new;
85772 + pax_close_kernel();
85773 +}
85774 +EXPORT_SYMBOL(__pax_list_add_rcu);
85775 +
85776 +void pax_list_del_rcu(struct list_head *entry)
85777 +{
85778 +#ifdef CONFIG_DEBUG_LIST
85779 + if (!__list_del_entry_debug(entry))
85780 + return;
85781 +#endif
85782 +
85783 + pax_open_kernel();
85784 + __list_del(entry->prev, entry->next);
85785 + entry->next = LIST_POISON1;
85786 + entry->prev = LIST_POISON2;
85787 + pax_close_kernel();
85788 +}
85789 +EXPORT_SYMBOL(pax_list_del_rcu);
85790 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
85791 index 7deeb62..144eb47 100644
85792 --- a/lib/percpu-refcount.c
85793 +++ b/lib/percpu-refcount.c
85794 @@ -29,7 +29,7 @@
85795 * can't hit 0 before we've added up all the percpu refs.
85796 */
85797
85798 -#define PCPU_COUNT_BIAS (1U << 31)
85799 +#define PCPU_COUNT_BIAS (1U << 30)
85800
85801 /**
85802 * percpu_ref_init - initialize a percpu refcount
85803 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
85804 index e796429..6e38f9f 100644
85805 --- a/lib/radix-tree.c
85806 +++ b/lib/radix-tree.c
85807 @@ -92,7 +92,7 @@ struct radix_tree_preload {
85808 int nr;
85809 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
85810 };
85811 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
85812 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
85813
85814 static inline void *ptr_to_indirect(void *ptr)
85815 {
85816 diff --git a/lib/scatterlist.c b/lib/scatterlist.c
85817 index a685c8a..d16fa29 100644
85818 --- a/lib/scatterlist.c
85819 +++ b/lib/scatterlist.c
85820 @@ -577,7 +577,8 @@ void sg_miter_stop(struct sg_mapping_iter *miter)
85821 miter->__offset += miter->consumed;
85822 miter->__remaining -= miter->consumed;
85823
85824 - if (miter->__flags & SG_MITER_TO_SG)
85825 + if ((miter->__flags & SG_MITER_TO_SG) &&
85826 + !PageSlab(miter->page))
85827 flush_kernel_dcache_page(miter->page);
85828
85829 if (miter->__flags & SG_MITER_ATOMIC) {
85830 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
85831 index bb2b201..46abaf9 100644
85832 --- a/lib/strncpy_from_user.c
85833 +++ b/lib/strncpy_from_user.c
85834 @@ -21,7 +21,7 @@
85835 */
85836 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
85837 {
85838 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85839 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85840 long res = 0;
85841
85842 /*
85843 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
85844 index a28df52..3d55877 100644
85845 --- a/lib/strnlen_user.c
85846 +++ b/lib/strnlen_user.c
85847 @@ -26,7 +26,7 @@
85848 */
85849 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
85850 {
85851 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85852 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
85853 long align, res = 0;
85854 unsigned long c;
85855
85856 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
85857 index d23762e..e21eab2 100644
85858 --- a/lib/swiotlb.c
85859 +++ b/lib/swiotlb.c
85860 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
85861
85862 void
85863 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
85864 - dma_addr_t dev_addr)
85865 + dma_addr_t dev_addr, struct dma_attrs *attrs)
85866 {
85867 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
85868
85869 diff --git a/lib/usercopy.c b/lib/usercopy.c
85870 index 4f5b1dd..7cab418 100644
85871 --- a/lib/usercopy.c
85872 +++ b/lib/usercopy.c
85873 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
85874 WARN(1, "Buffer overflow detected!\n");
85875 }
85876 EXPORT_SYMBOL(copy_from_user_overflow);
85877 +
85878 +void copy_to_user_overflow(void)
85879 +{
85880 + WARN(1, "Buffer overflow detected!\n");
85881 +}
85882 +EXPORT_SYMBOL(copy_to_user_overflow);
85883 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
85884 index 739a363..aa668d7 100644
85885 --- a/lib/vsprintf.c
85886 +++ b/lib/vsprintf.c
85887 @@ -16,6 +16,9 @@
85888 * - scnprintf and vscnprintf
85889 */
85890
85891 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85892 +#define __INCLUDED_BY_HIDESYM 1
85893 +#endif
85894 #include <stdarg.h>
85895 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
85896 #include <linux/types.h>
85897 @@ -1078,7 +1081,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
85898 return number(buf, end, *(const netdev_features_t *)addr, spec);
85899 }
85900
85901 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85902 +int kptr_restrict __read_mostly = 2;
85903 +#else
85904 int kptr_restrict __read_mostly;
85905 +#endif
85906
85907 /*
85908 * Show a '%p' thing. A kernel extension is that the '%p' is followed
85909 @@ -1091,6 +1098,7 @@ int kptr_restrict __read_mostly;
85910 * - 'f' For simple symbolic function names without offset
85911 * - 'S' For symbolic direct pointers with offset
85912 * - 's' For symbolic direct pointers without offset
85913 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
85914 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
85915 * - 'B' For backtraced symbolic direct pointers with offset
85916 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
85917 @@ -1155,12 +1163,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85918
85919 if (!ptr && *fmt != 'K') {
85920 /*
85921 - * Print (null) with the same width as a pointer so it makes
85922 + * Print (nil) with the same width as a pointer so it makes
85923 * tabular output look nice.
85924 */
85925 if (spec.field_width == -1)
85926 spec.field_width = default_width;
85927 - return string(buf, end, "(null)", spec);
85928 + return string(buf, end, "(nil)", spec);
85929 }
85930
85931 switch (*fmt) {
85932 @@ -1170,6 +1178,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85933 /* Fallthrough */
85934 case 'S':
85935 case 's':
85936 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85937 + break;
85938 +#else
85939 + return symbol_string(buf, end, ptr, spec, fmt);
85940 +#endif
85941 + case 'A':
85942 case 'B':
85943 return symbol_string(buf, end, ptr, spec, fmt);
85944 case 'R':
85945 @@ -1225,6 +1239,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85946 va_end(va);
85947 return buf;
85948 }
85949 + case 'P':
85950 + break;
85951 case 'K':
85952 /*
85953 * %pK cannot be used in IRQ context because its test
85954 @@ -1254,6 +1270,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
85955 return number(buf, end,
85956 (unsigned long long) *((phys_addr_t *)ptr), spec);
85957 }
85958 +
85959 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85960 + /* 'P' = approved pointers to copy to userland,
85961 + as in the /proc/kallsyms case, as we make it display nothing
85962 + for non-root users, and the real contents for root users
85963 + Also ignore 'K' pointers, since we force their NULLing for non-root users
85964 + above
85965 + */
85966 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
85967 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
85968 + dump_stack();
85969 + ptr = NULL;
85970 + }
85971 +#endif
85972 +
85973 spec.flags |= SMALL;
85974 if (spec.field_width == -1) {
85975 spec.field_width = default_width;
85976 @@ -1977,11 +2008,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85977 typeof(type) value; \
85978 if (sizeof(type) == 8) { \
85979 args = PTR_ALIGN(args, sizeof(u32)); \
85980 - *(u32 *)&value = *(u32 *)args; \
85981 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
85982 + *(u32 *)&value = *(const u32 *)args; \
85983 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
85984 } else { \
85985 args = PTR_ALIGN(args, sizeof(type)); \
85986 - value = *(typeof(type) *)args; \
85987 + value = *(const typeof(type) *)args; \
85988 } \
85989 args += sizeof(type); \
85990 value; \
85991 @@ -2044,7 +2075,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
85992 case FORMAT_TYPE_STR: {
85993 const char *str_arg = args;
85994 args += strlen(str_arg) + 1;
85995 - str = string(str, end, (char *)str_arg, spec);
85996 + str = string(str, end, str_arg, spec);
85997 break;
85998 }
85999
86000 diff --git a/localversion-grsec b/localversion-grsec
86001 new file mode 100644
86002 index 0000000..7cd6065
86003 --- /dev/null
86004 +++ b/localversion-grsec
86005 @@ -0,0 +1 @@
86006 +-grsec
86007 diff --git a/mm/Kconfig b/mm/Kconfig
86008 index 6509d27..dbec5b8 100644
86009 --- a/mm/Kconfig
86010 +++ b/mm/Kconfig
86011 @@ -317,10 +317,10 @@ config KSM
86012 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
86013
86014 config DEFAULT_MMAP_MIN_ADDR
86015 - int "Low address space to protect from user allocation"
86016 + int "Low address space to protect from user allocation"
86017 depends on MMU
86018 - default 4096
86019 - help
86020 + default 65536
86021 + help
86022 This is the portion of low virtual memory which should be protected
86023 from userspace allocation. Keeping a user from writing to low pages
86024 can help reduce the impact of kernel NULL pointer bugs.
86025 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
86026
86027 config HWPOISON_INJECT
86028 tristate "HWPoison pages injector"
86029 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
86030 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
86031 select PROC_PAGE_MONITOR
86032
86033 config NOMMU_INITIAL_TRIM_EXCESS
86034 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
86035 index e04454c..ca5be3e 100644
86036 --- a/mm/backing-dev.c
86037 +++ b/mm/backing-dev.c
86038 @@ -12,7 +12,7 @@
86039 #include <linux/device.h>
86040 #include <trace/events/writeback.h>
86041
86042 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
86043 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
86044
86045 struct backing_dev_info default_backing_dev_info = {
86046 .name = "default",
86047 @@ -522,7 +522,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
86048 return err;
86049
86050 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
86051 - atomic_long_inc_return(&bdi_seq));
86052 + atomic_long_inc_return_unchecked(&bdi_seq));
86053 if (err) {
86054 bdi_destroy(bdi);
86055 return err;
86056 diff --git a/mm/filemap.c b/mm/filemap.c
86057 index 4b51ac1..5aa90ff 100644
86058 --- a/mm/filemap.c
86059 +++ b/mm/filemap.c
86060 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
86061 struct address_space *mapping = file->f_mapping;
86062
86063 if (!mapping->a_ops->readpage)
86064 - return -ENOEXEC;
86065 + return -ENODEV;
86066 file_accessed(file);
86067 vma->vm_ops = &generic_file_vm_ops;
86068 return 0;
86069 @@ -1948,7 +1948,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
86070
86071 while (bytes) {
86072 char __user *buf = iov->iov_base + base;
86073 - int copy = min(bytes, iov->iov_len - base);
86074 + size_t copy = min(bytes, iov->iov_len - base);
86075
86076 base = 0;
86077 left = __copy_from_user_inatomic(vaddr, buf, copy);
86078 @@ -1977,7 +1977,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
86079 BUG_ON(!in_atomic());
86080 kaddr = kmap_atomic(page);
86081 if (likely(i->nr_segs == 1)) {
86082 - int left;
86083 + size_t left;
86084 char __user *buf = i->iov->iov_base + i->iov_offset;
86085 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
86086 copied = bytes - left;
86087 @@ -2005,7 +2005,7 @@ size_t iov_iter_copy_from_user(struct page *page,
86088
86089 kaddr = kmap(page);
86090 if (likely(i->nr_segs == 1)) {
86091 - int left;
86092 + size_t left;
86093 char __user *buf = i->iov->iov_base + i->iov_offset;
86094 left = __copy_from_user(kaddr + offset, buf, bytes);
86095 copied = bytes - left;
86096 @@ -2035,7 +2035,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
86097 * zero-length segments (without overruning the iovec).
86098 */
86099 while (bytes || unlikely(i->count && !iov->iov_len)) {
86100 - int copy;
86101 + size_t copy;
86102
86103 copy = min(bytes, iov->iov_len - base);
86104 BUG_ON(!i->count || i->count < copy);
86105 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
86106 *pos = i_size_read(inode);
86107
86108 if (limit != RLIM_INFINITY) {
86109 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
86110 if (*pos >= limit) {
86111 send_sig(SIGXFSZ, current, 0);
86112 return -EFBIG;
86113 diff --git a/mm/fremap.c b/mm/fremap.c
86114 index 5bff081..d8189a9 100644
86115 --- a/mm/fremap.c
86116 +++ b/mm/fremap.c
86117 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
86118 retry:
86119 vma = find_vma(mm, start);
86120
86121 +#ifdef CONFIG_PAX_SEGMEXEC
86122 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
86123 + goto out;
86124 +#endif
86125 +
86126 /*
86127 * Make sure the vma is shared, that it supports prefaulting,
86128 * and that the remapped range is valid and fully within
86129 diff --git a/mm/highmem.c b/mm/highmem.c
86130 index b32b70c..e512eb0 100644
86131 --- a/mm/highmem.c
86132 +++ b/mm/highmem.c
86133 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
86134 * So no dangers, even with speculative execution.
86135 */
86136 page = pte_page(pkmap_page_table[i]);
86137 + pax_open_kernel();
86138 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
86139 -
86140 + pax_close_kernel();
86141 set_page_address(page, NULL);
86142 need_flush = 1;
86143 }
86144 @@ -198,9 +199,11 @@ start:
86145 }
86146 }
86147 vaddr = PKMAP_ADDR(last_pkmap_nr);
86148 +
86149 + pax_open_kernel();
86150 set_pte_at(&init_mm, vaddr,
86151 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
86152 -
86153 + pax_close_kernel();
86154 pkmap_count[last_pkmap_nr] = 1;
86155 set_page_address(page, (void *)vaddr);
86156
86157 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
86158 index b60f330..ee7de7e 100644
86159 --- a/mm/hugetlb.c
86160 +++ b/mm/hugetlb.c
86161 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
86162 struct hstate *h = &default_hstate;
86163 unsigned long tmp;
86164 int ret;
86165 + ctl_table_no_const hugetlb_table;
86166
86167 tmp = h->max_huge_pages;
86168
86169 if (write && h->order >= MAX_ORDER)
86170 return -EINVAL;
86171
86172 - table->data = &tmp;
86173 - table->maxlen = sizeof(unsigned long);
86174 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86175 + hugetlb_table = *table;
86176 + hugetlb_table.data = &tmp;
86177 + hugetlb_table.maxlen = sizeof(unsigned long);
86178 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86179 if (ret)
86180 goto out;
86181
86182 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
86183 struct hstate *h = &default_hstate;
86184 unsigned long tmp;
86185 int ret;
86186 + ctl_table_no_const hugetlb_table;
86187
86188 tmp = h->nr_overcommit_huge_pages;
86189
86190 if (write && h->order >= MAX_ORDER)
86191 return -EINVAL;
86192
86193 - table->data = &tmp;
86194 - table->maxlen = sizeof(unsigned long);
86195 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
86196 + hugetlb_table = *table;
86197 + hugetlb_table.data = &tmp;
86198 + hugetlb_table.maxlen = sizeof(unsigned long);
86199 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
86200 if (ret)
86201 goto out;
86202
86203 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
86204 return 1;
86205 }
86206
86207 +#ifdef CONFIG_PAX_SEGMEXEC
86208 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
86209 +{
86210 + struct mm_struct *mm = vma->vm_mm;
86211 + struct vm_area_struct *vma_m;
86212 + unsigned long address_m;
86213 + pte_t *ptep_m;
86214 +
86215 + vma_m = pax_find_mirror_vma(vma);
86216 + if (!vma_m)
86217 + return;
86218 +
86219 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86220 + address_m = address + SEGMEXEC_TASK_SIZE;
86221 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
86222 + get_page(page_m);
86223 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
86224 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
86225 +}
86226 +#endif
86227 +
86228 /*
86229 * Hugetlb_cow() should be called with page lock of the original hugepage held.
86230 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
86231 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
86232 make_huge_pte(vma, new_page, 1));
86233 page_remove_rmap(old_page);
86234 hugepage_add_new_anon_rmap(new_page, vma, address);
86235 +
86236 +#ifdef CONFIG_PAX_SEGMEXEC
86237 + pax_mirror_huge_pte(vma, address, new_page);
86238 +#endif
86239 +
86240 /* Make the old page be freed below */
86241 new_page = old_page;
86242 }
86243 @@ -2821,6 +2851,10 @@ retry:
86244 && (vma->vm_flags & VM_SHARED)));
86245 set_huge_pte_at(mm, address, ptep, new_pte);
86246
86247 +#ifdef CONFIG_PAX_SEGMEXEC
86248 + pax_mirror_huge_pte(vma, address, page);
86249 +#endif
86250 +
86251 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
86252 /* Optimization, do the COW without a second fault */
86253 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
86254 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86255 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
86256 struct hstate *h = hstate_vma(vma);
86257
86258 +#ifdef CONFIG_PAX_SEGMEXEC
86259 + struct vm_area_struct *vma_m;
86260 +#endif
86261 +
86262 address &= huge_page_mask(h);
86263
86264 ptep = huge_pte_offset(mm, address);
86265 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
86266 VM_FAULT_SET_HINDEX(hstate_index(h));
86267 }
86268
86269 +#ifdef CONFIG_PAX_SEGMEXEC
86270 + vma_m = pax_find_mirror_vma(vma);
86271 + if (vma_m) {
86272 + unsigned long address_m;
86273 +
86274 + if (vma->vm_start > vma_m->vm_start) {
86275 + address_m = address;
86276 + address -= SEGMEXEC_TASK_SIZE;
86277 + vma = vma_m;
86278 + h = hstate_vma(vma);
86279 + } else
86280 + address_m = address + SEGMEXEC_TASK_SIZE;
86281 +
86282 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
86283 + return VM_FAULT_OOM;
86284 + address_m &= HPAGE_MASK;
86285 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
86286 + }
86287 +#endif
86288 +
86289 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
86290 if (!ptep)
86291 return VM_FAULT_OOM;
86292 diff --git a/mm/internal.h b/mm/internal.h
86293 index 4390ac6..fc60373c 100644
86294 --- a/mm/internal.h
86295 +++ b/mm/internal.h
86296 @@ -95,6 +95,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
86297 * in mm/page_alloc.c
86298 */
86299 extern void __free_pages_bootmem(struct page *page, unsigned int order);
86300 +extern void free_compound_page(struct page *page);
86301 extern void prep_compound_page(struct page *page, unsigned long order);
86302 #ifdef CONFIG_MEMORY_FAILURE
86303 extern bool is_free_buddy_page(struct page *page);
86304 @@ -350,7 +351,7 @@ extern u32 hwpoison_filter_enable;
86305
86306 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
86307 unsigned long, unsigned long,
86308 - unsigned long, unsigned long);
86309 + unsigned long, unsigned long) __intentional_overflow(-1);
86310
86311 extern void set_pageblock_order(void);
86312 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
86313 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
86314 index c8d7f31..2dbeffd 100644
86315 --- a/mm/kmemleak.c
86316 +++ b/mm/kmemleak.c
86317 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
86318
86319 for (i = 0; i < object->trace_len; i++) {
86320 void *ptr = (void *)object->trace[i];
86321 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
86322 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
86323 }
86324 }
86325
86326 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
86327 return -ENOMEM;
86328 }
86329
86330 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
86331 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
86332 &kmemleak_fops);
86333 if (!dentry)
86334 pr_warning("Failed to create the debugfs kmemleak file\n");
86335 diff --git a/mm/maccess.c b/mm/maccess.c
86336 index d53adf9..03a24bf 100644
86337 --- a/mm/maccess.c
86338 +++ b/mm/maccess.c
86339 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
86340 set_fs(KERNEL_DS);
86341 pagefault_disable();
86342 ret = __copy_from_user_inatomic(dst,
86343 - (__force const void __user *)src, size);
86344 + (const void __force_user *)src, size);
86345 pagefault_enable();
86346 set_fs(old_fs);
86347
86348 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
86349
86350 set_fs(KERNEL_DS);
86351 pagefault_disable();
86352 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
86353 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
86354 pagefault_enable();
86355 set_fs(old_fs);
86356
86357 diff --git a/mm/madvise.c b/mm/madvise.c
86358 index 7055883..aafb1ed 100644
86359 --- a/mm/madvise.c
86360 +++ b/mm/madvise.c
86361 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
86362 pgoff_t pgoff;
86363 unsigned long new_flags = vma->vm_flags;
86364
86365 +#ifdef CONFIG_PAX_SEGMEXEC
86366 + struct vm_area_struct *vma_m;
86367 +#endif
86368 +
86369 switch (behavior) {
86370 case MADV_NORMAL:
86371 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
86372 @@ -126,6 +130,13 @@ success:
86373 /*
86374 * vm_flags is protected by the mmap_sem held in write mode.
86375 */
86376 +
86377 +#ifdef CONFIG_PAX_SEGMEXEC
86378 + vma_m = pax_find_mirror_vma(vma);
86379 + if (vma_m)
86380 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
86381 +#endif
86382 +
86383 vma->vm_flags = new_flags;
86384
86385 out:
86386 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86387 struct vm_area_struct ** prev,
86388 unsigned long start, unsigned long end)
86389 {
86390 +
86391 +#ifdef CONFIG_PAX_SEGMEXEC
86392 + struct vm_area_struct *vma_m;
86393 +#endif
86394 +
86395 *prev = vma;
86396 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
86397 return -EINVAL;
86398 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
86399 zap_page_range(vma, start, end - start, &details);
86400 } else
86401 zap_page_range(vma, start, end - start, NULL);
86402 +
86403 +#ifdef CONFIG_PAX_SEGMEXEC
86404 + vma_m = pax_find_mirror_vma(vma);
86405 + if (vma_m) {
86406 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
86407 + struct zap_details details = {
86408 + .nonlinear_vma = vma_m,
86409 + .last_index = ULONG_MAX,
86410 + };
86411 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
86412 + } else
86413 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
86414 + }
86415 +#endif
86416 +
86417 return 0;
86418 }
86419
86420 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
86421 if (end < start)
86422 return error;
86423
86424 +#ifdef CONFIG_PAX_SEGMEXEC
86425 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86426 + if (end > SEGMEXEC_TASK_SIZE)
86427 + return error;
86428 + } else
86429 +#endif
86430 +
86431 + if (end > TASK_SIZE)
86432 + return error;
86433 +
86434 error = 0;
86435 if (end == start)
86436 return error;
86437 diff --git a/mm/memcontrol.c b/mm/memcontrol.c
86438 index aa44621..99011b3 100644
86439 --- a/mm/memcontrol.c
86440 +++ b/mm/memcontrol.c
86441 @@ -2772,6 +2772,8 @@ done:
86442 return 0;
86443 nomem:
86444 *ptr = NULL;
86445 + if (gfp_mask & __GFP_NOFAIL)
86446 + return 0;
86447 return -ENOMEM;
86448 bypass:
86449 *ptr = root_mem_cgroup;
86450 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
86451 index 2c13aa7..64cbc3f 100644
86452 --- a/mm/memory-failure.c
86453 +++ b/mm/memory-failure.c
86454 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
86455
86456 int sysctl_memory_failure_recovery __read_mostly = 1;
86457
86458 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86459 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
86460
86461 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
86462
86463 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
86464 pfn, t->comm, t->pid);
86465 si.si_signo = SIGBUS;
86466 si.si_errno = 0;
86467 - si.si_addr = (void *)addr;
86468 + si.si_addr = (void __user *)addr;
86469 #ifdef __ARCH_SI_TRAPNO
86470 si.si_trapno = trapno;
86471 #endif
86472 @@ -760,7 +760,7 @@ static struct page_state {
86473 unsigned long res;
86474 char *msg;
86475 int (*action)(struct page *p, unsigned long pfn);
86476 -} error_states[] = {
86477 +} __do_const error_states[] = {
86478 { reserved, reserved, "reserved kernel", me_kernel },
86479 /*
86480 * free pages are specially detected outside this table:
86481 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86482 nr_pages = 1 << compound_order(hpage);
86483 else /* normal page or thp */
86484 nr_pages = 1;
86485 - atomic_long_add(nr_pages, &num_poisoned_pages);
86486 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
86487
86488 /*
86489 * We need/can do nothing about count=0 pages.
86490 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86491 if (!PageHWPoison(hpage)
86492 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
86493 || (p != hpage && TestSetPageHWPoison(hpage))) {
86494 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86495 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86496 return 0;
86497 }
86498 set_page_hwpoison_huge_page(hpage);
86499 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
86500 }
86501 if (hwpoison_filter(p)) {
86502 if (TestClearPageHWPoison(p))
86503 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86504 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86505 unlock_page(hpage);
86506 put_page(hpage);
86507 return 0;
86508 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
86509 return 0;
86510 }
86511 if (TestClearPageHWPoison(p))
86512 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86513 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86514 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
86515 return 0;
86516 }
86517 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
86518 */
86519 if (TestClearPageHWPoison(page)) {
86520 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
86521 - atomic_long_sub(nr_pages, &num_poisoned_pages);
86522 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
86523 freeit = 1;
86524 if (PageHuge(page))
86525 clear_page_hwpoison_huge_page(page);
86526 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
86527 } else {
86528 set_page_hwpoison_huge_page(hpage);
86529 dequeue_hwpoisoned_huge_page(hpage);
86530 - atomic_long_add(1 << compound_trans_order(hpage),
86531 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86532 &num_poisoned_pages);
86533 }
86534 return ret;
86535 @@ -1551,11 +1551,11 @@ int soft_offline_page(struct page *page, int flags)
86536 if (PageHuge(page)) {
86537 set_page_hwpoison_huge_page(hpage);
86538 dequeue_hwpoisoned_huge_page(hpage);
86539 - atomic_long_add(1 << compound_trans_order(hpage),
86540 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
86541 &num_poisoned_pages);
86542 } else {
86543 SetPageHWPoison(page);
86544 - atomic_long_inc(&num_poisoned_pages);
86545 + atomic_long_inc_unchecked(&num_poisoned_pages);
86546 }
86547 }
86548 unset_migratetype_isolate(page, MIGRATE_MOVABLE);
86549 @@ -1595,7 +1595,7 @@ static int __soft_offline_page(struct page *page, int flags)
86550 put_page(page);
86551 pr_info("soft_offline: %#lx: invalidated\n", pfn);
86552 SetPageHWPoison(page);
86553 - atomic_long_inc(&num_poisoned_pages);
86554 + atomic_long_inc_unchecked(&num_poisoned_pages);
86555 return 0;
86556 }
86557
86558 @@ -1640,7 +1640,7 @@ static int __soft_offline_page(struct page *page, int flags)
86559 if (!is_free_buddy_page(page))
86560 pr_info("soft offline: %#lx: page leaked\n",
86561 pfn);
86562 - atomic_long_inc(&num_poisoned_pages);
86563 + atomic_long_inc_unchecked(&num_poisoned_pages);
86564 }
86565 } else {
86566 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
86567 diff --git a/mm/memory.c b/mm/memory.c
86568 index af84bc0..2ed0816 100644
86569 --- a/mm/memory.c
86570 +++ b/mm/memory.c
86571 @@ -426,6 +426,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86572 free_pte_range(tlb, pmd, addr);
86573 } while (pmd++, addr = next, addr != end);
86574
86575 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
86576 start &= PUD_MASK;
86577 if (start < floor)
86578 return;
86579 @@ -440,6 +441,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
86580 pmd = pmd_offset(pud, start);
86581 pud_clear(pud);
86582 pmd_free_tlb(tlb, pmd, start);
86583 +#endif
86584 +
86585 }
86586
86587 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86588 @@ -459,6 +462,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86589 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
86590 } while (pud++, addr = next, addr != end);
86591
86592 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
86593 start &= PGDIR_MASK;
86594 if (start < floor)
86595 return;
86596 @@ -473,6 +477,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
86597 pud = pud_offset(pgd, start);
86598 pgd_clear(pgd);
86599 pud_free_tlb(tlb, pud, start);
86600 +#endif
86601 +
86602 }
86603
86604 /*
86605 @@ -1645,12 +1651,6 @@ no_page_table:
86606 return page;
86607 }
86608
86609 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
86610 -{
86611 - return stack_guard_page_start(vma, addr) ||
86612 - stack_guard_page_end(vma, addr+PAGE_SIZE);
86613 -}
86614 -
86615 /**
86616 * __get_user_pages() - pin user pages in memory
86617 * @tsk: task_struct of target task
86618 @@ -1737,10 +1737,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86619
86620 i = 0;
86621
86622 - do {
86623 + while (nr_pages) {
86624 struct vm_area_struct *vma;
86625
86626 - vma = find_extend_vma(mm, start);
86627 + vma = find_vma(mm, start);
86628 if (!vma && in_gate_area(mm, start)) {
86629 unsigned long pg = start & PAGE_MASK;
86630 pgd_t *pgd;
86631 @@ -1789,7 +1789,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86632 goto next_page;
86633 }
86634
86635 - if (!vma ||
86636 + if (!vma || start < vma->vm_start ||
86637 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
86638 !(vm_flags & vma->vm_flags))
86639 return i ? : -EFAULT;
86640 @@ -1818,11 +1818,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
86641 int ret;
86642 unsigned int fault_flags = 0;
86643
86644 - /* For mlock, just skip the stack guard page. */
86645 - if (foll_flags & FOLL_MLOCK) {
86646 - if (stack_guard_page(vma, start))
86647 - goto next_page;
86648 - }
86649 if (foll_flags & FOLL_WRITE)
86650 fault_flags |= FAULT_FLAG_WRITE;
86651 if (nonblocking)
86652 @@ -1902,7 +1897,7 @@ next_page:
86653 start += page_increm * PAGE_SIZE;
86654 nr_pages -= page_increm;
86655 } while (nr_pages && start < vma->vm_end);
86656 - } while (nr_pages);
86657 + }
86658 return i;
86659 }
86660 EXPORT_SYMBOL(__get_user_pages);
86661 @@ -2109,6 +2104,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
86662 page_add_file_rmap(page);
86663 set_pte_at(mm, addr, pte, mk_pte(page, prot));
86664
86665 +#ifdef CONFIG_PAX_SEGMEXEC
86666 + pax_mirror_file_pte(vma, addr, page, ptl);
86667 +#endif
86668 +
86669 retval = 0;
86670 pte_unmap_unlock(pte, ptl);
86671 return retval;
86672 @@ -2153,9 +2152,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
86673 if (!page_count(page))
86674 return -EINVAL;
86675 if (!(vma->vm_flags & VM_MIXEDMAP)) {
86676 +
86677 +#ifdef CONFIG_PAX_SEGMEXEC
86678 + struct vm_area_struct *vma_m;
86679 +#endif
86680 +
86681 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
86682 BUG_ON(vma->vm_flags & VM_PFNMAP);
86683 vma->vm_flags |= VM_MIXEDMAP;
86684 +
86685 +#ifdef CONFIG_PAX_SEGMEXEC
86686 + vma_m = pax_find_mirror_vma(vma);
86687 + if (vma_m)
86688 + vma_m->vm_flags |= VM_MIXEDMAP;
86689 +#endif
86690 +
86691 }
86692 return insert_page(vma, addr, page, vma->vm_page_prot);
86693 }
86694 @@ -2238,6 +2249,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
86695 unsigned long pfn)
86696 {
86697 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
86698 + BUG_ON(vma->vm_mirror);
86699
86700 if (addr < vma->vm_start || addr >= vma->vm_end)
86701 return -EFAULT;
86702 @@ -2485,7 +2497,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
86703
86704 BUG_ON(pud_huge(*pud));
86705
86706 - pmd = pmd_alloc(mm, pud, addr);
86707 + pmd = (mm == &init_mm) ?
86708 + pmd_alloc_kernel(mm, pud, addr) :
86709 + pmd_alloc(mm, pud, addr);
86710 if (!pmd)
86711 return -ENOMEM;
86712 do {
86713 @@ -2505,7 +2519,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
86714 unsigned long next;
86715 int err;
86716
86717 - pud = pud_alloc(mm, pgd, addr);
86718 + pud = (mm == &init_mm) ?
86719 + pud_alloc_kernel(mm, pgd, addr) :
86720 + pud_alloc(mm, pgd, addr);
86721 if (!pud)
86722 return -ENOMEM;
86723 do {
86724 @@ -2593,6 +2609,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
86725 copy_user_highpage(dst, src, va, vma);
86726 }
86727
86728 +#ifdef CONFIG_PAX_SEGMEXEC
86729 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
86730 +{
86731 + struct mm_struct *mm = vma->vm_mm;
86732 + spinlock_t *ptl;
86733 + pte_t *pte, entry;
86734 +
86735 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
86736 + entry = *pte;
86737 + if (!pte_present(entry)) {
86738 + if (!pte_none(entry)) {
86739 + BUG_ON(pte_file(entry));
86740 + free_swap_and_cache(pte_to_swp_entry(entry));
86741 + pte_clear_not_present_full(mm, address, pte, 0);
86742 + }
86743 + } else {
86744 + struct page *page;
86745 +
86746 + flush_cache_page(vma, address, pte_pfn(entry));
86747 + entry = ptep_clear_flush(vma, address, pte);
86748 + BUG_ON(pte_dirty(entry));
86749 + page = vm_normal_page(vma, address, entry);
86750 + if (page) {
86751 + update_hiwater_rss(mm);
86752 + if (PageAnon(page))
86753 + dec_mm_counter_fast(mm, MM_ANONPAGES);
86754 + else
86755 + dec_mm_counter_fast(mm, MM_FILEPAGES);
86756 + page_remove_rmap(page);
86757 + page_cache_release(page);
86758 + }
86759 + }
86760 + pte_unmap_unlock(pte, ptl);
86761 +}
86762 +
86763 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
86764 + *
86765 + * the ptl of the lower mapped page is held on entry and is not released on exit
86766 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
86767 + */
86768 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86769 +{
86770 + struct mm_struct *mm = vma->vm_mm;
86771 + unsigned long address_m;
86772 + spinlock_t *ptl_m;
86773 + struct vm_area_struct *vma_m;
86774 + pmd_t *pmd_m;
86775 + pte_t *pte_m, entry_m;
86776 +
86777 + BUG_ON(!page_m || !PageAnon(page_m));
86778 +
86779 + vma_m = pax_find_mirror_vma(vma);
86780 + if (!vma_m)
86781 + return;
86782 +
86783 + BUG_ON(!PageLocked(page_m));
86784 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86785 + address_m = address + SEGMEXEC_TASK_SIZE;
86786 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86787 + pte_m = pte_offset_map(pmd_m, address_m);
86788 + ptl_m = pte_lockptr(mm, pmd_m);
86789 + if (ptl != ptl_m) {
86790 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86791 + if (!pte_none(*pte_m))
86792 + goto out;
86793 + }
86794 +
86795 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86796 + page_cache_get(page_m);
86797 + page_add_anon_rmap(page_m, vma_m, address_m);
86798 + inc_mm_counter_fast(mm, MM_ANONPAGES);
86799 + set_pte_at(mm, address_m, pte_m, entry_m);
86800 + update_mmu_cache(vma_m, address_m, pte_m);
86801 +out:
86802 + if (ptl != ptl_m)
86803 + spin_unlock(ptl_m);
86804 + pte_unmap(pte_m);
86805 + unlock_page(page_m);
86806 +}
86807 +
86808 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
86809 +{
86810 + struct mm_struct *mm = vma->vm_mm;
86811 + unsigned long address_m;
86812 + spinlock_t *ptl_m;
86813 + struct vm_area_struct *vma_m;
86814 + pmd_t *pmd_m;
86815 + pte_t *pte_m, entry_m;
86816 +
86817 + BUG_ON(!page_m || PageAnon(page_m));
86818 +
86819 + vma_m = pax_find_mirror_vma(vma);
86820 + if (!vma_m)
86821 + return;
86822 +
86823 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86824 + address_m = address + SEGMEXEC_TASK_SIZE;
86825 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86826 + pte_m = pte_offset_map(pmd_m, address_m);
86827 + ptl_m = pte_lockptr(mm, pmd_m);
86828 + if (ptl != ptl_m) {
86829 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86830 + if (!pte_none(*pte_m))
86831 + goto out;
86832 + }
86833 +
86834 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
86835 + page_cache_get(page_m);
86836 + page_add_file_rmap(page_m);
86837 + inc_mm_counter_fast(mm, MM_FILEPAGES);
86838 + set_pte_at(mm, address_m, pte_m, entry_m);
86839 + update_mmu_cache(vma_m, address_m, pte_m);
86840 +out:
86841 + if (ptl != ptl_m)
86842 + spin_unlock(ptl_m);
86843 + pte_unmap(pte_m);
86844 +}
86845 +
86846 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
86847 +{
86848 + struct mm_struct *mm = vma->vm_mm;
86849 + unsigned long address_m;
86850 + spinlock_t *ptl_m;
86851 + struct vm_area_struct *vma_m;
86852 + pmd_t *pmd_m;
86853 + pte_t *pte_m, entry_m;
86854 +
86855 + vma_m = pax_find_mirror_vma(vma);
86856 + if (!vma_m)
86857 + return;
86858 +
86859 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
86860 + address_m = address + SEGMEXEC_TASK_SIZE;
86861 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
86862 + pte_m = pte_offset_map(pmd_m, address_m);
86863 + ptl_m = pte_lockptr(mm, pmd_m);
86864 + if (ptl != ptl_m) {
86865 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
86866 + if (!pte_none(*pte_m))
86867 + goto out;
86868 + }
86869 +
86870 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
86871 + set_pte_at(mm, address_m, pte_m, entry_m);
86872 +out:
86873 + if (ptl != ptl_m)
86874 + spin_unlock(ptl_m);
86875 + pte_unmap(pte_m);
86876 +}
86877 +
86878 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
86879 +{
86880 + struct page *page_m;
86881 + pte_t entry;
86882 +
86883 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
86884 + goto out;
86885 +
86886 + entry = *pte;
86887 + page_m = vm_normal_page(vma, address, entry);
86888 + if (!page_m)
86889 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
86890 + else if (PageAnon(page_m)) {
86891 + if (pax_find_mirror_vma(vma)) {
86892 + pte_unmap_unlock(pte, ptl);
86893 + lock_page(page_m);
86894 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
86895 + if (pte_same(entry, *pte))
86896 + pax_mirror_anon_pte(vma, address, page_m, ptl);
86897 + else
86898 + unlock_page(page_m);
86899 + }
86900 + } else
86901 + pax_mirror_file_pte(vma, address, page_m, ptl);
86902 +
86903 +out:
86904 + pte_unmap_unlock(pte, ptl);
86905 +}
86906 +#endif
86907 +
86908 /*
86909 * This routine handles present pages, when users try to write
86910 * to a shared page. It is done by copying the page to a new address
86911 @@ -2809,6 +3005,12 @@ gotten:
86912 */
86913 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
86914 if (likely(pte_same(*page_table, orig_pte))) {
86915 +
86916 +#ifdef CONFIG_PAX_SEGMEXEC
86917 + if (pax_find_mirror_vma(vma))
86918 + BUG_ON(!trylock_page(new_page));
86919 +#endif
86920 +
86921 if (old_page) {
86922 if (!PageAnon(old_page)) {
86923 dec_mm_counter_fast(mm, MM_FILEPAGES);
86924 @@ -2860,6 +3062,10 @@ gotten:
86925 page_remove_rmap(old_page);
86926 }
86927
86928 +#ifdef CONFIG_PAX_SEGMEXEC
86929 + pax_mirror_anon_pte(vma, address, new_page, ptl);
86930 +#endif
86931 +
86932 /* Free the old page.. */
86933 new_page = old_page;
86934 ret |= VM_FAULT_WRITE;
86935 @@ -3137,6 +3343,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86936 swap_free(entry);
86937 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
86938 try_to_free_swap(page);
86939 +
86940 +#ifdef CONFIG_PAX_SEGMEXEC
86941 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
86942 +#endif
86943 +
86944 unlock_page(page);
86945 if (page != swapcache) {
86946 /*
86947 @@ -3160,6 +3371,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
86948
86949 /* No need to invalidate - it was non-present before */
86950 update_mmu_cache(vma, address, page_table);
86951 +
86952 +#ifdef CONFIG_PAX_SEGMEXEC
86953 + pax_mirror_anon_pte(vma, address, page, ptl);
86954 +#endif
86955 +
86956 unlock:
86957 pte_unmap_unlock(page_table, ptl);
86958 out:
86959 @@ -3179,40 +3395,6 @@ out_release:
86960 }
86961
86962 /*
86963 - * This is like a special single-page "expand_{down|up}wards()",
86964 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
86965 - * doesn't hit another vma.
86966 - */
86967 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
86968 -{
86969 - address &= PAGE_MASK;
86970 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
86971 - struct vm_area_struct *prev = vma->vm_prev;
86972 -
86973 - /*
86974 - * Is there a mapping abutting this one below?
86975 - *
86976 - * That's only ok if it's the same stack mapping
86977 - * that has gotten split..
86978 - */
86979 - if (prev && prev->vm_end == address)
86980 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
86981 -
86982 - expand_downwards(vma, address - PAGE_SIZE);
86983 - }
86984 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
86985 - struct vm_area_struct *next = vma->vm_next;
86986 -
86987 - /* As VM_GROWSDOWN but s/below/above/ */
86988 - if (next && next->vm_start == address + PAGE_SIZE)
86989 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
86990 -
86991 - expand_upwards(vma, address + PAGE_SIZE);
86992 - }
86993 - return 0;
86994 -}
86995 -
86996 -/*
86997 * We enter with non-exclusive mmap_sem (to exclude vma changes,
86998 * but allow concurrent faults), and pte mapped but not yet locked.
86999 * We return with mmap_sem still held, but pte unmapped and unlocked.
87000 @@ -3221,27 +3403,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87001 unsigned long address, pte_t *page_table, pmd_t *pmd,
87002 unsigned int flags)
87003 {
87004 - struct page *page;
87005 + struct page *page = NULL;
87006 spinlock_t *ptl;
87007 pte_t entry;
87008
87009 - pte_unmap(page_table);
87010 -
87011 - /* Check if we need to add a guard page to the stack */
87012 - if (check_stack_guard_page(vma, address) < 0)
87013 - return VM_FAULT_SIGBUS;
87014 -
87015 - /* Use the zero-page for reads */
87016 if (!(flags & FAULT_FLAG_WRITE)) {
87017 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
87018 vma->vm_page_prot));
87019 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
87020 + ptl = pte_lockptr(mm, pmd);
87021 + spin_lock(ptl);
87022 if (!pte_none(*page_table))
87023 goto unlock;
87024 goto setpte;
87025 }
87026
87027 /* Allocate our own private page. */
87028 + pte_unmap(page_table);
87029 +
87030 if (unlikely(anon_vma_prepare(vma)))
87031 goto oom;
87032 page = alloc_zeroed_user_highpage_movable(vma, address);
87033 @@ -3265,6 +3443,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
87034 if (!pte_none(*page_table))
87035 goto release;
87036
87037 +#ifdef CONFIG_PAX_SEGMEXEC
87038 + if (pax_find_mirror_vma(vma))
87039 + BUG_ON(!trylock_page(page));
87040 +#endif
87041 +
87042 inc_mm_counter_fast(mm, MM_ANONPAGES);
87043 page_add_new_anon_rmap(page, vma, address);
87044 setpte:
87045 @@ -3272,6 +3455,12 @@ setpte:
87046
87047 /* No need to invalidate - it was non-present before */
87048 update_mmu_cache(vma, address, page_table);
87049 +
87050 +#ifdef CONFIG_PAX_SEGMEXEC
87051 + if (page)
87052 + pax_mirror_anon_pte(vma, address, page, ptl);
87053 +#endif
87054 +
87055 unlock:
87056 pte_unmap_unlock(page_table, ptl);
87057 return 0;
87058 @@ -3415,6 +3604,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87059 */
87060 /* Only go through if we didn't race with anybody else... */
87061 if (likely(pte_same(*page_table, orig_pte))) {
87062 +
87063 +#ifdef CONFIG_PAX_SEGMEXEC
87064 + if (anon && pax_find_mirror_vma(vma))
87065 + BUG_ON(!trylock_page(page));
87066 +#endif
87067 +
87068 flush_icache_page(vma, page);
87069 entry = mk_pte(page, vma->vm_page_prot);
87070 if (flags & FAULT_FLAG_WRITE)
87071 @@ -3436,6 +3631,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87072
87073 /* no need to invalidate: a not-present page won't be cached */
87074 update_mmu_cache(vma, address, page_table);
87075 +
87076 +#ifdef CONFIG_PAX_SEGMEXEC
87077 + if (anon)
87078 + pax_mirror_anon_pte(vma, address, page, ptl);
87079 + else
87080 + pax_mirror_file_pte(vma, address, page, ptl);
87081 +#endif
87082 +
87083 } else {
87084 if (cow_page)
87085 mem_cgroup_uncharge_page(cow_page);
87086 @@ -3757,6 +3960,12 @@ int handle_pte_fault(struct mm_struct *mm,
87087 if (flags & FAULT_FLAG_WRITE)
87088 flush_tlb_fix_spurious_fault(vma, address);
87089 }
87090 +
87091 +#ifdef CONFIG_PAX_SEGMEXEC
87092 + pax_mirror_pte(vma, address, pte, pmd, ptl);
87093 + return 0;
87094 +#endif
87095 +
87096 unlock:
87097 pte_unmap_unlock(pte, ptl);
87098 return 0;
87099 @@ -3773,6 +3982,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87100 pmd_t *pmd;
87101 pte_t *pte;
87102
87103 +#ifdef CONFIG_PAX_SEGMEXEC
87104 + struct vm_area_struct *vma_m;
87105 +#endif
87106 +
87107 __set_current_state(TASK_RUNNING);
87108
87109 count_vm_event(PGFAULT);
87110 @@ -3784,6 +3997,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
87111 if (unlikely(is_vm_hugetlb_page(vma)))
87112 return hugetlb_fault(mm, vma, address, flags);
87113
87114 +#ifdef CONFIG_PAX_SEGMEXEC
87115 + vma_m = pax_find_mirror_vma(vma);
87116 + if (vma_m) {
87117 + unsigned long address_m;
87118 + pgd_t *pgd_m;
87119 + pud_t *pud_m;
87120 + pmd_t *pmd_m;
87121 +
87122 + if (vma->vm_start > vma_m->vm_start) {
87123 + address_m = address;
87124 + address -= SEGMEXEC_TASK_SIZE;
87125 + vma = vma_m;
87126 + } else
87127 + address_m = address + SEGMEXEC_TASK_SIZE;
87128 +
87129 + pgd_m = pgd_offset(mm, address_m);
87130 + pud_m = pud_alloc(mm, pgd_m, address_m);
87131 + if (!pud_m)
87132 + return VM_FAULT_OOM;
87133 + pmd_m = pmd_alloc(mm, pud_m, address_m);
87134 + if (!pmd_m)
87135 + return VM_FAULT_OOM;
87136 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
87137 + return VM_FAULT_OOM;
87138 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
87139 + }
87140 +#endif
87141 +
87142 retry:
87143 pgd = pgd_offset(mm, address);
87144 pud = pud_alloc(mm, pgd, address);
87145 @@ -3882,6 +4123,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87146 spin_unlock(&mm->page_table_lock);
87147 return 0;
87148 }
87149 +
87150 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
87151 +{
87152 + pud_t *new = pud_alloc_one(mm, address);
87153 + if (!new)
87154 + return -ENOMEM;
87155 +
87156 + smp_wmb(); /* See comment in __pte_alloc */
87157 +
87158 + spin_lock(&mm->page_table_lock);
87159 + if (pgd_present(*pgd)) /* Another has populated it */
87160 + pud_free(mm, new);
87161 + else
87162 + pgd_populate_kernel(mm, pgd, new);
87163 + spin_unlock(&mm->page_table_lock);
87164 + return 0;
87165 +}
87166 #endif /* __PAGETABLE_PUD_FOLDED */
87167
87168 #ifndef __PAGETABLE_PMD_FOLDED
87169 @@ -3912,6 +4170,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
87170 spin_unlock(&mm->page_table_lock);
87171 return 0;
87172 }
87173 +
87174 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
87175 +{
87176 + pmd_t *new = pmd_alloc_one(mm, address);
87177 + if (!new)
87178 + return -ENOMEM;
87179 +
87180 + smp_wmb(); /* See comment in __pte_alloc */
87181 +
87182 + spin_lock(&mm->page_table_lock);
87183 +#ifndef __ARCH_HAS_4LEVEL_HACK
87184 + if (pud_present(*pud)) /* Another has populated it */
87185 + pmd_free(mm, new);
87186 + else
87187 + pud_populate_kernel(mm, pud, new);
87188 +#else
87189 + if (pgd_present(*pud)) /* Another has populated it */
87190 + pmd_free(mm, new);
87191 + else
87192 + pgd_populate_kernel(mm, pud, new);
87193 +#endif /* __ARCH_HAS_4LEVEL_HACK */
87194 + spin_unlock(&mm->page_table_lock);
87195 + return 0;
87196 +}
87197 #endif /* __PAGETABLE_PMD_FOLDED */
87198
87199 #if !defined(__HAVE_ARCH_GATE_AREA)
87200 @@ -3925,7 +4207,7 @@ static int __init gate_vma_init(void)
87201 gate_vma.vm_start = FIXADDR_USER_START;
87202 gate_vma.vm_end = FIXADDR_USER_END;
87203 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
87204 - gate_vma.vm_page_prot = __P101;
87205 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
87206
87207 return 0;
87208 }
87209 @@ -4059,8 +4341,8 @@ out:
87210 return ret;
87211 }
87212
87213 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87214 - void *buf, int len, int write)
87215 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87216 + void *buf, size_t len, int write)
87217 {
87218 resource_size_t phys_addr;
87219 unsigned long prot = 0;
87220 @@ -4085,8 +4367,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
87221 * Access another process' address space as given in mm. If non-NULL, use the
87222 * given task for page fault accounting.
87223 */
87224 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87225 - unsigned long addr, void *buf, int len, int write)
87226 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87227 + unsigned long addr, void *buf, size_t len, int write)
87228 {
87229 struct vm_area_struct *vma;
87230 void *old_buf = buf;
87231 @@ -4094,7 +4376,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87232 down_read(&mm->mmap_sem);
87233 /* ignore errors, just check how much was successfully transferred */
87234 while (len) {
87235 - int bytes, ret, offset;
87236 + ssize_t bytes, ret, offset;
87237 void *maddr;
87238 struct page *page = NULL;
87239
87240 @@ -4153,8 +4435,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87241 *
87242 * The caller must hold a reference on @mm.
87243 */
87244 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87245 - void *buf, int len, int write)
87246 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87247 + void *buf, size_t len, int write)
87248 {
87249 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87250 }
87251 @@ -4164,11 +4446,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87252 * Source/target buffer must be kernel space,
87253 * Do not walk the page table directly, use get_user_pages
87254 */
87255 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
87256 - void *buf, int len, int write)
87257 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
87258 + void *buf, size_t len, int write)
87259 {
87260 struct mm_struct *mm;
87261 - int ret;
87262 + ssize_t ret;
87263
87264 mm = get_task_mm(tsk);
87265 if (!mm)
87266 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
87267 index 4baf12e..5497066 100644
87268 --- a/mm/mempolicy.c
87269 +++ b/mm/mempolicy.c
87270 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87271 unsigned long vmstart;
87272 unsigned long vmend;
87273
87274 +#ifdef CONFIG_PAX_SEGMEXEC
87275 + struct vm_area_struct *vma_m;
87276 +#endif
87277 +
87278 vma = find_vma(mm, start);
87279 if (!vma || vma->vm_start > start)
87280 return -EFAULT;
87281 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
87282 err = vma_replace_policy(vma, new_pol);
87283 if (err)
87284 goto out;
87285 +
87286 +#ifdef CONFIG_PAX_SEGMEXEC
87287 + vma_m = pax_find_mirror_vma(vma);
87288 + if (vma_m) {
87289 + err = vma_replace_policy(vma_m, new_pol);
87290 + if (err)
87291 + goto out;
87292 + }
87293 +#endif
87294 +
87295 }
87296
87297 out:
87298 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
87299
87300 if (end < start)
87301 return -EINVAL;
87302 +
87303 +#ifdef CONFIG_PAX_SEGMEXEC
87304 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
87305 + if (end > SEGMEXEC_TASK_SIZE)
87306 + return -EINVAL;
87307 + } else
87308 +#endif
87309 +
87310 + if (end > TASK_SIZE)
87311 + return -EINVAL;
87312 +
87313 if (end == start)
87314 return 0;
87315
87316 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87317 */
87318 tcred = __task_cred(task);
87319 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87320 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87321 - !capable(CAP_SYS_NICE)) {
87322 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87323 rcu_read_unlock();
87324 err = -EPERM;
87325 goto out_put;
87326 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
87327 goto out;
87328 }
87329
87330 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
87331 + if (mm != current->mm &&
87332 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
87333 + mmput(mm);
87334 + err = -EPERM;
87335 + goto out;
87336 + }
87337 +#endif
87338 +
87339 err = do_migrate_pages(mm, old, new,
87340 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
87341
87342 diff --git a/mm/migrate.c b/mm/migrate.c
87343 index 25ca7ca..abe1836 100644
87344 --- a/mm/migrate.c
87345 +++ b/mm/migrate.c
87346 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
87347 */
87348 tcred = __task_cred(task);
87349 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
87350 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
87351 - !capable(CAP_SYS_NICE)) {
87352 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
87353 rcu_read_unlock();
87354 err = -EPERM;
87355 goto out;
87356 diff --git a/mm/mlock.c b/mm/mlock.c
87357 index 79b7cf7..37472bf 100644
87358 --- a/mm/mlock.c
87359 +++ b/mm/mlock.c
87360 @@ -13,6 +13,7 @@
87361 #include <linux/pagemap.h>
87362 #include <linux/mempolicy.h>
87363 #include <linux/syscalls.h>
87364 +#include <linux/security.h>
87365 #include <linux/sched.h>
87366 #include <linux/export.h>
87367 #include <linux/rmap.h>
87368 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
87369 {
87370 unsigned long nstart, end, tmp;
87371 struct vm_area_struct * vma, * prev;
87372 - int error;
87373 + int error = 0;
87374
87375 VM_BUG_ON(start & ~PAGE_MASK);
87376 VM_BUG_ON(len != PAGE_ALIGN(len));
87377 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
87378 return -EINVAL;
87379 if (end == start)
87380 return 0;
87381 + if (end > TASK_SIZE)
87382 + return -EINVAL;
87383 +
87384 vma = find_vma(current->mm, start);
87385 if (!vma || vma->vm_start > start)
87386 return -ENOMEM;
87387 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
87388 for (nstart = start ; ; ) {
87389 vm_flags_t newflags;
87390
87391 +#ifdef CONFIG_PAX_SEGMEXEC
87392 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87393 + break;
87394 +#endif
87395 +
87396 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
87397
87398 newflags = vma->vm_flags & ~VM_LOCKED;
87399 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
87400 lock_limit >>= PAGE_SHIFT;
87401
87402 /* check against resource limits */
87403 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
87404 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
87405 error = do_mlock(start, len, 1);
87406 up_write(&current->mm->mmap_sem);
87407 @@ -500,12 +510,18 @@ static int do_mlockall(int flags)
87408 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
87409 vm_flags_t newflags;
87410
87411 +#ifdef CONFIG_PAX_SEGMEXEC
87412 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
87413 + break;
87414 +#endif
87415 +
87416 newflags = vma->vm_flags & ~VM_LOCKED;
87417 if (flags & MCL_CURRENT)
87418 newflags |= VM_LOCKED;
87419
87420 /* Ignore errors */
87421 mlock_fixup(vma, &prev, vma->vm_start, vma->vm_end, newflags);
87422 + cond_resched();
87423 }
87424 out:
87425 return 0;
87426 @@ -532,6 +548,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
87427 lock_limit >>= PAGE_SHIFT;
87428
87429 ret = -ENOMEM;
87430 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
87431 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
87432 capable(CAP_IPC_LOCK))
87433 ret = do_mlockall(flags);
87434 diff --git a/mm/mmap.c b/mm/mmap.c
87435 index f9c97d1..3468d3b 100644
87436 --- a/mm/mmap.c
87437 +++ b/mm/mmap.c
87438 @@ -36,6 +36,7 @@
87439 #include <linux/sched/sysctl.h>
87440 #include <linux/notifier.h>
87441 #include <linux/memory.h>
87442 +#include <linux/random.h>
87443
87444 #include <asm/uaccess.h>
87445 #include <asm/cacheflush.h>
87446 @@ -52,6 +53,16 @@
87447 #define arch_rebalance_pgtables(addr, len) (addr)
87448 #endif
87449
87450 +static inline void verify_mm_writelocked(struct mm_struct *mm)
87451 +{
87452 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
87453 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
87454 + up_read(&mm->mmap_sem);
87455 + BUG();
87456 + }
87457 +#endif
87458 +}
87459 +
87460 static void unmap_region(struct mm_struct *mm,
87461 struct vm_area_struct *vma, struct vm_area_struct *prev,
87462 unsigned long start, unsigned long end);
87463 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
87464 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
87465 *
87466 */
87467 -pgprot_t protection_map[16] = {
87468 +pgprot_t protection_map[16] __read_only = {
87469 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
87470 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
87471 };
87472
87473 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
87474 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
87475 {
87476 - return __pgprot(pgprot_val(protection_map[vm_flags &
87477 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
87478 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
87479 pgprot_val(arch_vm_get_page_prot(vm_flags)));
87480 +
87481 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87482 + if (!(__supported_pte_mask & _PAGE_NX) &&
87483 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
87484 + (vm_flags & (VM_READ | VM_WRITE)))
87485 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
87486 +#endif
87487 +
87488 + return prot;
87489 }
87490 EXPORT_SYMBOL(vm_get_page_prot);
87491
87492 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
87493 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
87494 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87495 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87496 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
87497 /*
87498 * Make sure vm_committed_as in one cacheline and not cacheline shared with
87499 * other variables. It can be updated by several CPUs frequently.
87500 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
87501 struct vm_area_struct *next = vma->vm_next;
87502
87503 might_sleep();
87504 + BUG_ON(vma->vm_mirror);
87505 if (vma->vm_ops && vma->vm_ops->close)
87506 vma->vm_ops->close(vma);
87507 if (vma->vm_file)
87508 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
87509 * not page aligned -Ram Gupta
87510 */
87511 rlim = rlimit(RLIMIT_DATA);
87512 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
87513 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
87514 (mm->end_data - mm->start_data) > rlim)
87515 goto out;
87516 @@ -933,6 +956,12 @@ static int
87517 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
87518 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87519 {
87520 +
87521 +#ifdef CONFIG_PAX_SEGMEXEC
87522 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
87523 + return 0;
87524 +#endif
87525 +
87526 if (is_mergeable_vma(vma, file, vm_flags) &&
87527 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87528 if (vma->vm_pgoff == vm_pgoff)
87529 @@ -952,6 +981,12 @@ static int
87530 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87531 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
87532 {
87533 +
87534 +#ifdef CONFIG_PAX_SEGMEXEC
87535 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
87536 + return 0;
87537 +#endif
87538 +
87539 if (is_mergeable_vma(vma, file, vm_flags) &&
87540 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
87541 pgoff_t vm_pglen;
87542 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
87543 struct vm_area_struct *vma_merge(struct mm_struct *mm,
87544 struct vm_area_struct *prev, unsigned long addr,
87545 unsigned long end, unsigned long vm_flags,
87546 - struct anon_vma *anon_vma, struct file *file,
87547 + struct anon_vma *anon_vma, struct file *file,
87548 pgoff_t pgoff, struct mempolicy *policy)
87549 {
87550 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
87551 struct vm_area_struct *area, *next;
87552 int err;
87553
87554 +#ifdef CONFIG_PAX_SEGMEXEC
87555 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
87556 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
87557 +
87558 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
87559 +#endif
87560 +
87561 /*
87562 * We later require that vma->vm_flags == vm_flags,
87563 * so this tests vma->vm_flags & VM_SPECIAL, too.
87564 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87565 if (next && next->vm_end == end) /* cases 6, 7, 8 */
87566 next = next->vm_next;
87567
87568 +#ifdef CONFIG_PAX_SEGMEXEC
87569 + if (prev)
87570 + prev_m = pax_find_mirror_vma(prev);
87571 + if (area)
87572 + area_m = pax_find_mirror_vma(area);
87573 + if (next)
87574 + next_m = pax_find_mirror_vma(next);
87575 +#endif
87576 +
87577 /*
87578 * Can it merge with the predecessor?
87579 */
87580 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87581 /* cases 1, 6 */
87582 err = vma_adjust(prev, prev->vm_start,
87583 next->vm_end, prev->vm_pgoff, NULL);
87584 - } else /* cases 2, 5, 7 */
87585 +
87586 +#ifdef CONFIG_PAX_SEGMEXEC
87587 + if (!err && prev_m)
87588 + err = vma_adjust(prev_m, prev_m->vm_start,
87589 + next_m->vm_end, prev_m->vm_pgoff, NULL);
87590 +#endif
87591 +
87592 + } else { /* cases 2, 5, 7 */
87593 err = vma_adjust(prev, prev->vm_start,
87594 end, prev->vm_pgoff, NULL);
87595 +
87596 +#ifdef CONFIG_PAX_SEGMEXEC
87597 + if (!err && prev_m)
87598 + err = vma_adjust(prev_m, prev_m->vm_start,
87599 + end_m, prev_m->vm_pgoff, NULL);
87600 +#endif
87601 +
87602 + }
87603 if (err)
87604 return NULL;
87605 khugepaged_enter_vma_merge(prev);
87606 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
87607 mpol_equal(policy, vma_policy(next)) &&
87608 can_vma_merge_before(next, vm_flags,
87609 anon_vma, file, pgoff+pglen)) {
87610 - if (prev && addr < prev->vm_end) /* case 4 */
87611 + if (prev && addr < prev->vm_end) { /* case 4 */
87612 err = vma_adjust(prev, prev->vm_start,
87613 addr, prev->vm_pgoff, NULL);
87614 - else /* cases 3, 8 */
87615 +
87616 +#ifdef CONFIG_PAX_SEGMEXEC
87617 + if (!err && prev_m)
87618 + err = vma_adjust(prev_m, prev_m->vm_start,
87619 + addr_m, prev_m->vm_pgoff, NULL);
87620 +#endif
87621 +
87622 + } else { /* cases 3, 8 */
87623 err = vma_adjust(area, addr, next->vm_end,
87624 next->vm_pgoff - pglen, NULL);
87625 +
87626 +#ifdef CONFIG_PAX_SEGMEXEC
87627 + if (!err && area_m)
87628 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
87629 + next_m->vm_pgoff - pglen, NULL);
87630 +#endif
87631 +
87632 + }
87633 if (err)
87634 return NULL;
87635 khugepaged_enter_vma_merge(area);
87636 @@ -1165,8 +1246,10 @@ none:
87637 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87638 struct file *file, long pages)
87639 {
87640 - const unsigned long stack_flags
87641 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
87642 +
87643 +#ifdef CONFIG_PAX_RANDMMAP
87644 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87645 +#endif
87646
87647 mm->total_vm += pages;
87648
87649 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
87650 mm->shared_vm += pages;
87651 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
87652 mm->exec_vm += pages;
87653 - } else if (flags & stack_flags)
87654 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
87655 mm->stack_vm += pages;
87656 }
87657 #endif /* CONFIG_PROC_FS */
87658 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87659 * (the exception is when the underlying filesystem is noexec
87660 * mounted, in which case we dont add PROT_EXEC.)
87661 */
87662 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87663 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87664 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
87665 prot |= PROT_EXEC;
87666
87667 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87668 /* Obtain the address to map to. we verify (or select) it and ensure
87669 * that it represents a valid section of the address space.
87670 */
87671 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
87672 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
87673 if (addr & ~PAGE_MASK)
87674 return addr;
87675
87676 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87677 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
87678 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
87679
87680 +#ifdef CONFIG_PAX_MPROTECT
87681 + if (mm->pax_flags & MF_PAX_MPROTECT) {
87682 +
87683 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
87684 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
87685 + mm->binfmt->handle_mmap)
87686 + mm->binfmt->handle_mmap(file);
87687 +#endif
87688 +
87689 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
87690 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
87691 + gr_log_rwxmmap(file);
87692 +
87693 +#ifdef CONFIG_PAX_EMUPLT
87694 + vm_flags &= ~VM_EXEC;
87695 +#else
87696 + return -EPERM;
87697 +#endif
87698 +
87699 + }
87700 +
87701 + if (!(vm_flags & VM_EXEC))
87702 + vm_flags &= ~VM_MAYEXEC;
87703 +#else
87704 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
87705 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
87706 +#endif
87707 + else
87708 + vm_flags &= ~VM_MAYWRITE;
87709 + }
87710 +#endif
87711 +
87712 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87713 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
87714 + vm_flags &= ~VM_PAGEEXEC;
87715 +#endif
87716 +
87717 if (flags & MAP_LOCKED)
87718 if (!can_do_mlock())
87719 return -EPERM;
87720 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87721 locked += mm->locked_vm;
87722 lock_limit = rlimit(RLIMIT_MEMLOCK);
87723 lock_limit >>= PAGE_SHIFT;
87724 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
87725 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
87726 return -EAGAIN;
87727 }
87728 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
87729 vm_flags |= VM_NORESERVE;
87730 }
87731
87732 + if (!gr_acl_handle_mmap(file, prot))
87733 + return -EACCES;
87734 +
87735 addr = mmap_region(file, addr, len, vm_flags, pgoff);
87736 if (!IS_ERR_VALUE(addr) &&
87737 ((vm_flags & VM_LOCKED) ||
87738 @@ -1434,7 +1558,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
87739 vm_flags_t vm_flags = vma->vm_flags;
87740
87741 /* If it was private or non-writable, the write bit is already clear */
87742 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
87743 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
87744 return 0;
87745
87746 /* The backer wishes to know when pages are first written to? */
87747 @@ -1482,7 +1606,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87748 unsigned long charged = 0;
87749 struct inode *inode = file ? file_inode(file) : NULL;
87750
87751 +#ifdef CONFIG_PAX_SEGMEXEC
87752 + struct vm_area_struct *vma_m = NULL;
87753 +#endif
87754 +
87755 + /*
87756 + * mm->mmap_sem is required to protect against another thread
87757 + * changing the mappings in case we sleep.
87758 + */
87759 + verify_mm_writelocked(mm);
87760 +
87761 /* Check against address space limit. */
87762 +
87763 +#ifdef CONFIG_PAX_RANDMMAP
87764 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
87765 +#endif
87766 +
87767 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
87768 unsigned long nr_pages;
87769
87770 @@ -1501,11 +1640,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
87771
87772 /* Clear old maps */
87773 error = -ENOMEM;
87774 -munmap_back:
87775 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
87776 if (do_munmap(mm, addr, len))
87777 return -ENOMEM;
87778 - goto munmap_back;
87779 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
87780 }
87781
87782 /*
87783 @@ -1536,6 +1674,16 @@ munmap_back:
87784 goto unacct_error;
87785 }
87786
87787 +#ifdef CONFIG_PAX_SEGMEXEC
87788 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
87789 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
87790 + if (!vma_m) {
87791 + error = -ENOMEM;
87792 + goto free_vma;
87793 + }
87794 + }
87795 +#endif
87796 +
87797 vma->vm_mm = mm;
87798 vma->vm_start = addr;
87799 vma->vm_end = addr + len;
87800 @@ -1560,6 +1708,13 @@ munmap_back:
87801 if (error)
87802 goto unmap_and_free_vma;
87803
87804 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
87805 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
87806 + vma->vm_flags |= VM_PAGEEXEC;
87807 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
87808 + }
87809 +#endif
87810 +
87811 /* Can addr have changed??
87812 *
87813 * Answer: Yes, several device drivers can do it in their
87814 @@ -1598,6 +1753,11 @@ munmap_back:
87815 vma_link(mm, vma, prev, rb_link, rb_parent);
87816 file = vma->vm_file;
87817
87818 +#ifdef CONFIG_PAX_SEGMEXEC
87819 + if (vma_m)
87820 + BUG_ON(pax_mirror_vma(vma_m, vma));
87821 +#endif
87822 +
87823 /* Once vma denies write, undo our temporary denial count */
87824 if (correct_wcount)
87825 atomic_inc(&inode->i_writecount);
87826 @@ -1605,6 +1765,7 @@ out:
87827 perf_event_mmap(vma);
87828
87829 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
87830 + track_exec_limit(mm, addr, addr + len, vm_flags);
87831 if (vm_flags & VM_LOCKED) {
87832 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
87833 vma == get_gate_vma(current->mm)))
87834 @@ -1628,6 +1789,12 @@ unmap_and_free_vma:
87835 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
87836 charged = 0;
87837 free_vma:
87838 +
87839 +#ifdef CONFIG_PAX_SEGMEXEC
87840 + if (vma_m)
87841 + kmem_cache_free(vm_area_cachep, vma_m);
87842 +#endif
87843 +
87844 kmem_cache_free(vm_area_cachep, vma);
87845 unacct_error:
87846 if (charged)
87847 @@ -1635,7 +1802,63 @@ unacct_error:
87848 return error;
87849 }
87850
87851 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87852 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
87853 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
87854 +{
87855 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
87856 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
87857 +
87858 + return 0;
87859 +}
87860 +#endif
87861 +
87862 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
87863 +{
87864 + if (!vma) {
87865 +#ifdef CONFIG_STACK_GROWSUP
87866 + if (addr > sysctl_heap_stack_gap)
87867 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
87868 + else
87869 + vma = find_vma(current->mm, 0);
87870 + if (vma && (vma->vm_flags & VM_GROWSUP))
87871 + return false;
87872 +#endif
87873 + return true;
87874 + }
87875 +
87876 + if (addr + len > vma->vm_start)
87877 + return false;
87878 +
87879 + if (vma->vm_flags & VM_GROWSDOWN)
87880 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
87881 +#ifdef CONFIG_STACK_GROWSUP
87882 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
87883 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
87884 +#endif
87885 + else if (offset)
87886 + return offset <= vma->vm_start - addr - len;
87887 +
87888 + return true;
87889 +}
87890 +
87891 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
87892 +{
87893 + if (vma->vm_start < len)
87894 + return -ENOMEM;
87895 +
87896 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
87897 + if (offset <= vma->vm_start - len)
87898 + return vma->vm_start - len - offset;
87899 + else
87900 + return -ENOMEM;
87901 + }
87902 +
87903 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
87904 + return vma->vm_start - len - sysctl_heap_stack_gap;
87905 + return -ENOMEM;
87906 +}
87907 +
87908 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
87909 {
87910 /*
87911 * We implement the search by looking for an rbtree node that
87912 @@ -1683,11 +1906,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
87913 }
87914 }
87915
87916 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
87917 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
87918 check_current:
87919 /* Check if current node has a suitable gap */
87920 if (gap_start > high_limit)
87921 return -ENOMEM;
87922 +
87923 + if (gap_end - gap_start > info->threadstack_offset)
87924 + gap_start += info->threadstack_offset;
87925 + else
87926 + gap_start = gap_end;
87927 +
87928 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87929 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87930 + gap_start += sysctl_heap_stack_gap;
87931 + else
87932 + gap_start = gap_end;
87933 + }
87934 + if (vma->vm_flags & VM_GROWSDOWN) {
87935 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87936 + gap_end -= sysctl_heap_stack_gap;
87937 + else
87938 + gap_end = gap_start;
87939 + }
87940 if (gap_end >= low_limit && gap_end - gap_start >= length)
87941 goto found;
87942
87943 @@ -1737,7 +1978,7 @@ found:
87944 return gap_start;
87945 }
87946
87947 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
87948 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
87949 {
87950 struct mm_struct *mm = current->mm;
87951 struct vm_area_struct *vma;
87952 @@ -1791,6 +2032,24 @@ check_current:
87953 gap_end = vma->vm_start;
87954 if (gap_end < low_limit)
87955 return -ENOMEM;
87956 +
87957 + if (gap_end - gap_start > info->threadstack_offset)
87958 + gap_end -= info->threadstack_offset;
87959 + else
87960 + gap_end = gap_start;
87961 +
87962 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
87963 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87964 + gap_start += sysctl_heap_stack_gap;
87965 + else
87966 + gap_start = gap_end;
87967 + }
87968 + if (vma->vm_flags & VM_GROWSDOWN) {
87969 + if (gap_end - gap_start > sysctl_heap_stack_gap)
87970 + gap_end -= sysctl_heap_stack_gap;
87971 + else
87972 + gap_end = gap_start;
87973 + }
87974 if (gap_start <= high_limit && gap_end - gap_start >= length)
87975 goto found;
87976
87977 @@ -1854,6 +2113,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87978 struct mm_struct *mm = current->mm;
87979 struct vm_area_struct *vma;
87980 struct vm_unmapped_area_info info;
87981 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
87982
87983 if (len > TASK_SIZE)
87984 return -ENOMEM;
87985 @@ -1861,19 +2121,29 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
87986 if (flags & MAP_FIXED)
87987 return addr;
87988
87989 +#ifdef CONFIG_PAX_RANDMMAP
87990 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
87991 +#endif
87992 +
87993 if (addr) {
87994 addr = PAGE_ALIGN(addr);
87995 vma = find_vma(mm, addr);
87996 - if (TASK_SIZE - len >= addr &&
87997 - (!vma || addr + len <= vma->vm_start))
87998 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
87999 return addr;
88000 }
88001
88002 info.flags = 0;
88003 info.length = len;
88004 info.low_limit = TASK_UNMAPPED_BASE;
88005 +
88006 +#ifdef CONFIG_PAX_RANDMMAP
88007 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88008 + info.low_limit += mm->delta_mmap;
88009 +#endif
88010 +
88011 info.high_limit = TASK_SIZE;
88012 info.align_mask = 0;
88013 + info.threadstack_offset = offset;
88014 return vm_unmapped_area(&info);
88015 }
88016 #endif
88017 @@ -1892,6 +2162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88018 struct mm_struct *mm = current->mm;
88019 unsigned long addr = addr0;
88020 struct vm_unmapped_area_info info;
88021 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
88022
88023 /* requested length too big for entire address space */
88024 if (len > TASK_SIZE)
88025 @@ -1900,12 +2171,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88026 if (flags & MAP_FIXED)
88027 return addr;
88028
88029 +#ifdef CONFIG_PAX_RANDMMAP
88030 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
88031 +#endif
88032 +
88033 /* requesting a specific address */
88034 if (addr) {
88035 addr = PAGE_ALIGN(addr);
88036 vma = find_vma(mm, addr);
88037 - if (TASK_SIZE - len >= addr &&
88038 - (!vma || addr + len <= vma->vm_start))
88039 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
88040 return addr;
88041 }
88042
88043 @@ -1914,6 +2188,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88044 info.low_limit = PAGE_SIZE;
88045 info.high_limit = mm->mmap_base;
88046 info.align_mask = 0;
88047 + info.threadstack_offset = offset;
88048 addr = vm_unmapped_area(&info);
88049
88050 /*
88051 @@ -1926,6 +2201,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
88052 VM_BUG_ON(addr != -ENOMEM);
88053 info.flags = 0;
88054 info.low_limit = TASK_UNMAPPED_BASE;
88055 +
88056 +#ifdef CONFIG_PAX_RANDMMAP
88057 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88058 + info.low_limit += mm->delta_mmap;
88059 +#endif
88060 +
88061 info.high_limit = TASK_SIZE;
88062 addr = vm_unmapped_area(&info);
88063 }
88064 @@ -2027,6 +2308,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
88065 return vma;
88066 }
88067
88068 +#ifdef CONFIG_PAX_SEGMEXEC
88069 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
88070 +{
88071 + struct vm_area_struct *vma_m;
88072 +
88073 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
88074 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
88075 + BUG_ON(vma->vm_mirror);
88076 + return NULL;
88077 + }
88078 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
88079 + vma_m = vma->vm_mirror;
88080 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
88081 + BUG_ON(vma->vm_file != vma_m->vm_file);
88082 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
88083 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
88084 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
88085 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
88086 + return vma_m;
88087 +}
88088 +#endif
88089 +
88090 /*
88091 * Verify that the stack growth is acceptable and
88092 * update accounting. This is shared with both the
88093 @@ -2043,6 +2346,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88094 return -ENOMEM;
88095
88096 /* Stack limit test */
88097 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
88098 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
88099 return -ENOMEM;
88100
88101 @@ -2053,6 +2357,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88102 locked = mm->locked_vm + grow;
88103 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
88104 limit >>= PAGE_SHIFT;
88105 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
88106 if (locked > limit && !capable(CAP_IPC_LOCK))
88107 return -ENOMEM;
88108 }
88109 @@ -2082,37 +2387,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
88110 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
88111 * vma is the last one with address > vma->vm_end. Have to extend vma.
88112 */
88113 +#ifndef CONFIG_IA64
88114 +static
88115 +#endif
88116 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88117 {
88118 int error;
88119 + bool locknext;
88120
88121 if (!(vma->vm_flags & VM_GROWSUP))
88122 return -EFAULT;
88123
88124 + /* Also guard against wrapping around to address 0. */
88125 + if (address < PAGE_ALIGN(address+1))
88126 + address = PAGE_ALIGN(address+1);
88127 + else
88128 + return -ENOMEM;
88129 +
88130 /*
88131 * We must make sure the anon_vma is allocated
88132 * so that the anon_vma locking is not a noop.
88133 */
88134 if (unlikely(anon_vma_prepare(vma)))
88135 return -ENOMEM;
88136 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
88137 + if (locknext && anon_vma_prepare(vma->vm_next))
88138 + return -ENOMEM;
88139 vma_lock_anon_vma(vma);
88140 + if (locknext)
88141 + vma_lock_anon_vma(vma->vm_next);
88142
88143 /*
88144 * vma->vm_start/vm_end cannot change under us because the caller
88145 * is required to hold the mmap_sem in read mode. We need the
88146 - * anon_vma lock to serialize against concurrent expand_stacks.
88147 - * Also guard against wrapping around to address 0.
88148 + * anon_vma locks to serialize against concurrent expand_stacks
88149 + * and expand_upwards.
88150 */
88151 - if (address < PAGE_ALIGN(address+4))
88152 - address = PAGE_ALIGN(address+4);
88153 - else {
88154 - vma_unlock_anon_vma(vma);
88155 - return -ENOMEM;
88156 - }
88157 error = 0;
88158
88159 /* Somebody else might have raced and expanded it already */
88160 - if (address > vma->vm_end) {
88161 + 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)
88162 + error = -ENOMEM;
88163 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
88164 unsigned long size, grow;
88165
88166 size = address - vma->vm_start;
88167 @@ -2147,6 +2463,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
88168 }
88169 }
88170 }
88171 + if (locknext)
88172 + vma_unlock_anon_vma(vma->vm_next);
88173 vma_unlock_anon_vma(vma);
88174 khugepaged_enter_vma_merge(vma);
88175 validate_mm(vma->vm_mm);
88176 @@ -2161,6 +2479,8 @@ int expand_downwards(struct vm_area_struct *vma,
88177 unsigned long address)
88178 {
88179 int error;
88180 + bool lockprev = false;
88181 + struct vm_area_struct *prev;
88182
88183 /*
88184 * We must make sure the anon_vma is allocated
88185 @@ -2174,6 +2494,15 @@ int expand_downwards(struct vm_area_struct *vma,
88186 if (error)
88187 return error;
88188
88189 + prev = vma->vm_prev;
88190 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
88191 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
88192 +#endif
88193 + if (lockprev && anon_vma_prepare(prev))
88194 + return -ENOMEM;
88195 + if (lockprev)
88196 + vma_lock_anon_vma(prev);
88197 +
88198 vma_lock_anon_vma(vma);
88199
88200 /*
88201 @@ -2183,9 +2512,17 @@ int expand_downwards(struct vm_area_struct *vma,
88202 */
88203
88204 /* Somebody else might have raced and expanded it already */
88205 - if (address < vma->vm_start) {
88206 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
88207 + error = -ENOMEM;
88208 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
88209 unsigned long size, grow;
88210
88211 +#ifdef CONFIG_PAX_SEGMEXEC
88212 + struct vm_area_struct *vma_m;
88213 +
88214 + vma_m = pax_find_mirror_vma(vma);
88215 +#endif
88216 +
88217 size = vma->vm_end - address;
88218 grow = (vma->vm_start - address) >> PAGE_SHIFT;
88219
88220 @@ -2210,13 +2547,27 @@ int expand_downwards(struct vm_area_struct *vma,
88221 vma->vm_pgoff -= grow;
88222 anon_vma_interval_tree_post_update_vma(vma);
88223 vma_gap_update(vma);
88224 +
88225 +#ifdef CONFIG_PAX_SEGMEXEC
88226 + if (vma_m) {
88227 + anon_vma_interval_tree_pre_update_vma(vma_m);
88228 + vma_m->vm_start -= grow << PAGE_SHIFT;
88229 + vma_m->vm_pgoff -= grow;
88230 + anon_vma_interval_tree_post_update_vma(vma_m);
88231 + vma_gap_update(vma_m);
88232 + }
88233 +#endif
88234 +
88235 spin_unlock(&vma->vm_mm->page_table_lock);
88236
88237 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
88238 perf_event_mmap(vma);
88239 }
88240 }
88241 }
88242 vma_unlock_anon_vma(vma);
88243 + if (lockprev)
88244 + vma_unlock_anon_vma(prev);
88245 khugepaged_enter_vma_merge(vma);
88246 validate_mm(vma->vm_mm);
88247 return error;
88248 @@ -2314,6 +2665,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
88249 do {
88250 long nrpages = vma_pages(vma);
88251
88252 +#ifdef CONFIG_PAX_SEGMEXEC
88253 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
88254 + vma = remove_vma(vma);
88255 + continue;
88256 + }
88257 +#endif
88258 +
88259 if (vma->vm_flags & VM_ACCOUNT)
88260 nr_accounted += nrpages;
88261 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
88262 @@ -2358,6 +2716,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
88263 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
88264 vma->vm_prev = NULL;
88265 do {
88266 +
88267 +#ifdef CONFIG_PAX_SEGMEXEC
88268 + if (vma->vm_mirror) {
88269 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
88270 + vma->vm_mirror->vm_mirror = NULL;
88271 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
88272 + vma->vm_mirror = NULL;
88273 + }
88274 +#endif
88275 +
88276 vma_rb_erase(vma, &mm->mm_rb);
88277 mm->map_count--;
88278 tail_vma = vma;
88279 @@ -2384,14 +2752,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88280 struct vm_area_struct *new;
88281 int err = -ENOMEM;
88282
88283 +#ifdef CONFIG_PAX_SEGMEXEC
88284 + struct vm_area_struct *vma_m, *new_m = NULL;
88285 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
88286 +#endif
88287 +
88288 if (is_vm_hugetlb_page(vma) && (addr &
88289 ~(huge_page_mask(hstate_vma(vma)))))
88290 return -EINVAL;
88291
88292 +#ifdef CONFIG_PAX_SEGMEXEC
88293 + vma_m = pax_find_mirror_vma(vma);
88294 +#endif
88295 +
88296 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88297 if (!new)
88298 goto out_err;
88299
88300 +#ifdef CONFIG_PAX_SEGMEXEC
88301 + if (vma_m) {
88302 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
88303 + if (!new_m) {
88304 + kmem_cache_free(vm_area_cachep, new);
88305 + goto out_err;
88306 + }
88307 + }
88308 +#endif
88309 +
88310 /* most fields are the same, copy all, and then fixup */
88311 *new = *vma;
88312
88313 @@ -2404,6 +2791,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88314 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
88315 }
88316
88317 +#ifdef CONFIG_PAX_SEGMEXEC
88318 + if (vma_m) {
88319 + *new_m = *vma_m;
88320 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
88321 + new_m->vm_mirror = new;
88322 + new->vm_mirror = new_m;
88323 +
88324 + if (new_below)
88325 + new_m->vm_end = addr_m;
88326 + else {
88327 + new_m->vm_start = addr_m;
88328 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
88329 + }
88330 + }
88331 +#endif
88332 +
88333 pol = mpol_dup(vma_policy(vma));
88334 if (IS_ERR(pol)) {
88335 err = PTR_ERR(pol);
88336 @@ -2426,6 +2829,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88337 else
88338 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
88339
88340 +#ifdef CONFIG_PAX_SEGMEXEC
88341 + if (!err && vma_m) {
88342 + if (anon_vma_clone(new_m, vma_m))
88343 + goto out_free_mpol;
88344 +
88345 + mpol_get(pol);
88346 + vma_set_policy(new_m, pol);
88347 +
88348 + if (new_m->vm_file)
88349 + get_file(new_m->vm_file);
88350 +
88351 + if (new_m->vm_ops && new_m->vm_ops->open)
88352 + new_m->vm_ops->open(new_m);
88353 +
88354 + if (new_below)
88355 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
88356 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
88357 + else
88358 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
88359 +
88360 + if (err) {
88361 + if (new_m->vm_ops && new_m->vm_ops->close)
88362 + new_m->vm_ops->close(new_m);
88363 + if (new_m->vm_file)
88364 + fput(new_m->vm_file);
88365 + mpol_put(pol);
88366 + }
88367 + }
88368 +#endif
88369 +
88370 /* Success. */
88371 if (!err)
88372 return 0;
88373 @@ -2435,10 +2868,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88374 new->vm_ops->close(new);
88375 if (new->vm_file)
88376 fput(new->vm_file);
88377 - unlink_anon_vmas(new);
88378 out_free_mpol:
88379 mpol_put(pol);
88380 out_free_vma:
88381 +
88382 +#ifdef CONFIG_PAX_SEGMEXEC
88383 + if (new_m) {
88384 + unlink_anon_vmas(new_m);
88385 + kmem_cache_free(vm_area_cachep, new_m);
88386 + }
88387 +#endif
88388 +
88389 + unlink_anon_vmas(new);
88390 kmem_cache_free(vm_area_cachep, new);
88391 out_err:
88392 return err;
88393 @@ -2451,6 +2892,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
88394 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88395 unsigned long addr, int new_below)
88396 {
88397 +
88398 +#ifdef CONFIG_PAX_SEGMEXEC
88399 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
88400 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
88401 + if (mm->map_count >= sysctl_max_map_count-1)
88402 + return -ENOMEM;
88403 + } else
88404 +#endif
88405 +
88406 if (mm->map_count >= sysctl_max_map_count)
88407 return -ENOMEM;
88408
88409 @@ -2462,11 +2912,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
88410 * work. This now handles partial unmappings.
88411 * Jeremy Fitzhardinge <jeremy@goop.org>
88412 */
88413 +#ifdef CONFIG_PAX_SEGMEXEC
88414 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88415 {
88416 + int ret = __do_munmap(mm, start, len);
88417 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
88418 + return ret;
88419 +
88420 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
88421 +}
88422 +
88423 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88424 +#else
88425 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88426 +#endif
88427 +{
88428 unsigned long end;
88429 struct vm_area_struct *vma, *prev, *last;
88430
88431 + /*
88432 + * mm->mmap_sem is required to protect against another thread
88433 + * changing the mappings in case we sleep.
88434 + */
88435 + verify_mm_writelocked(mm);
88436 +
88437 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
88438 return -EINVAL;
88439
88440 @@ -2541,6 +3010,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
88441 /* Fix up all other VM information */
88442 remove_vma_list(mm, vma);
88443
88444 + track_exec_limit(mm, start, end, 0UL);
88445 +
88446 return 0;
88447 }
88448
88449 @@ -2549,6 +3020,13 @@ int vm_munmap(unsigned long start, size_t len)
88450 int ret;
88451 struct mm_struct *mm = current->mm;
88452
88453 +
88454 +#ifdef CONFIG_PAX_SEGMEXEC
88455 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
88456 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
88457 + return -EINVAL;
88458 +#endif
88459 +
88460 down_write(&mm->mmap_sem);
88461 ret = do_munmap(mm, start, len);
88462 up_write(&mm->mmap_sem);
88463 @@ -2562,16 +3040,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
88464 return vm_munmap(addr, len);
88465 }
88466
88467 -static inline void verify_mm_writelocked(struct mm_struct *mm)
88468 -{
88469 -#ifdef CONFIG_DEBUG_VM
88470 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
88471 - WARN_ON(1);
88472 - up_read(&mm->mmap_sem);
88473 - }
88474 -#endif
88475 -}
88476 -
88477 /*
88478 * this is really a simplified "do_mmap". it only handles
88479 * anonymous maps. eventually we may be able to do some
88480 @@ -2585,6 +3053,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88481 struct rb_node ** rb_link, * rb_parent;
88482 pgoff_t pgoff = addr >> PAGE_SHIFT;
88483 int error;
88484 + unsigned long charged;
88485
88486 len = PAGE_ALIGN(len);
88487 if (!len)
88488 @@ -2592,16 +3061,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88489
88490 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
88491
88492 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
88493 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
88494 + flags &= ~VM_EXEC;
88495 +
88496 +#ifdef CONFIG_PAX_MPROTECT
88497 + if (mm->pax_flags & MF_PAX_MPROTECT)
88498 + flags &= ~VM_MAYEXEC;
88499 +#endif
88500 +
88501 + }
88502 +#endif
88503 +
88504 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
88505 if (error & ~PAGE_MASK)
88506 return error;
88507
88508 + charged = len >> PAGE_SHIFT;
88509 +
88510 /*
88511 * mlock MCL_FUTURE?
88512 */
88513 if (mm->def_flags & VM_LOCKED) {
88514 unsigned long locked, lock_limit;
88515 - locked = len >> PAGE_SHIFT;
88516 + locked = charged;
88517 locked += mm->locked_vm;
88518 lock_limit = rlimit(RLIMIT_MEMLOCK);
88519 lock_limit >>= PAGE_SHIFT;
88520 @@ -2618,21 +3101,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88521 /*
88522 * Clear old maps. this also does some error checking for us
88523 */
88524 - munmap_back:
88525 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
88526 if (do_munmap(mm, addr, len))
88527 return -ENOMEM;
88528 - goto munmap_back;
88529 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
88530 }
88531
88532 /* Check against address space limits *after* clearing old maps... */
88533 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
88534 + if (!may_expand_vm(mm, charged))
88535 return -ENOMEM;
88536
88537 if (mm->map_count > sysctl_max_map_count)
88538 return -ENOMEM;
88539
88540 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
88541 + if (security_vm_enough_memory_mm(mm, charged))
88542 return -ENOMEM;
88543
88544 /* Can we just expand an old private anonymous mapping? */
88545 @@ -2646,7 +3128,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88546 */
88547 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88548 if (!vma) {
88549 - vm_unacct_memory(len >> PAGE_SHIFT);
88550 + vm_unacct_memory(charged);
88551 return -ENOMEM;
88552 }
88553
88554 @@ -2660,9 +3142,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
88555 vma_link(mm, vma, prev, rb_link, rb_parent);
88556 out:
88557 perf_event_mmap(vma);
88558 - mm->total_vm += len >> PAGE_SHIFT;
88559 + mm->total_vm += charged;
88560 if (flags & VM_LOCKED)
88561 - mm->locked_vm += (len >> PAGE_SHIFT);
88562 + mm->locked_vm += charged;
88563 + track_exec_limit(mm, addr, addr + len, flags);
88564 return addr;
88565 }
88566
88567 @@ -2724,6 +3207,7 @@ void exit_mmap(struct mm_struct *mm)
88568 while (vma) {
88569 if (vma->vm_flags & VM_ACCOUNT)
88570 nr_accounted += vma_pages(vma);
88571 + vma->vm_mirror = NULL;
88572 vma = remove_vma(vma);
88573 }
88574 vm_unacct_memory(nr_accounted);
88575 @@ -2740,6 +3224,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88576 struct vm_area_struct *prev;
88577 struct rb_node **rb_link, *rb_parent;
88578
88579 +#ifdef CONFIG_PAX_SEGMEXEC
88580 + struct vm_area_struct *vma_m = NULL;
88581 +#endif
88582 +
88583 + if (security_mmap_addr(vma->vm_start))
88584 + return -EPERM;
88585 +
88586 /*
88587 * The vm_pgoff of a purely anonymous vma should be irrelevant
88588 * until its first write fault, when page's anon_vma and index
88589 @@ -2763,7 +3254,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
88590 security_vm_enough_memory_mm(mm, vma_pages(vma)))
88591 return -ENOMEM;
88592
88593 +#ifdef CONFIG_PAX_SEGMEXEC
88594 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
88595 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88596 + if (!vma_m)
88597 + return -ENOMEM;
88598 + }
88599 +#endif
88600 +
88601 vma_link(mm, vma, prev, rb_link, rb_parent);
88602 +
88603 +#ifdef CONFIG_PAX_SEGMEXEC
88604 + if (vma_m)
88605 + BUG_ON(pax_mirror_vma(vma_m, vma));
88606 +#endif
88607 +
88608 return 0;
88609 }
88610
88611 @@ -2783,6 +3288,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88612 struct mempolicy *pol;
88613 bool faulted_in_anon_vma = true;
88614
88615 + BUG_ON(vma->vm_mirror);
88616 +
88617 /*
88618 * If anonymous vma has not yet been faulted, update new pgoff
88619 * to match new location, to increase its chance of merging.
88620 @@ -2849,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
88621 return NULL;
88622 }
88623
88624 +#ifdef CONFIG_PAX_SEGMEXEC
88625 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
88626 +{
88627 + struct vm_area_struct *prev_m;
88628 + struct rb_node **rb_link_m, *rb_parent_m;
88629 + struct mempolicy *pol_m;
88630 +
88631 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
88632 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
88633 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
88634 + *vma_m = *vma;
88635 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
88636 + if (anon_vma_clone(vma_m, vma))
88637 + return -ENOMEM;
88638 + pol_m = vma_policy(vma_m);
88639 + mpol_get(pol_m);
88640 + vma_set_policy(vma_m, pol_m);
88641 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
88642 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
88643 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
88644 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
88645 + if (vma_m->vm_file)
88646 + get_file(vma_m->vm_file);
88647 + if (vma_m->vm_ops && vma_m->vm_ops->open)
88648 + vma_m->vm_ops->open(vma_m);
88649 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
88650 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
88651 + vma_m->vm_mirror = vma;
88652 + vma->vm_mirror = vma_m;
88653 + return 0;
88654 +}
88655 +#endif
88656 +
88657 /*
88658 * Return true if the calling process may expand its vm space by the passed
88659 * number of pages
88660 @@ -2860,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
88661
88662 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
88663
88664 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
88665 if (cur + npages > lim)
88666 return 0;
88667 return 1;
88668 @@ -2930,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
88669 vma->vm_start = addr;
88670 vma->vm_end = addr + len;
88671
88672 +#ifdef CONFIG_PAX_MPROTECT
88673 + if (mm->pax_flags & MF_PAX_MPROTECT) {
88674 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
88675 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
88676 + return -EPERM;
88677 + if (!(vm_flags & VM_EXEC))
88678 + vm_flags &= ~VM_MAYEXEC;
88679 +#else
88680 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
88681 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
88682 +#endif
88683 + else
88684 + vm_flags &= ~VM_MAYWRITE;
88685 + }
88686 +#endif
88687 +
88688 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
88689 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
88690
88691 diff --git a/mm/mprotect.c b/mm/mprotect.c
88692 index 94722a4..e661e29 100644
88693 --- a/mm/mprotect.c
88694 +++ b/mm/mprotect.c
88695 @@ -23,10 +23,18 @@
88696 #include <linux/mmu_notifier.h>
88697 #include <linux/migrate.h>
88698 #include <linux/perf_event.h>
88699 +#include <linux/sched/sysctl.h>
88700 +
88701 +#ifdef CONFIG_PAX_MPROTECT
88702 +#include <linux/elf.h>
88703 +#include <linux/binfmts.h>
88704 +#endif
88705 +
88706 #include <asm/uaccess.h>
88707 #include <asm/pgtable.h>
88708 #include <asm/cacheflush.h>
88709 #include <asm/tlbflush.h>
88710 +#include <asm/mmu_context.h>
88711
88712 #ifndef pgprot_modify
88713 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
88714 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
88715 return pages;
88716 }
88717
88718 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88719 +/* called while holding the mmap semaphor for writing except stack expansion */
88720 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
88721 +{
88722 + unsigned long oldlimit, newlimit = 0UL;
88723 +
88724 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
88725 + return;
88726 +
88727 + spin_lock(&mm->page_table_lock);
88728 + oldlimit = mm->context.user_cs_limit;
88729 + if ((prot & VM_EXEC) && oldlimit < end)
88730 + /* USER_CS limit moved up */
88731 + newlimit = end;
88732 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
88733 + /* USER_CS limit moved down */
88734 + newlimit = start;
88735 +
88736 + if (newlimit) {
88737 + mm->context.user_cs_limit = newlimit;
88738 +
88739 +#ifdef CONFIG_SMP
88740 + wmb();
88741 + cpus_clear(mm->context.cpu_user_cs_mask);
88742 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
88743 +#endif
88744 +
88745 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
88746 + }
88747 + spin_unlock(&mm->page_table_lock);
88748 + if (newlimit == end) {
88749 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
88750 +
88751 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
88752 + if (is_vm_hugetlb_page(vma))
88753 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
88754 + else
88755 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
88756 + }
88757 +}
88758 +#endif
88759 +
88760 int
88761 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88762 unsigned long start, unsigned long end, unsigned long newflags)
88763 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88764 int error;
88765 int dirty_accountable = 0;
88766
88767 +#ifdef CONFIG_PAX_SEGMEXEC
88768 + struct vm_area_struct *vma_m = NULL;
88769 + unsigned long start_m, end_m;
88770 +
88771 + start_m = start + SEGMEXEC_TASK_SIZE;
88772 + end_m = end + SEGMEXEC_TASK_SIZE;
88773 +#endif
88774 +
88775 if (newflags == oldflags) {
88776 *pprev = vma;
88777 return 0;
88778 }
88779
88780 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
88781 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
88782 +
88783 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
88784 + return -ENOMEM;
88785 +
88786 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
88787 + return -ENOMEM;
88788 + }
88789 +
88790 /*
88791 * If we make a private mapping writable we increase our commit;
88792 * but (without finer accounting) cannot reduce our commit if we
88793 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
88794 }
88795 }
88796
88797 +#ifdef CONFIG_PAX_SEGMEXEC
88798 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
88799 + if (start != vma->vm_start) {
88800 + error = split_vma(mm, vma, start, 1);
88801 + if (error)
88802 + goto fail;
88803 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
88804 + *pprev = (*pprev)->vm_next;
88805 + }
88806 +
88807 + if (end != vma->vm_end) {
88808 + error = split_vma(mm, vma, end, 0);
88809 + if (error)
88810 + goto fail;
88811 + }
88812 +
88813 + if (pax_find_mirror_vma(vma)) {
88814 + error = __do_munmap(mm, start_m, end_m - start_m);
88815 + if (error)
88816 + goto fail;
88817 + } else {
88818 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
88819 + if (!vma_m) {
88820 + error = -ENOMEM;
88821 + goto fail;
88822 + }
88823 + vma->vm_flags = newflags;
88824 + error = pax_mirror_vma(vma_m, vma);
88825 + if (error) {
88826 + vma->vm_flags = oldflags;
88827 + goto fail;
88828 + }
88829 + }
88830 + }
88831 +#endif
88832 +
88833 /*
88834 * First try to merge with previous and/or next vma.
88835 */
88836 @@ -296,9 +400,21 @@ success:
88837 * vm_flags and vm_page_prot are protected by the mmap_sem
88838 * held in write mode.
88839 */
88840 +
88841 +#ifdef CONFIG_PAX_SEGMEXEC
88842 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
88843 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
88844 +#endif
88845 +
88846 vma->vm_flags = newflags;
88847 +
88848 +#ifdef CONFIG_PAX_MPROTECT
88849 + if (mm->binfmt && mm->binfmt->handle_mprotect)
88850 + mm->binfmt->handle_mprotect(vma, newflags);
88851 +#endif
88852 +
88853 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
88854 - vm_get_page_prot(newflags));
88855 + vm_get_page_prot(vma->vm_flags));
88856
88857 if (vma_wants_writenotify(vma)) {
88858 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
88859 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88860 end = start + len;
88861 if (end <= start)
88862 return -ENOMEM;
88863 +
88864 +#ifdef CONFIG_PAX_SEGMEXEC
88865 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88866 + if (end > SEGMEXEC_TASK_SIZE)
88867 + return -EINVAL;
88868 + } else
88869 +#endif
88870 +
88871 + if (end > TASK_SIZE)
88872 + return -EINVAL;
88873 +
88874 if (!arch_validate_prot(prot))
88875 return -EINVAL;
88876
88877 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88878 /*
88879 * Does the application expect PROT_READ to imply PROT_EXEC:
88880 */
88881 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
88882 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
88883 prot |= PROT_EXEC;
88884
88885 vm_flags = calc_vm_prot_bits(prot);
88886 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88887 if (start > vma->vm_start)
88888 prev = vma;
88889
88890 +#ifdef CONFIG_PAX_MPROTECT
88891 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
88892 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
88893 +#endif
88894 +
88895 for (nstart = start ; ; ) {
88896 unsigned long newflags;
88897
88898 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88899
88900 /* newflags >> 4 shift VM_MAY% in place of VM_% */
88901 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
88902 + if (prot & (PROT_WRITE | PROT_EXEC))
88903 + gr_log_rwxmprotect(vma);
88904 +
88905 + error = -EACCES;
88906 + goto out;
88907 + }
88908 +
88909 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
88910 error = -EACCES;
88911 goto out;
88912 }
88913 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
88914 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
88915 if (error)
88916 goto out;
88917 +
88918 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
88919 +
88920 nstart = tmp;
88921
88922 if (nstart < prev->vm_end)
88923 diff --git a/mm/mremap.c b/mm/mremap.c
88924 index 0843feb..4f5b2e6 100644
88925 --- a/mm/mremap.c
88926 +++ b/mm/mremap.c
88927 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
88928 continue;
88929 pte = ptep_get_and_clear(mm, old_addr, old_pte);
88930 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
88931 +
88932 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
88933 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
88934 + pte = pte_exprotect(pte);
88935 +#endif
88936 +
88937 pte = move_soft_dirty_pte(pte);
88938 set_pte_at(mm, new_addr, new_pte, pte);
88939 }
88940 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
88941 if (is_vm_hugetlb_page(vma))
88942 goto Einval;
88943
88944 +#ifdef CONFIG_PAX_SEGMEXEC
88945 + if (pax_find_mirror_vma(vma))
88946 + goto Einval;
88947 +#endif
88948 +
88949 /* We can't remap across vm area boundaries */
88950 if (old_len > vma->vm_end - addr)
88951 goto Efault;
88952 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
88953 unsigned long ret = -EINVAL;
88954 unsigned long charged = 0;
88955 unsigned long map_flags;
88956 + unsigned long pax_task_size = TASK_SIZE;
88957
88958 if (new_addr & ~PAGE_MASK)
88959 goto out;
88960
88961 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
88962 +#ifdef CONFIG_PAX_SEGMEXEC
88963 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88964 + pax_task_size = SEGMEXEC_TASK_SIZE;
88965 +#endif
88966 +
88967 + pax_task_size -= PAGE_SIZE;
88968 +
88969 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
88970 goto out;
88971
88972 /* Check if the location we're moving into overlaps the
88973 * old location at all, and fail if it does.
88974 */
88975 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
88976 - goto out;
88977 -
88978 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
88979 + if (addr + old_len > new_addr && new_addr + new_len > addr)
88980 goto out;
88981
88982 ret = do_munmap(mm, new_addr, new_len);
88983 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88984 unsigned long ret = -EINVAL;
88985 unsigned long charged = 0;
88986 bool locked = false;
88987 + unsigned long pax_task_size = TASK_SIZE;
88988
88989 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
88990 return ret;
88991 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
88992 if (!new_len)
88993 return ret;
88994
88995 +#ifdef CONFIG_PAX_SEGMEXEC
88996 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
88997 + pax_task_size = SEGMEXEC_TASK_SIZE;
88998 +#endif
88999 +
89000 + pax_task_size -= PAGE_SIZE;
89001 +
89002 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
89003 + old_len > pax_task_size || addr > pax_task_size-old_len)
89004 + return ret;
89005 +
89006 down_write(&current->mm->mmap_sem);
89007
89008 if (flags & MREMAP_FIXED) {
89009 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89010 new_addr = addr;
89011 }
89012 ret = addr;
89013 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
89014 goto out;
89015 }
89016 }
89017 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
89018 goto out;
89019 }
89020
89021 + map_flags = vma->vm_flags;
89022 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
89023 + if (!(ret & ~PAGE_MASK)) {
89024 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
89025 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
89026 + }
89027 }
89028 out:
89029 if (ret & ~PAGE_MASK)
89030 diff --git a/mm/nommu.c b/mm/nommu.c
89031 index ecd1f15..77039bd 100644
89032 --- a/mm/nommu.c
89033 +++ b/mm/nommu.c
89034 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
89035 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
89036 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
89037 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
89038 -int heap_stack_gap = 0;
89039
89040 atomic_long_t mmap_pages_allocated;
89041
89042 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
89043 EXPORT_SYMBOL(find_vma);
89044
89045 /*
89046 - * find a VMA
89047 - * - we don't extend stack VMAs under NOMMU conditions
89048 - */
89049 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
89050 -{
89051 - return find_vma(mm, addr);
89052 -}
89053 -
89054 -/*
89055 * expand a stack to a given address
89056 * - not supported under NOMMU conditions
89057 */
89058 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
89059
89060 /* most fields are the same, copy all, and then fixup */
89061 *new = *vma;
89062 + INIT_LIST_HEAD(&new->anon_vma_chain);
89063 *region = *vma->vm_region;
89064 new->vm_region = region;
89065
89066 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
89067 }
89068 EXPORT_SYMBOL(generic_file_remap_pages);
89069
89070 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89071 - unsigned long addr, void *buf, int len, int write)
89072 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89073 + unsigned long addr, void *buf, size_t len, int write)
89074 {
89075 struct vm_area_struct *vma;
89076
89077 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89078 *
89079 * The caller must hold a reference on @mm.
89080 */
89081 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89082 - void *buf, int len, int write)
89083 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89084 + void *buf, size_t len, int write)
89085 {
89086 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89087 }
89088 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89089 * Access another process' address space.
89090 * - source/target buffer must be kernel space
89091 */
89092 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
89093 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
89094 {
89095 struct mm_struct *mm;
89096
89097 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
89098 index 3f0c895..60cd104 100644
89099 --- a/mm/page-writeback.c
89100 +++ b/mm/page-writeback.c
89101 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
89102 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
89103 * - the bdi dirty thresh drops quickly due to change of JBOD workload
89104 */
89105 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
89106 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
89107 unsigned long thresh,
89108 unsigned long bg_thresh,
89109 unsigned long dirty,
89110 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
89111 index b100255..fba1254 100644
89112 --- a/mm/page_alloc.c
89113 +++ b/mm/page_alloc.c
89114 @@ -60,6 +60,7 @@
89115 #include <linux/page-debug-flags.h>
89116 #include <linux/hugetlb.h>
89117 #include <linux/sched/rt.h>
89118 +#include <linux/random.h>
89119
89120 #include <asm/sections.h>
89121 #include <asm/tlbflush.h>
89122 @@ -353,7 +354,7 @@ out:
89123 * This usage means that zero-order pages may not be compound.
89124 */
89125
89126 -static void free_compound_page(struct page *page)
89127 +void free_compound_page(struct page *page)
89128 {
89129 __free_pages_ok(page, compound_order(page));
89130 }
89131 @@ -710,6 +711,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89132 int i;
89133 int bad = 0;
89134
89135 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89136 + unsigned long index = 1UL << order;
89137 +#endif
89138 +
89139 trace_mm_page_free(page, order);
89140 kmemcheck_free_shadow(page, order);
89141
89142 @@ -725,6 +730,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
89143 debug_check_no_obj_freed(page_address(page),
89144 PAGE_SIZE << order);
89145 }
89146 +
89147 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89148 + for (; index; --index)
89149 + sanitize_highpage(page + index - 1);
89150 +#endif
89151 +
89152 arch_free_page(page, order);
89153 kernel_map_pages(page, 1 << order, 0);
89154
89155 @@ -747,6 +758,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
89156 local_irq_restore(flags);
89157 }
89158
89159 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89160 +bool __meminitdata extra_latent_entropy;
89161 +
89162 +static int __init setup_pax_extra_latent_entropy(char *str)
89163 +{
89164 + extra_latent_entropy = true;
89165 + return 0;
89166 +}
89167 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
89168 +
89169 +volatile u64 latent_entropy;
89170 +EXPORT_SYMBOL(latent_entropy);
89171 +#endif
89172 +
89173 void __init __free_pages_bootmem(struct page *page, unsigned int order)
89174 {
89175 unsigned int nr_pages = 1 << order;
89176 @@ -762,6 +787,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
89177 set_page_count(p, 0);
89178 }
89179
89180 +#ifdef CONFIG_PAX_LATENT_ENTROPY
89181 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
89182 + u64 hash = 0;
89183 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
89184 + const u64 *data = lowmem_page_address(page);
89185 +
89186 + for (index = 0; index < end; index++)
89187 + hash ^= hash + data[index];
89188 + latent_entropy ^= hash;
89189 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
89190 + }
89191 +#endif
89192 +
89193 page_zone(page)->managed_pages += 1 << order;
89194 set_page_refcounted(page);
89195 __free_pages(page, order);
89196 @@ -867,8 +905,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
89197 arch_alloc_page(page, order);
89198 kernel_map_pages(page, 1 << order, 1);
89199
89200 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
89201 if (gfp_flags & __GFP_ZERO)
89202 prep_zero_page(page, order, gfp_flags);
89203 +#endif
89204
89205 if (order && (gfp_flags & __GFP_COMP))
89206 prep_compound_page(page, order);
89207 diff --git a/mm/page_io.c b/mm/page_io.c
89208 index ba05b64..ef2f314 100644
89209 --- a/mm/page_io.c
89210 +++ b/mm/page_io.c
89211 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
89212 struct file *swap_file = sis->swap_file;
89213 struct address_space *mapping = swap_file->f_mapping;
89214 struct iovec iov = {
89215 - .iov_base = kmap(page),
89216 + .iov_base = (void __force_user *)kmap(page),
89217 .iov_len = PAGE_SIZE,
89218 };
89219
89220 diff --git a/mm/percpu.c b/mm/percpu.c
89221 index 8c8e08f..73a5cda 100644
89222 --- a/mm/percpu.c
89223 +++ b/mm/percpu.c
89224 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
89225 static unsigned int pcpu_high_unit_cpu __read_mostly;
89226
89227 /* the address of the first chunk which starts with the kernel static area */
89228 -void *pcpu_base_addr __read_mostly;
89229 +void *pcpu_base_addr __read_only;
89230 EXPORT_SYMBOL_GPL(pcpu_base_addr);
89231
89232 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
89233 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
89234 index fd26d04..0cea1b0 100644
89235 --- a/mm/process_vm_access.c
89236 +++ b/mm/process_vm_access.c
89237 @@ -13,6 +13,7 @@
89238 #include <linux/uio.h>
89239 #include <linux/sched.h>
89240 #include <linux/highmem.h>
89241 +#include <linux/security.h>
89242 #include <linux/ptrace.h>
89243 #include <linux/slab.h>
89244 #include <linux/syscalls.h>
89245 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89246 size_t iov_l_curr_offset = 0;
89247 ssize_t iov_len;
89248
89249 + return -ENOSYS; // PaX: until properly audited
89250 +
89251 /*
89252 * Work out how many pages of struct pages we're going to need
89253 * when eventually calling get_user_pages
89254 */
89255 for (i = 0; i < riovcnt; i++) {
89256 iov_len = rvec[i].iov_len;
89257 - if (iov_len > 0) {
89258 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
89259 - + iov_len)
89260 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
89261 - / PAGE_SIZE + 1;
89262 - nr_pages = max(nr_pages, nr_pages_iov);
89263 - }
89264 + if (iov_len <= 0)
89265 + continue;
89266 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
89267 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
89268 + nr_pages = max(nr_pages, nr_pages_iov);
89269 }
89270
89271 if (nr_pages == 0)
89272 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
89273 goto free_proc_pages;
89274 }
89275
89276 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
89277 + rc = -EPERM;
89278 + goto put_task_struct;
89279 + }
89280 +
89281 mm = mm_access(task, PTRACE_MODE_ATTACH);
89282 if (!mm || IS_ERR(mm)) {
89283 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
89284 diff --git a/mm/rmap.c b/mm/rmap.c
89285 index b2e29ac..4168491 100644
89286 --- a/mm/rmap.c
89287 +++ b/mm/rmap.c
89288 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89289 struct anon_vma *anon_vma = vma->anon_vma;
89290 struct anon_vma_chain *avc;
89291
89292 +#ifdef CONFIG_PAX_SEGMEXEC
89293 + struct anon_vma_chain *avc_m = NULL;
89294 +#endif
89295 +
89296 might_sleep();
89297 if (unlikely(!anon_vma)) {
89298 struct mm_struct *mm = vma->vm_mm;
89299 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89300 if (!avc)
89301 goto out_enomem;
89302
89303 +#ifdef CONFIG_PAX_SEGMEXEC
89304 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
89305 + if (!avc_m)
89306 + goto out_enomem_free_avc;
89307 +#endif
89308 +
89309 anon_vma = find_mergeable_anon_vma(vma);
89310 allocated = NULL;
89311 if (!anon_vma) {
89312 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89313 /* page_table_lock to protect against threads */
89314 spin_lock(&mm->page_table_lock);
89315 if (likely(!vma->anon_vma)) {
89316 +
89317 +#ifdef CONFIG_PAX_SEGMEXEC
89318 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
89319 +
89320 + if (vma_m) {
89321 + BUG_ON(vma_m->anon_vma);
89322 + vma_m->anon_vma = anon_vma;
89323 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
89324 + avc_m = NULL;
89325 + }
89326 +#endif
89327 +
89328 vma->anon_vma = anon_vma;
89329 anon_vma_chain_link(vma, avc, anon_vma);
89330 allocated = NULL;
89331 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
89332
89333 if (unlikely(allocated))
89334 put_anon_vma(allocated);
89335 +
89336 +#ifdef CONFIG_PAX_SEGMEXEC
89337 + if (unlikely(avc_m))
89338 + anon_vma_chain_free(avc_m);
89339 +#endif
89340 +
89341 if (unlikely(avc))
89342 anon_vma_chain_free(avc);
89343 }
89344 return 0;
89345
89346 out_enomem_free_avc:
89347 +
89348 +#ifdef CONFIG_PAX_SEGMEXEC
89349 + if (avc_m)
89350 + anon_vma_chain_free(avc_m);
89351 +#endif
89352 +
89353 anon_vma_chain_free(avc);
89354 out_enomem:
89355 return -ENOMEM;
89356 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
89357 * Attach the anon_vmas from src to dst.
89358 * Returns 0 on success, -ENOMEM on failure.
89359 */
89360 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89361 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
89362 {
89363 struct anon_vma_chain *avc, *pavc;
89364 struct anon_vma *root = NULL;
89365 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
89366 * the corresponding VMA in the parent process is attached to.
89367 * Returns 0 on success, non-zero on failure.
89368 */
89369 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
89370 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
89371 {
89372 struct anon_vma_chain *avc;
89373 struct anon_vma *anon_vma;
89374 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
89375 void __init anon_vma_init(void)
89376 {
89377 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
89378 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
89379 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
89380 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
89381 + anon_vma_ctor);
89382 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
89383 + SLAB_PANIC|SLAB_NO_SANITIZE);
89384 }
89385
89386 /*
89387 diff --git a/mm/shmem.c b/mm/shmem.c
89388 index e43dc55..930e3a2 100644
89389 --- a/mm/shmem.c
89390 +++ b/mm/shmem.c
89391 @@ -33,7 +33,7 @@
89392 #include <linux/swap.h>
89393 #include <linux/aio.h>
89394
89395 -static struct vfsmount *shm_mnt;
89396 +struct vfsmount *shm_mnt;
89397
89398 #ifdef CONFIG_SHMEM
89399 /*
89400 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
89401 #define BOGO_DIRENT_SIZE 20
89402
89403 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
89404 -#define SHORT_SYMLINK_LEN 128
89405 +#define SHORT_SYMLINK_LEN 64
89406
89407 /*
89408 * shmem_fallocate and shmem_writepage communicate via inode->i_private
89409 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
89410 static int shmem_xattr_validate(const char *name)
89411 {
89412 struct { const char *prefix; size_t len; } arr[] = {
89413 +
89414 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89415 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
89416 +#endif
89417 +
89418 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
89419 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
89420 };
89421 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
89422 if (err)
89423 return err;
89424
89425 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
89426 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
89427 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
89428 + return -EOPNOTSUPP;
89429 + if (size > 8)
89430 + return -EINVAL;
89431 + }
89432 +#endif
89433 +
89434 return simple_xattr_set(&info->xattrs, name, value, size, flags);
89435 }
89436
89437 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
89438 int err = -ENOMEM;
89439
89440 /* Round up to L1_CACHE_BYTES to resist false sharing */
89441 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
89442 - L1_CACHE_BYTES), GFP_KERNEL);
89443 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
89444 if (!sbinfo)
89445 return -ENOMEM;
89446
89447 diff --git a/mm/slab.c b/mm/slab.c
89448 index 2580db0..0523956 100644
89449 --- a/mm/slab.c
89450 +++ b/mm/slab.c
89451 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89452 if ((x)->max_freeable < i) \
89453 (x)->max_freeable = i; \
89454 } while (0)
89455 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
89456 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
89457 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
89458 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
89459 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
89460 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
89461 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
89462 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
89463 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
89464 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
89465 #else
89466 #define STATS_INC_ACTIVE(x) do { } while (0)
89467 #define STATS_DEC_ACTIVE(x) do { } while (0)
89468 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
89469 #define STATS_INC_ALLOCMISS(x) do { } while (0)
89470 #define STATS_INC_FREEHIT(x) do { } while (0)
89471 #define STATS_INC_FREEMISS(x) do { } while (0)
89472 +#define STATS_INC_SANITIZED(x) do { } while (0)
89473 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
89474 #endif
89475
89476 #if DEBUG
89477 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
89478 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
89479 */
89480 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
89481 - const struct slab *slab, void *obj)
89482 + const struct slab *slab, const void *obj)
89483 {
89484 u32 offset = (obj - slab->s_mem);
89485 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
89486 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
89487 */
89488
89489 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
89490 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
89491 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89492
89493 if (INDEX_AC != INDEX_NODE)
89494 kmalloc_caches[INDEX_NODE] =
89495 create_kmalloc_cache("kmalloc-node",
89496 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
89497 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
89498
89499 slab_early_init = 0;
89500
89501 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
89502 struct array_cache *ac = cpu_cache_get(cachep);
89503
89504 check_irq_off();
89505 +
89506 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89507 + if (pax_sanitize_slab) {
89508 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
89509 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
89510 +
89511 + if (cachep->ctor)
89512 + cachep->ctor(objp);
89513 +
89514 + STATS_INC_SANITIZED(cachep);
89515 + } else
89516 + STATS_INC_NOT_SANITIZED(cachep);
89517 + }
89518 +#endif
89519 +
89520 kmemleak_free_recursive(objp, cachep->flags);
89521 objp = cache_free_debugcheck(cachep, objp, caller);
89522
89523 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
89524
89525 if (unlikely(ZERO_OR_NULL_PTR(objp)))
89526 return;
89527 + VM_BUG_ON(!virt_addr_valid(objp));
89528 local_irq_save(flags);
89529 kfree_debugcheck(objp);
89530 c = virt_to_cache(objp);
89531 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
89532 }
89533 /* cpu stats */
89534 {
89535 - unsigned long allochit = atomic_read(&cachep->allochit);
89536 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
89537 - unsigned long freehit = atomic_read(&cachep->freehit);
89538 - unsigned long freemiss = atomic_read(&cachep->freemiss);
89539 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
89540 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
89541 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
89542 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
89543
89544 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
89545 allochit, allocmiss, freehit, freemiss);
89546 }
89547 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89548 + {
89549 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
89550 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
89551 +
89552 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
89553 + }
89554 +#endif
89555 #endif
89556 }
89557
89558 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
89559 static int __init slab_proc_init(void)
89560 {
89561 #ifdef CONFIG_DEBUG_SLAB_LEAK
89562 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
89563 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
89564 #endif
89565 return 0;
89566 }
89567 module_init(slab_proc_init);
89568 #endif
89569
89570 +bool is_usercopy_object(const void *ptr)
89571 +{
89572 + struct page *page;
89573 + struct kmem_cache *cachep;
89574 +
89575 + if (ZERO_OR_NULL_PTR(ptr))
89576 + return false;
89577 +
89578 + if (!slab_is_available())
89579 + return false;
89580 +
89581 + if (!virt_addr_valid(ptr))
89582 + return false;
89583 +
89584 + page = virt_to_head_page(ptr);
89585 +
89586 + if (!PageSlab(page))
89587 + return false;
89588 +
89589 + cachep = page->slab_cache;
89590 + return cachep->flags & SLAB_USERCOPY;
89591 +}
89592 +
89593 +#ifdef CONFIG_PAX_USERCOPY
89594 +const char *check_heap_object(const void *ptr, unsigned long n)
89595 +{
89596 + struct page *page;
89597 + struct kmem_cache *cachep;
89598 + struct slab *slabp;
89599 + unsigned int objnr;
89600 + unsigned long offset;
89601 +
89602 + if (ZERO_OR_NULL_PTR(ptr))
89603 + return "<null>";
89604 +
89605 + if (!virt_addr_valid(ptr))
89606 + return NULL;
89607 +
89608 + page = virt_to_head_page(ptr);
89609 +
89610 + if (!PageSlab(page))
89611 + return NULL;
89612 +
89613 + cachep = page->slab_cache;
89614 + if (!(cachep->flags & SLAB_USERCOPY))
89615 + return cachep->name;
89616 +
89617 + slabp = page->slab_page;
89618 + objnr = obj_to_index(cachep, slabp, ptr);
89619 + BUG_ON(objnr >= cachep->num);
89620 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
89621 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
89622 + return NULL;
89623 +
89624 + return cachep->name;
89625 +}
89626 +#endif
89627 +
89628 /**
89629 * ksize - get the actual amount of memory allocated for a given object
89630 * @objp: Pointer to the object
89631 diff --git a/mm/slab.h b/mm/slab.h
89632 index a535033..2f98fe5 100644
89633 --- a/mm/slab.h
89634 +++ b/mm/slab.h
89635 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
89636 /* The slab cache that manages slab cache information */
89637 extern struct kmem_cache *kmem_cache;
89638
89639 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89640 +#ifdef CONFIG_X86_64
89641 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
89642 +#else
89643 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
89644 +#endif
89645 +extern bool pax_sanitize_slab;
89646 +#endif
89647 +
89648 unsigned long calculate_alignment(unsigned long flags,
89649 unsigned long align, unsigned long size);
89650
89651 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
89652
89653 /* Legal flag mask for kmem_cache_create(), for various configurations */
89654 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
89655 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
89656 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
89657 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
89658
89659 #if defined(CONFIG_DEBUG_SLAB)
89660 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
89661 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
89662 return s;
89663
89664 page = virt_to_head_page(x);
89665 +
89666 + BUG_ON(!PageSlab(page));
89667 +
89668 cachep = page->slab_cache;
89669 if (slab_equal_or_root(cachep, s))
89670 return cachep;
89671 diff --git a/mm/slab_common.c b/mm/slab_common.c
89672 index 538bade..36fed99 100644
89673 --- a/mm/slab_common.c
89674 +++ b/mm/slab_common.c
89675 @@ -22,11 +22,22 @@
89676
89677 #include "slab.h"
89678
89679 -enum slab_state slab_state;
89680 +enum slab_state slab_state __read_only;
89681 LIST_HEAD(slab_caches);
89682 DEFINE_MUTEX(slab_mutex);
89683 struct kmem_cache *kmem_cache;
89684
89685 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89686 +bool pax_sanitize_slab __read_only = true;
89687 +static int __init pax_sanitize_slab_setup(char *str)
89688 +{
89689 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
89690 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
89691 + return 1;
89692 +}
89693 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
89694 +#endif
89695 +
89696 #ifdef CONFIG_DEBUG_VM
89697 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
89698 size_t size)
89699 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
89700
89701 err = __kmem_cache_create(s, flags);
89702 if (!err) {
89703 - s->refcount = 1;
89704 + atomic_set(&s->refcount, 1);
89705 list_add(&s->list, &slab_caches);
89706 memcg_cache_list_add(memcg, s);
89707 } else {
89708 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
89709
89710 get_online_cpus();
89711 mutex_lock(&slab_mutex);
89712 - s->refcount--;
89713 - if (!s->refcount) {
89714 + if (atomic_dec_and_test(&s->refcount)) {
89715 list_del(&s->list);
89716
89717 if (!__kmem_cache_shutdown(s)) {
89718 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
89719 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
89720 name, size, err);
89721
89722 - s->refcount = -1; /* Exempt from merging for now */
89723 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
89724 }
89725
89726 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89727 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
89728
89729 create_boot_cache(s, name, size, flags);
89730 list_add(&s->list, &slab_caches);
89731 - s->refcount = 1;
89732 + atomic_set(&s->refcount, 1);
89733 return s;
89734 }
89735
89736 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
89737 EXPORT_SYMBOL(kmalloc_dma_caches);
89738 #endif
89739
89740 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89741 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
89742 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
89743 +#endif
89744 +
89745 /*
89746 * Conversion table for small slabs sizes / 8 to the index in the
89747 * kmalloc array. This is necessary for slabs < 192 since we have non power
89748 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
89749 return kmalloc_dma_caches[index];
89750
89751 #endif
89752 +
89753 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89754 + if (unlikely((flags & GFP_USERCOPY)))
89755 + return kmalloc_usercopy_caches[index];
89756 +
89757 +#endif
89758 +
89759 return kmalloc_caches[index];
89760 }
89761
89762 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
89763 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
89764 if (!kmalloc_caches[i]) {
89765 kmalloc_caches[i] = create_kmalloc_cache(NULL,
89766 - 1 << i, flags);
89767 + 1 << i, SLAB_USERCOPY | flags);
89768 }
89769
89770 /*
89771 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
89772 * earlier power of two caches
89773 */
89774 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
89775 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
89776 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
89777
89778 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
89779 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
89780 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
89781 }
89782
89783 /* Kmalloc array is now usable */
89784 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
89785 }
89786 }
89787 #endif
89788 +
89789 +#ifdef CONFIG_PAX_USERCOPY_SLABS
89790 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
89791 + struct kmem_cache *s = kmalloc_caches[i];
89792 +
89793 + if (s) {
89794 + int size = kmalloc_size(i);
89795 + char *n = kasprintf(GFP_NOWAIT,
89796 + "usercopy-kmalloc-%d", size);
89797 +
89798 + BUG_ON(!n);
89799 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
89800 + size, SLAB_USERCOPY | flags);
89801 + }
89802 + }
89803 +#endif
89804 +
89805 }
89806 #endif /* !CONFIG_SLOB */
89807
89808 @@ -523,6 +562,9 @@ void print_slabinfo_header(struct seq_file *m)
89809 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
89810 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
89811 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
89812 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89813 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
89814 +#endif
89815 #endif
89816 seq_putc(m, '\n');
89817 }
89818 diff --git a/mm/slob.c b/mm/slob.c
89819 index 91bd3f2..e2f549e 100644
89820 --- a/mm/slob.c
89821 +++ b/mm/slob.c
89822 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
89823 /*
89824 * Return the size of a slob block.
89825 */
89826 -static slobidx_t slob_units(slob_t *s)
89827 +static slobidx_t slob_units(const slob_t *s)
89828 {
89829 if (s->units > 0)
89830 return s->units;
89831 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
89832 /*
89833 * Return the next free slob block pointer after this one.
89834 */
89835 -static slob_t *slob_next(slob_t *s)
89836 +static slob_t *slob_next(const slob_t *s)
89837 {
89838 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
89839 slobidx_t next;
89840 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
89841 /*
89842 * Returns true if s is the last free block in its page.
89843 */
89844 -static int slob_last(slob_t *s)
89845 +static int slob_last(const slob_t *s)
89846 {
89847 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
89848 }
89849
89850 -static void *slob_new_pages(gfp_t gfp, int order, int node)
89851 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
89852 {
89853 - void *page;
89854 + struct page *page;
89855
89856 #ifdef CONFIG_NUMA
89857 if (node != NUMA_NO_NODE)
89858 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
89859 if (!page)
89860 return NULL;
89861
89862 - return page_address(page);
89863 + __SetPageSlab(page);
89864 + return page;
89865 }
89866
89867 -static void slob_free_pages(void *b, int order)
89868 +static void slob_free_pages(struct page *sp, int order)
89869 {
89870 if (current->reclaim_state)
89871 current->reclaim_state->reclaimed_slab += 1 << order;
89872 - free_pages((unsigned long)b, order);
89873 + __ClearPageSlab(sp);
89874 + page_mapcount_reset(sp);
89875 + sp->private = 0;
89876 + __free_pages(sp, order);
89877 }
89878
89879 /*
89880 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
89881
89882 /* Not enough space: must allocate a new page */
89883 if (!b) {
89884 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89885 - if (!b)
89886 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
89887 + if (!sp)
89888 return NULL;
89889 - sp = virt_to_page(b);
89890 - __SetPageSlab(sp);
89891 + b = page_address(sp);
89892
89893 spin_lock_irqsave(&slob_lock, flags);
89894 sp->units = SLOB_UNITS(PAGE_SIZE);
89895 sp->freelist = b;
89896 + sp->private = 0;
89897 INIT_LIST_HEAD(&sp->list);
89898 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
89899 set_slob_page_free(sp, slob_list);
89900 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
89901 if (slob_page_free(sp))
89902 clear_slob_page_free(sp);
89903 spin_unlock_irqrestore(&slob_lock, flags);
89904 - __ClearPageSlab(sp);
89905 - page_mapcount_reset(sp);
89906 - slob_free_pages(b, 0);
89907 + slob_free_pages(sp, 0);
89908 return;
89909 }
89910
89911 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
89912 + if (pax_sanitize_slab)
89913 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
89914 +#endif
89915 +
89916 if (!slob_page_free(sp)) {
89917 /* This slob page is about to become partially free. Easy! */
89918 sp->units = units;
89919 @@ -424,11 +431,10 @@ out:
89920 */
89921
89922 static __always_inline void *
89923 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89924 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
89925 {
89926 - unsigned int *m;
89927 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89928 - void *ret;
89929 + slob_t *m;
89930 + void *ret = NULL;
89931
89932 gfp &= gfp_allowed_mask;
89933
89934 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89935
89936 if (!m)
89937 return NULL;
89938 - *m = size;
89939 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
89940 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
89941 + m[0].units = size;
89942 + m[1].units = align;
89943 ret = (void *)m + align;
89944
89945 trace_kmalloc_node(caller, ret,
89946 size, size + align, gfp, node);
89947 } else {
89948 unsigned int order = get_order(size);
89949 + struct page *page;
89950
89951 if (likely(order))
89952 gfp |= __GFP_COMP;
89953 - ret = slob_new_pages(gfp, order, node);
89954 + page = slob_new_pages(gfp, order, node);
89955 + if (page) {
89956 + ret = page_address(page);
89957 + page->private = size;
89958 + }
89959
89960 trace_kmalloc_node(caller, ret,
89961 size, PAGE_SIZE << order, gfp, node);
89962 }
89963
89964 - kmemleak_alloc(ret, size, 1, gfp);
89965 + return ret;
89966 +}
89967 +
89968 +static __always_inline void *
89969 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
89970 +{
89971 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89972 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
89973 +
89974 + if (!ZERO_OR_NULL_PTR(ret))
89975 + kmemleak_alloc(ret, size, 1, gfp);
89976 return ret;
89977 }
89978
89979 @@ -493,34 +517,112 @@ void kfree(const void *block)
89980 return;
89981 kmemleak_free(block);
89982
89983 + VM_BUG_ON(!virt_addr_valid(block));
89984 sp = virt_to_page(block);
89985 - if (PageSlab(sp)) {
89986 + VM_BUG_ON(!PageSlab(sp));
89987 + if (!sp->private) {
89988 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
89989 - unsigned int *m = (unsigned int *)(block - align);
89990 - slob_free(m, *m + align);
89991 - } else
89992 + slob_t *m = (slob_t *)(block - align);
89993 + slob_free(m, m[0].units + align);
89994 + } else {
89995 + __ClearPageSlab(sp);
89996 + page_mapcount_reset(sp);
89997 + sp->private = 0;
89998 __free_pages(sp, compound_order(sp));
89999 + }
90000 }
90001 EXPORT_SYMBOL(kfree);
90002
90003 +bool is_usercopy_object(const void *ptr)
90004 +{
90005 + if (!slab_is_available())
90006 + return false;
90007 +
90008 + // PAX: TODO
90009 +
90010 + return false;
90011 +}
90012 +
90013 +#ifdef CONFIG_PAX_USERCOPY
90014 +const char *check_heap_object(const void *ptr, unsigned long n)
90015 +{
90016 + struct page *page;
90017 + const slob_t *free;
90018 + const void *base;
90019 + unsigned long flags;
90020 +
90021 + if (ZERO_OR_NULL_PTR(ptr))
90022 + return "<null>";
90023 +
90024 + if (!virt_addr_valid(ptr))
90025 + return NULL;
90026 +
90027 + page = virt_to_head_page(ptr);
90028 + if (!PageSlab(page))
90029 + return NULL;
90030 +
90031 + if (page->private) {
90032 + base = page;
90033 + if (base <= ptr && n <= page->private - (ptr - base))
90034 + return NULL;
90035 + return "<slob>";
90036 + }
90037 +
90038 + /* some tricky double walking to find the chunk */
90039 + spin_lock_irqsave(&slob_lock, flags);
90040 + base = (void *)((unsigned long)ptr & PAGE_MASK);
90041 + free = page->freelist;
90042 +
90043 + while (!slob_last(free) && (void *)free <= ptr) {
90044 + base = free + slob_units(free);
90045 + free = slob_next(free);
90046 + }
90047 +
90048 + while (base < (void *)free) {
90049 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
90050 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
90051 + int offset;
90052 +
90053 + if (ptr < base + align)
90054 + break;
90055 +
90056 + offset = ptr - base - align;
90057 + if (offset >= m) {
90058 + base += size;
90059 + continue;
90060 + }
90061 +
90062 + if (n > m - offset)
90063 + break;
90064 +
90065 + spin_unlock_irqrestore(&slob_lock, flags);
90066 + return NULL;
90067 + }
90068 +
90069 + spin_unlock_irqrestore(&slob_lock, flags);
90070 + return "<slob>";
90071 +}
90072 +#endif
90073 +
90074 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
90075 size_t ksize(const void *block)
90076 {
90077 struct page *sp;
90078 int align;
90079 - unsigned int *m;
90080 + slob_t *m;
90081
90082 BUG_ON(!block);
90083 if (unlikely(block == ZERO_SIZE_PTR))
90084 return 0;
90085
90086 sp = virt_to_page(block);
90087 - if (unlikely(!PageSlab(sp)))
90088 - return PAGE_SIZE << compound_order(sp);
90089 + VM_BUG_ON(!PageSlab(sp));
90090 + if (sp->private)
90091 + return sp->private;
90092
90093 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
90094 - m = (unsigned int *)(block - align);
90095 - return SLOB_UNITS(*m) * SLOB_UNIT;
90096 + m = (slob_t *)(block - align);
90097 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
90098 }
90099 EXPORT_SYMBOL(ksize);
90100
90101 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
90102
90103 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
90104 {
90105 - void *b;
90106 + void *b = NULL;
90107
90108 flags &= gfp_allowed_mask;
90109
90110 lockdep_trace_alloc(flags);
90111
90112 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90113 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
90114 +#else
90115 if (c->size < PAGE_SIZE) {
90116 b = slob_alloc(c->size, flags, c->align, node);
90117 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90118 SLOB_UNITS(c->size) * SLOB_UNIT,
90119 flags, node);
90120 } else {
90121 - b = slob_new_pages(flags, get_order(c->size), node);
90122 + struct page *sp;
90123 +
90124 + sp = slob_new_pages(flags, get_order(c->size), node);
90125 + if (sp) {
90126 + b = page_address(sp);
90127 + sp->private = c->size;
90128 + }
90129 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
90130 PAGE_SIZE << get_order(c->size),
90131 flags, node);
90132 }
90133 +#endif
90134
90135 if (b && c->ctor)
90136 c->ctor(b);
90137 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
90138
90139 static void __kmem_cache_free(void *b, int size)
90140 {
90141 - if (size < PAGE_SIZE)
90142 + struct page *sp;
90143 +
90144 + sp = virt_to_page(b);
90145 + BUG_ON(!PageSlab(sp));
90146 + if (!sp->private)
90147 slob_free(b, size);
90148 else
90149 - slob_free_pages(b, get_order(size));
90150 + slob_free_pages(sp, get_order(size));
90151 }
90152
90153 static void kmem_rcu_free(struct rcu_head *head)
90154 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
90155
90156 void kmem_cache_free(struct kmem_cache *c, void *b)
90157 {
90158 + int size = c->size;
90159 +
90160 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90161 + if (size + c->align < PAGE_SIZE) {
90162 + size += c->align;
90163 + b -= c->align;
90164 + }
90165 +#endif
90166 +
90167 kmemleak_free_recursive(b, c->flags);
90168 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
90169 struct slob_rcu *slob_rcu;
90170 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
90171 - slob_rcu->size = c->size;
90172 + slob_rcu = b + (size - sizeof(struct slob_rcu));
90173 + slob_rcu->size = size;
90174 call_rcu(&slob_rcu->head, kmem_rcu_free);
90175 } else {
90176 - __kmem_cache_free(b, c->size);
90177 + __kmem_cache_free(b, size);
90178 }
90179
90180 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90181 + trace_kfree(_RET_IP_, b);
90182 +#else
90183 trace_kmem_cache_free(_RET_IP_, b);
90184 +#endif
90185 +
90186 }
90187 EXPORT_SYMBOL(kmem_cache_free);
90188
90189 diff --git a/mm/slub.c b/mm/slub.c
90190 index e3ba1f2..bd45dac 100644
90191 --- a/mm/slub.c
90192 +++ b/mm/slub.c
90193 @@ -207,7 +207,7 @@ struct track {
90194
90195 enum track_item { TRACK_ALLOC, TRACK_FREE };
90196
90197 -#ifdef CONFIG_SYSFS
90198 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90199 static int sysfs_slab_add(struct kmem_cache *);
90200 static int sysfs_slab_alias(struct kmem_cache *, const char *);
90201 static void sysfs_slab_remove(struct kmem_cache *);
90202 @@ -528,7 +528,7 @@ static void print_track(const char *s, struct track *t)
90203 if (!t->addr)
90204 return;
90205
90206 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
90207 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
90208 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
90209 #ifdef CONFIG_STACKTRACE
90210 {
90211 @@ -2609,6 +2609,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
90212
90213 slab_free_hook(s, x);
90214
90215 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90216 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
90217 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
90218 + if (s->ctor)
90219 + s->ctor(x);
90220 + }
90221 +#endif
90222 +
90223 redo:
90224 /*
90225 * Determine the currently cpus per cpu slab.
90226 @@ -2676,7 +2684,7 @@ static int slub_min_objects;
90227 * Merge control. If this is set then no merging of slab caches will occur.
90228 * (Could be removed. This was introduced to pacify the merge skeptics.)
90229 */
90230 -static int slub_nomerge;
90231 +static int slub_nomerge = 1;
90232
90233 /*
90234 * Calculate the order of allocation given an slab object size.
90235 @@ -2953,6 +2961,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
90236 s->inuse = size;
90237
90238 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
90239 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
90240 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
90241 +#endif
90242 s->ctor)) {
90243 /*
90244 * Relocate free pointer after the object if it is not
90245 @@ -3298,6 +3309,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
90246 EXPORT_SYMBOL(__kmalloc_node);
90247 #endif
90248
90249 +bool is_usercopy_object(const void *ptr)
90250 +{
90251 + struct page *page;
90252 + struct kmem_cache *s;
90253 +
90254 + if (ZERO_OR_NULL_PTR(ptr))
90255 + return false;
90256 +
90257 + if (!slab_is_available())
90258 + return false;
90259 +
90260 + if (!virt_addr_valid(ptr))
90261 + return false;
90262 +
90263 + page = virt_to_head_page(ptr);
90264 +
90265 + if (!PageSlab(page))
90266 + return false;
90267 +
90268 + s = page->slab_cache;
90269 + return s->flags & SLAB_USERCOPY;
90270 +}
90271 +
90272 +#ifdef CONFIG_PAX_USERCOPY
90273 +const char *check_heap_object(const void *ptr, unsigned long n)
90274 +{
90275 + struct page *page;
90276 + struct kmem_cache *s;
90277 + unsigned long offset;
90278 +
90279 + if (ZERO_OR_NULL_PTR(ptr))
90280 + return "<null>";
90281 +
90282 + if (!virt_addr_valid(ptr))
90283 + return NULL;
90284 +
90285 + page = virt_to_head_page(ptr);
90286 +
90287 + if (!PageSlab(page))
90288 + return NULL;
90289 +
90290 + s = page->slab_cache;
90291 + if (!(s->flags & SLAB_USERCOPY))
90292 + return s->name;
90293 +
90294 + offset = (ptr - page_address(page)) % s->size;
90295 + if (offset <= s->object_size && n <= s->object_size - offset)
90296 + return NULL;
90297 +
90298 + return s->name;
90299 +}
90300 +#endif
90301 +
90302 size_t ksize(const void *object)
90303 {
90304 struct page *page;
90305 @@ -3362,6 +3426,7 @@ void kfree(const void *x)
90306 if (unlikely(ZERO_OR_NULL_PTR(x)))
90307 return;
90308
90309 + VM_BUG_ON(!virt_addr_valid(x));
90310 page = virt_to_head_page(x);
90311 if (unlikely(!PageSlab(page))) {
90312 BUG_ON(!PageCompound(page));
90313 @@ -3667,7 +3732,7 @@ static int slab_unmergeable(struct kmem_cache *s)
90314 /*
90315 * We may have set a slab to be unmergeable during bootstrap.
90316 */
90317 - if (s->refcount < 0)
90318 + if (atomic_read(&s->refcount) < 0)
90319 return 1;
90320
90321 return 0;
90322 @@ -3725,7 +3790,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90323
90324 s = find_mergeable(memcg, size, align, flags, name, ctor);
90325 if (s) {
90326 - s->refcount++;
90327 + atomic_inc(&s->refcount);
90328 /*
90329 * Adjust the object sizes so that we clear
90330 * the complete object on kzalloc.
90331 @@ -3734,7 +3799,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
90332 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
90333
90334 if (sysfs_slab_alias(s, name)) {
90335 - s->refcount--;
90336 + atomic_dec(&s->refcount);
90337 s = NULL;
90338 }
90339 }
90340 @@ -3854,7 +3919,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
90341 }
90342 #endif
90343
90344 -#ifdef CONFIG_SYSFS
90345 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90346 static int count_inuse(struct page *page)
90347 {
90348 return page->inuse;
90349 @@ -4241,12 +4306,12 @@ static void resiliency_test(void)
90350 validate_slab_cache(kmalloc_caches[9]);
90351 }
90352 #else
90353 -#ifdef CONFIG_SYSFS
90354 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90355 static void resiliency_test(void) {};
90356 #endif
90357 #endif
90358
90359 -#ifdef CONFIG_SYSFS
90360 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90361 enum slab_stat_type {
90362 SL_ALL, /* All slabs */
90363 SL_PARTIAL, /* Only partially allocated slabs */
90364 @@ -4490,7 +4555,7 @@ SLAB_ATTR_RO(ctor);
90365
90366 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
90367 {
90368 - return sprintf(buf, "%d\n", s->refcount - 1);
90369 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
90370 }
90371 SLAB_ATTR_RO(aliases);
90372
90373 @@ -4578,6 +4643,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
90374 SLAB_ATTR_RO(cache_dma);
90375 #endif
90376
90377 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90378 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
90379 +{
90380 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
90381 +}
90382 +SLAB_ATTR_RO(usercopy);
90383 +#endif
90384 +
90385 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
90386 {
90387 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
90388 @@ -4912,6 +4985,9 @@ static struct attribute *slab_attrs[] = {
90389 #ifdef CONFIG_ZONE_DMA
90390 &cache_dma_attr.attr,
90391 #endif
90392 +#ifdef CONFIG_PAX_USERCOPY_SLABS
90393 + &usercopy_attr.attr,
90394 +#endif
90395 #ifdef CONFIG_NUMA
90396 &remote_node_defrag_ratio_attr.attr,
90397 #endif
90398 @@ -5143,6 +5219,7 @@ static char *create_unique_id(struct kmem_cache *s)
90399 return name;
90400 }
90401
90402 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90403 static int sysfs_slab_add(struct kmem_cache *s)
90404 {
90405 int err;
90406 @@ -5166,7 +5243,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
90407 }
90408
90409 s->kobj.kset = slab_kset;
90410 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
90411 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
90412 if (err) {
90413 kobject_put(&s->kobj);
90414 return err;
90415 @@ -5200,6 +5277,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
90416 kobject_del(&s->kobj);
90417 kobject_put(&s->kobj);
90418 }
90419 +#endif
90420
90421 /*
90422 * Need to buffer aliases during bootup until sysfs becomes
90423 @@ -5213,6 +5291,7 @@ struct saved_alias {
90424
90425 static struct saved_alias *alias_list;
90426
90427 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
90428 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90429 {
90430 struct saved_alias *al;
90431 @@ -5235,6 +5314,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
90432 alias_list = al;
90433 return 0;
90434 }
90435 +#endif
90436
90437 static int __init slab_sysfs_init(void)
90438 {
90439 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
90440 index 27eeab3..7c3f7f2 100644
90441 --- a/mm/sparse-vmemmap.c
90442 +++ b/mm/sparse-vmemmap.c
90443 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
90444 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90445 if (!p)
90446 return NULL;
90447 - pud_populate(&init_mm, pud, p);
90448 + pud_populate_kernel(&init_mm, pud, p);
90449 }
90450 return pud;
90451 }
90452 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
90453 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
90454 if (!p)
90455 return NULL;
90456 - pgd_populate(&init_mm, pgd, p);
90457 + pgd_populate_kernel(&init_mm, pgd, p);
90458 }
90459 return pgd;
90460 }
90461 diff --git a/mm/sparse.c b/mm/sparse.c
90462 index 308d503..3dbbd04 100644
90463 --- a/mm/sparse.c
90464 +++ b/mm/sparse.c
90465 @@ -764,7 +764,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
90466
90467 for (i = 0; i < PAGES_PER_SECTION; i++) {
90468 if (PageHWPoison(&memmap[i])) {
90469 - atomic_long_sub(1, &num_poisoned_pages);
90470 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
90471 ClearPageHWPoison(&memmap[i]);
90472 }
90473 }
90474 diff --git a/mm/swap.c b/mm/swap.c
90475 index c899502..d4dc2cd 100644
90476 --- a/mm/swap.c
90477 +++ b/mm/swap.c
90478 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
90479
90480 __page_cache_release(page);
90481 dtor = get_compound_page_dtor(page);
90482 + if (!PageHuge(page))
90483 + BUG_ON(dtor != free_compound_page);
90484 (*dtor)(page);
90485 }
90486
90487 diff --git a/mm/swapfile.c b/mm/swapfile.c
90488 index 6cf2e60..d204b3e 100644
90489 --- a/mm/swapfile.c
90490 +++ b/mm/swapfile.c
90491 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
90492
90493 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
90494 /* Activity counter to indicate that a swapon or swapoff has occurred */
90495 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
90496 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
90497
90498 static inline unsigned char swap_count(unsigned char ent)
90499 {
90500 @@ -1699,7 +1699,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
90501 }
90502 filp_close(swap_file, NULL);
90503 err = 0;
90504 - atomic_inc(&proc_poll_event);
90505 + atomic_inc_unchecked(&proc_poll_event);
90506 wake_up_interruptible(&proc_poll_wait);
90507
90508 out_dput:
90509 @@ -1716,8 +1716,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
90510
90511 poll_wait(file, &proc_poll_wait, wait);
90512
90513 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
90514 - seq->poll_event = atomic_read(&proc_poll_event);
90515 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
90516 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90517 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
90518 }
90519
90520 @@ -1815,7 +1815,7 @@ static int swaps_open(struct inode *inode, struct file *file)
90521 return ret;
90522
90523 seq = file->private_data;
90524 - seq->poll_event = atomic_read(&proc_poll_event);
90525 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
90526 return 0;
90527 }
90528
90529 @@ -2203,7 +2203,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
90530 (frontswap_map) ? "FS" : "");
90531
90532 mutex_unlock(&swapon_mutex);
90533 - atomic_inc(&proc_poll_event);
90534 + atomic_inc_unchecked(&proc_poll_event);
90535 wake_up_interruptible(&proc_poll_wait);
90536
90537 if (S_ISREG(inode->i_mode))
90538 diff --git a/mm/util.c b/mm/util.c
90539 index 7441c41..c3de793 100644
90540 --- a/mm/util.c
90541 +++ b/mm/util.c
90542 @@ -294,6 +294,12 @@ done:
90543 void arch_pick_mmap_layout(struct mm_struct *mm)
90544 {
90545 mm->mmap_base = TASK_UNMAPPED_BASE;
90546 +
90547 +#ifdef CONFIG_PAX_RANDMMAP
90548 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90549 + mm->mmap_base += mm->delta_mmap;
90550 +#endif
90551 +
90552 mm->get_unmapped_area = arch_get_unmapped_area;
90553 }
90554 #endif
90555 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
90556 index 13a5495..6707d97 100644
90557 --- a/mm/vmalloc.c
90558 +++ b/mm/vmalloc.c
90559 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
90560
90561 pte = pte_offset_kernel(pmd, addr);
90562 do {
90563 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90564 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90565 +
90566 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90567 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
90568 + BUG_ON(!pte_exec(*pte));
90569 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
90570 + continue;
90571 + }
90572 +#endif
90573 +
90574 + {
90575 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
90576 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
90577 + }
90578 } while (pte++, addr += PAGE_SIZE, addr != end);
90579 }
90580
90581 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
90582 pte = pte_alloc_kernel(pmd, addr);
90583 if (!pte)
90584 return -ENOMEM;
90585 +
90586 + pax_open_kernel();
90587 do {
90588 struct page *page = pages[*nr];
90589
90590 - if (WARN_ON(!pte_none(*pte)))
90591 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90592 + if (pgprot_val(prot) & _PAGE_NX)
90593 +#endif
90594 +
90595 + if (!pte_none(*pte)) {
90596 + pax_close_kernel();
90597 + WARN_ON(1);
90598 return -EBUSY;
90599 - if (WARN_ON(!page))
90600 + }
90601 + if (!page) {
90602 + pax_close_kernel();
90603 + WARN_ON(1);
90604 return -ENOMEM;
90605 + }
90606 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
90607 (*nr)++;
90608 } while (pte++, addr += PAGE_SIZE, addr != end);
90609 + pax_close_kernel();
90610 return 0;
90611 }
90612
90613 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
90614 pmd_t *pmd;
90615 unsigned long next;
90616
90617 - pmd = pmd_alloc(&init_mm, pud, addr);
90618 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
90619 if (!pmd)
90620 return -ENOMEM;
90621 do {
90622 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
90623 pud_t *pud;
90624 unsigned long next;
90625
90626 - pud = pud_alloc(&init_mm, pgd, addr);
90627 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
90628 if (!pud)
90629 return -ENOMEM;
90630 do {
90631 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
90632 if (addr >= MODULES_VADDR && addr < MODULES_END)
90633 return 1;
90634 #endif
90635 +
90636 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
90637 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
90638 + return 1;
90639 +#endif
90640 +
90641 return is_vmalloc_addr(x);
90642 }
90643
90644 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
90645
90646 if (!pgd_none(*pgd)) {
90647 pud_t *pud = pud_offset(pgd, addr);
90648 +#ifdef CONFIG_X86
90649 + if (!pud_large(*pud))
90650 +#endif
90651 if (!pud_none(*pud)) {
90652 pmd_t *pmd = pmd_offset(pud, addr);
90653 +#ifdef CONFIG_X86
90654 + if (!pmd_large(*pmd))
90655 +#endif
90656 if (!pmd_none(*pmd)) {
90657 pte_t *ptep, pte;
90658
90659 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
90660 * Allocate a region of KVA of the specified size and alignment, within the
90661 * vstart and vend.
90662 */
90663 -static struct vmap_area *alloc_vmap_area(unsigned long size,
90664 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
90665 unsigned long align,
90666 unsigned long vstart, unsigned long vend,
90667 int node, gfp_t gfp_mask)
90668 @@ -1308,6 +1344,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
90669 struct vm_struct *area;
90670
90671 BUG_ON(in_interrupt());
90672 +
90673 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90674 + if (flags & VM_KERNEXEC) {
90675 + if (start != VMALLOC_START || end != VMALLOC_END)
90676 + return NULL;
90677 + start = (unsigned long)MODULES_EXEC_VADDR;
90678 + end = (unsigned long)MODULES_EXEC_END;
90679 + }
90680 +#endif
90681 +
90682 if (flags & VM_IOREMAP)
90683 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
90684
90685 @@ -1533,6 +1579,11 @@ void *vmap(struct page **pages, unsigned int count,
90686 if (count > totalram_pages)
90687 return NULL;
90688
90689 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90690 + if (!(pgprot_val(prot) & _PAGE_NX))
90691 + flags |= VM_KERNEXEC;
90692 +#endif
90693 +
90694 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
90695 __builtin_return_address(0));
90696 if (!area)
90697 @@ -1634,6 +1685,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
90698 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
90699 goto fail;
90700
90701 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
90702 + if (!(pgprot_val(prot) & _PAGE_NX))
90703 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
90704 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
90705 + else
90706 +#endif
90707 +
90708 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
90709 start, end, node, gfp_mask, caller);
90710 if (!area)
90711 @@ -1810,10 +1868,9 @@ EXPORT_SYMBOL(vzalloc_node);
90712 * For tight control over page level allocator and protection flags
90713 * use __vmalloc() instead.
90714 */
90715 -
90716 void *vmalloc_exec(unsigned long size)
90717 {
90718 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
90719 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
90720 NUMA_NO_NODE, __builtin_return_address(0));
90721 }
90722
90723 @@ -2120,6 +2177,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
90724 {
90725 struct vm_struct *area;
90726
90727 + BUG_ON(vma->vm_mirror);
90728 +
90729 size = PAGE_ALIGN(size);
90730
90731 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
90732 @@ -2605,7 +2664,11 @@ static int s_show(struct seq_file *m, void *p)
90733 v->addr, v->addr + v->size, v->size);
90734
90735 if (v->caller)
90736 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90737 + seq_printf(m, " %pK", v->caller);
90738 +#else
90739 seq_printf(m, " %pS", v->caller);
90740 +#endif
90741
90742 if (v->nr_pages)
90743 seq_printf(m, " pages=%d", v->nr_pages);
90744 diff --git a/mm/vmstat.c b/mm/vmstat.c
90745 index 20c2ef4..15e7ab7 100644
90746 --- a/mm/vmstat.c
90747 +++ b/mm/vmstat.c
90748 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
90749 *
90750 * vm_stat contains the global counters
90751 */
90752 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90753 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
90754 EXPORT_SYMBOL(vm_stat);
90755
90756 #ifdef CONFIG_SMP
90757 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
90758 v = p->vm_stat_diff[i];
90759 p->vm_stat_diff[i] = 0;
90760 local_irq_restore(flags);
90761 - atomic_long_add(v, &zone->vm_stat[i]);
90762 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90763 global_diff[i] += v;
90764 #ifdef CONFIG_NUMA
90765 /* 3 seconds idle till flush */
90766 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
90767
90768 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
90769 if (global_diff[i])
90770 - atomic_long_add(global_diff[i], &vm_stat[i]);
90771 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
90772 }
90773
90774 /*
90775 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
90776 if (pset->vm_stat_diff[i]) {
90777 int v = pset->vm_stat_diff[i];
90778 pset->vm_stat_diff[i] = 0;
90779 - atomic_long_add(v, &zone->vm_stat[i]);
90780 - atomic_long_add(v, &vm_stat[i]);
90781 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
90782 + atomic_long_add_unchecked(v, &vm_stat[i]);
90783 }
90784 }
90785 #endif
90786 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
90787 start_cpu_timer(cpu);
90788 #endif
90789 #ifdef CONFIG_PROC_FS
90790 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
90791 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
90792 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
90793 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
90794 + {
90795 + mode_t gr_mode = S_IRUGO;
90796 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
90797 + gr_mode = S_IRUSR;
90798 +#endif
90799 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
90800 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
90801 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
90802 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
90803 +#else
90804 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
90805 +#endif
90806 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
90807 + }
90808 #endif
90809 return 0;
90810 }
90811 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
90812 index 2fb2d88..8c06e40 100644
90813 --- a/net/8021q/vlan.c
90814 +++ b/net/8021q/vlan.c
90815 @@ -469,7 +469,7 @@ out:
90816 return NOTIFY_DONE;
90817 }
90818
90819 -static struct notifier_block vlan_notifier_block __read_mostly = {
90820 +static struct notifier_block vlan_notifier_block = {
90821 .notifier_call = vlan_device_event,
90822 };
90823
90824 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
90825 err = -EPERM;
90826 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
90827 break;
90828 - if ((args.u.name_type >= 0) &&
90829 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
90830 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
90831 struct vlan_net *vn;
90832
90833 vn = net_generic(net, vlan_net_id);
90834 diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
90835 index 3091297..c7e634a 100644
90836 --- a/net/8021q/vlan_netlink.c
90837 +++ b/net/8021q/vlan_netlink.c
90838 @@ -171,7 +171,7 @@ static size_t vlan_get_size(const struct net_device *dev)
90839
90840 return nla_total_size(2) + /* IFLA_VLAN_PROTOCOL */
90841 nla_total_size(2) + /* IFLA_VLAN_ID */
90842 - sizeof(struct ifla_vlan_flags) + /* IFLA_VLAN_FLAGS */
90843 + nla_total_size(sizeof(struct ifla_vlan_flags)) + /* IFLA_VLAN_FLAGS */
90844 vlan_qos_map_size(vlan->nr_ingress_mappings) +
90845 vlan_qos_map_size(vlan->nr_egress_mappings);
90846 }
90847 diff --git a/net/9p/mod.c b/net/9p/mod.c
90848 index 6ab36ae..6f1841b 100644
90849 --- a/net/9p/mod.c
90850 +++ b/net/9p/mod.c
90851 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
90852 void v9fs_register_trans(struct p9_trans_module *m)
90853 {
90854 spin_lock(&v9fs_trans_lock);
90855 - list_add_tail(&m->list, &v9fs_trans_list);
90856 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
90857 spin_unlock(&v9fs_trans_lock);
90858 }
90859 EXPORT_SYMBOL(v9fs_register_trans);
90860 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
90861 void v9fs_unregister_trans(struct p9_trans_module *m)
90862 {
90863 spin_lock(&v9fs_trans_lock);
90864 - list_del_init(&m->list);
90865 + pax_list_del_init((struct list_head *)&m->list);
90866 spin_unlock(&v9fs_trans_lock);
90867 }
90868 EXPORT_SYMBOL(v9fs_unregister_trans);
90869 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
90870 index 3ffda1b..fceac96 100644
90871 --- a/net/9p/trans_fd.c
90872 +++ b/net/9p/trans_fd.c
90873 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
90874 oldfs = get_fs();
90875 set_fs(get_ds());
90876 /* The cast to a user pointer is valid due to the set_fs() */
90877 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
90878 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
90879 set_fs(oldfs);
90880
90881 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
90882 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
90883 index 876fbe8..8bbea9f 100644
90884 --- a/net/atm/atm_misc.c
90885 +++ b/net/atm/atm_misc.c
90886 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
90887 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
90888 return 1;
90889 atm_return(vcc, truesize);
90890 - atomic_inc(&vcc->stats->rx_drop);
90891 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90892 return 0;
90893 }
90894 EXPORT_SYMBOL(atm_charge);
90895 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
90896 }
90897 }
90898 atm_return(vcc, guess);
90899 - atomic_inc(&vcc->stats->rx_drop);
90900 + atomic_inc_unchecked(&vcc->stats->rx_drop);
90901 return NULL;
90902 }
90903 EXPORT_SYMBOL(atm_alloc_charge);
90904 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
90905
90906 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90907 {
90908 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90909 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90910 __SONET_ITEMS
90911 #undef __HANDLE_ITEM
90912 }
90913 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
90914
90915 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
90916 {
90917 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90918 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
90919 __SONET_ITEMS
90920 #undef __HANDLE_ITEM
90921 }
90922 diff --git a/net/atm/lec.h b/net/atm/lec.h
90923 index 4149db1..f2ab682 100644
90924 --- a/net/atm/lec.h
90925 +++ b/net/atm/lec.h
90926 @@ -48,7 +48,7 @@ struct lane2_ops {
90927 const u8 *tlvs, u32 sizeoftlvs);
90928 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
90929 const u8 *tlvs, u32 sizeoftlvs);
90930 -};
90931 +} __no_const;
90932
90933 /*
90934 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
90935 diff --git a/net/atm/proc.c b/net/atm/proc.c
90936 index bbb6461..cf04016 100644
90937 --- a/net/atm/proc.c
90938 +++ b/net/atm/proc.c
90939 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
90940 const struct k_atm_aal_stats *stats)
90941 {
90942 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
90943 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
90944 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
90945 - atomic_read(&stats->rx_drop));
90946 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
90947 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
90948 + atomic_read_unchecked(&stats->rx_drop));
90949 }
90950
90951 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
90952 diff --git a/net/atm/resources.c b/net/atm/resources.c
90953 index 0447d5d..3cf4728 100644
90954 --- a/net/atm/resources.c
90955 +++ b/net/atm/resources.c
90956 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
90957 static void copy_aal_stats(struct k_atm_aal_stats *from,
90958 struct atm_aal_stats *to)
90959 {
90960 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
90961 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
90962 __AAL_STAT_ITEMS
90963 #undef __HANDLE_ITEM
90964 }
90965 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
90966 static void subtract_aal_stats(struct k_atm_aal_stats *from,
90967 struct atm_aal_stats *to)
90968 {
90969 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
90970 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
90971 __AAL_STAT_ITEMS
90972 #undef __HANDLE_ITEM
90973 }
90974 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
90975 index 919a5ce..cc6b444 100644
90976 --- a/net/ax25/sysctl_net_ax25.c
90977 +++ b/net/ax25/sysctl_net_ax25.c
90978 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
90979 {
90980 char path[sizeof("net/ax25/") + IFNAMSIZ];
90981 int k;
90982 - struct ctl_table *table;
90983 + ctl_table_no_const *table;
90984
90985 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
90986 if (!table)
90987 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
90988 index 62da527..aa27535 100644
90989 --- a/net/batman-adv/bat_iv_ogm.c
90990 +++ b/net/batman-adv/bat_iv_ogm.c
90991 @@ -120,7 +120,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
90992
90993 /* randomize initial seqno to avoid collision */
90994 get_random_bytes(&random_seqno, sizeof(random_seqno));
90995 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90996 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
90997
90998 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
90999 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
91000 @@ -701,9 +701,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
91001 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
91002
91003 /* change sequence number to network order */
91004 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
91005 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
91006 batadv_ogm_packet->seqno = htonl(seqno);
91007 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
91008 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
91009
91010 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
91011 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
91012 @@ -1109,7 +1109,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
91013 return;
91014
91015 /* could be changed by schedule_own_packet() */
91016 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
91017 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
91018
91019 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
91020 has_directlink_flag = 1;
91021 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
91022 index c478e6b..469fd2f 100644
91023 --- a/net/batman-adv/hard-interface.c
91024 +++ b/net/batman-adv/hard-interface.c
91025 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
91026 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
91027 dev_add_pack(&hard_iface->batman_adv_ptype);
91028
91029 - atomic_set(&hard_iface->frag_seqno, 1);
91030 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
91031 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
91032 hard_iface->net_dev->name);
91033
91034 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
91035 index 33b6144..3212ac5 100644
91036 --- a/net/batman-adv/soft-interface.c
91037 +++ b/net/batman-adv/soft-interface.c
91038 @@ -261,7 +261,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
91039 primary_if->net_dev->dev_addr, ETH_ALEN);
91040
91041 /* set broadcast sequence number */
91042 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
91043 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
91044 bcast_packet->seqno = htonl(seqno);
91045
91046 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
91047 @@ -481,7 +481,7 @@ static int batadv_softif_init_late(struct net_device *dev)
91048 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
91049
91050 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
91051 - atomic_set(&bat_priv->bcast_seqno, 1);
91052 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
91053 atomic_set(&bat_priv->tt.vn, 0);
91054 atomic_set(&bat_priv->tt.local_changes, 0);
91055 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
91056 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
91057 index b2c94e1..3d47e07 100644
91058 --- a/net/batman-adv/types.h
91059 +++ b/net/batman-adv/types.h
91060 @@ -51,7 +51,7 @@
91061 struct batadv_hard_iface_bat_iv {
91062 unsigned char *ogm_buff;
91063 int ogm_buff_len;
91064 - atomic_t ogm_seqno;
91065 + atomic_unchecked_t ogm_seqno;
91066 };
91067
91068 /**
91069 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
91070 int16_t if_num;
91071 char if_status;
91072 struct net_device *net_dev;
91073 - atomic_t frag_seqno;
91074 + atomic_unchecked_t frag_seqno;
91075 uint8_t num_bcasts;
91076 struct kobject *hardif_obj;
91077 atomic_t refcount;
91078 @@ -560,7 +560,7 @@ struct batadv_priv {
91079 #ifdef CONFIG_BATMAN_ADV_DEBUG
91080 atomic_t log_level;
91081 #endif
91082 - atomic_t bcast_seqno;
91083 + atomic_unchecked_t bcast_seqno;
91084 atomic_t bcast_queue_left;
91085 atomic_t batman_queue_left;
91086 char num_ifaces;
91087 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
91088 index 857e1b8..5ad07b2 100644
91089 --- a/net/batman-adv/unicast.c
91090 +++ b/net/batman-adv/unicast.c
91091 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
91092 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
91093 frag2->flags = large_tail;
91094
91095 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
91096 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
91097 frag1->seqno = htons(seqno - 1);
91098 frag2->seqno = htons(seqno);
91099
91100 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
91101 index 9bd7d95..6c4884f 100644
91102 --- a/net/bluetooth/hci_sock.c
91103 +++ b/net/bluetooth/hci_sock.c
91104 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
91105 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
91106 }
91107
91108 - len = min_t(unsigned int, len, sizeof(uf));
91109 + len = min((size_t)len, sizeof(uf));
91110 if (copy_from_user(&uf, optval, len)) {
91111 err = -EFAULT;
91112 break;
91113 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
91114 index 8c3499b..2661c6a 100644
91115 --- a/net/bluetooth/l2cap_core.c
91116 +++ b/net/bluetooth/l2cap_core.c
91117 @@ -3510,8 +3510,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
91118 break;
91119
91120 case L2CAP_CONF_RFC:
91121 - if (olen == sizeof(rfc))
91122 - memcpy(&rfc, (void *)val, olen);
91123 + if (olen != sizeof(rfc))
91124 + break;
91125 +
91126 + memcpy(&rfc, (void *)val, olen);
91127
91128 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
91129 rfc.mode != chan->mode)
91130 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
91131 index 0098af8..fb5a31f 100644
91132 --- a/net/bluetooth/l2cap_sock.c
91133 +++ b/net/bluetooth/l2cap_sock.c
91134 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91135 struct sock *sk = sock->sk;
91136 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
91137 struct l2cap_options opts;
91138 - int len, err = 0;
91139 + int err = 0;
91140 + size_t len = optlen;
91141 u32 opt;
91142
91143 BT_DBG("sk %p", sk);
91144 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
91145 opts.max_tx = chan->max_tx;
91146 opts.txwin_size = chan->tx_win;
91147
91148 - len = min_t(unsigned int, sizeof(opts), optlen);
91149 + len = min(sizeof(opts), len);
91150 if (copy_from_user((char *) &opts, optval, len)) {
91151 err = -EFAULT;
91152 break;
91153 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91154 struct bt_security sec;
91155 struct bt_power pwr;
91156 struct l2cap_conn *conn;
91157 - int len, err = 0;
91158 + int err = 0;
91159 + size_t len = optlen;
91160 u32 opt;
91161
91162 BT_DBG("sk %p", sk);
91163 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91164
91165 sec.level = BT_SECURITY_LOW;
91166
91167 - len = min_t(unsigned int, sizeof(sec), optlen);
91168 + len = min(sizeof(sec), len);
91169 if (copy_from_user((char *) &sec, optval, len)) {
91170 err = -EFAULT;
91171 break;
91172 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
91173
91174 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
91175
91176 - len = min_t(unsigned int, sizeof(pwr), optlen);
91177 + len = min(sizeof(pwr), len);
91178 if (copy_from_user((char *) &pwr, optval, len)) {
91179 err = -EFAULT;
91180 break;
91181 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
91182 index 30b3721..c1bd0a0 100644
91183 --- a/net/bluetooth/rfcomm/sock.c
91184 +++ b/net/bluetooth/rfcomm/sock.c
91185 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91186 struct sock *sk = sock->sk;
91187 struct bt_security sec;
91188 int err = 0;
91189 - size_t len;
91190 + size_t len = optlen;
91191 u32 opt;
91192
91193 BT_DBG("sk %p", sk);
91194 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
91195
91196 sec.level = BT_SECURITY_LOW;
91197
91198 - len = min_t(unsigned int, sizeof(sec), optlen);
91199 + len = min(sizeof(sec), len);
91200 if (copy_from_user((char *) &sec, optval, len)) {
91201 err = -EFAULT;
91202 break;
91203 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
91204 index b6e44ad..5b0d514 100644
91205 --- a/net/bluetooth/rfcomm/tty.c
91206 +++ b/net/bluetooth/rfcomm/tty.c
91207 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
91208 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
91209
91210 spin_lock_irqsave(&dev->port.lock, flags);
91211 - if (dev->port.count > 0) {
91212 + if (atomic_read(&dev->port.count) > 0) {
91213 spin_unlock_irqrestore(&dev->port.lock, flags);
91214 return;
91215 }
91216 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
91217 return -ENODEV;
91218
91219 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
91220 - dev->channel, dev->port.count);
91221 + dev->channel, atomic_read(&dev->port.count));
91222
91223 spin_lock_irqsave(&dev->port.lock, flags);
91224 - if (++dev->port.count > 1) {
91225 + if (atomic_inc_return(&dev->port.count) > 1) {
91226 spin_unlock_irqrestore(&dev->port.lock, flags);
91227 return 0;
91228 }
91229 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
91230 return;
91231
91232 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
91233 - dev->port.count);
91234 + atomic_read(&dev->port.count));
91235
91236 spin_lock_irqsave(&dev->port.lock, flags);
91237 - if (!--dev->port.count) {
91238 + if (!atomic_dec_return(&dev->port.count)) {
91239 spin_unlock_irqrestore(&dev->port.lock, flags);
91240 if (dev->tty_dev->parent)
91241 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
91242 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
91243 index 5180938..7c470c3 100644
91244 --- a/net/bridge/netfilter/ebt_ulog.c
91245 +++ b/net/bridge/netfilter/ebt_ulog.c
91246 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91247 ub->qlen++;
91248
91249 pm = nlmsg_data(nlh);
91250 + memset(pm, 0, sizeof(*pm));
91251
91252 /* Fill in the ulog data */
91253 pm->version = EBT_ULOG_VERSION;
91254 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91255 pm->hook = hooknr;
91256 if (uloginfo->prefix != NULL)
91257 strcpy(pm->prefix, uloginfo->prefix);
91258 - else
91259 - *(pm->prefix) = '\0';
91260
91261 if (in) {
91262 strcpy(pm->physindev, in->name);
91263 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
91264 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
91265 else
91266 strcpy(pm->indev, in->name);
91267 - } else
91268 - pm->indev[0] = pm->physindev[0] = '\0';
91269 + }
91270
91271 if (out) {
91272 /* If out exists, then out is a bridge port */
91273 strcpy(pm->physoutdev, out->name);
91274 /* rcu_read_lock()ed by nf_hook_slow */
91275 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
91276 - } else
91277 - pm->outdev[0] = pm->physoutdev[0] = '\0';
91278 + }
91279
91280 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
91281 BUG();
91282 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
91283 index ac78024..161a80c 100644
91284 --- a/net/bridge/netfilter/ebtables.c
91285 +++ b/net/bridge/netfilter/ebtables.c
91286 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91287 tmp.valid_hooks = t->table->valid_hooks;
91288 }
91289 mutex_unlock(&ebt_mutex);
91290 - if (copy_to_user(user, &tmp, *len) != 0){
91291 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
91292 BUGPRINT("c2u Didn't work\n");
91293 ret = -EFAULT;
91294 break;
91295 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91296 goto out;
91297 tmp.valid_hooks = t->valid_hooks;
91298
91299 - if (copy_to_user(user, &tmp, *len) != 0) {
91300 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91301 ret = -EFAULT;
91302 break;
91303 }
91304 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
91305 tmp.entries_size = t->table->entries_size;
91306 tmp.valid_hooks = t->table->valid_hooks;
91307
91308 - if (copy_to_user(user, &tmp, *len) != 0) {
91309 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
91310 ret = -EFAULT;
91311 break;
91312 }
91313 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
91314 index 0f45522..dab651f 100644
91315 --- a/net/caif/cfctrl.c
91316 +++ b/net/caif/cfctrl.c
91317 @@ -10,6 +10,7 @@
91318 #include <linux/spinlock.h>
91319 #include <linux/slab.h>
91320 #include <linux/pkt_sched.h>
91321 +#include <linux/sched.h>
91322 #include <net/caif/caif_layer.h>
91323 #include <net/caif/cfpkt.h>
91324 #include <net/caif/cfctrl.h>
91325 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
91326 memset(&dev_info, 0, sizeof(dev_info));
91327 dev_info.id = 0xff;
91328 cfsrvl_init(&this->serv, 0, &dev_info, false);
91329 - atomic_set(&this->req_seq_no, 1);
91330 - atomic_set(&this->rsp_seq_no, 1);
91331 + atomic_set_unchecked(&this->req_seq_no, 1);
91332 + atomic_set_unchecked(&this->rsp_seq_no, 1);
91333 this->serv.layer.receive = cfctrl_recv;
91334 sprintf(this->serv.layer.name, "ctrl");
91335 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
91336 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
91337 struct cfctrl_request_info *req)
91338 {
91339 spin_lock_bh(&ctrl->info_list_lock);
91340 - atomic_inc(&ctrl->req_seq_no);
91341 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
91342 + atomic_inc_unchecked(&ctrl->req_seq_no);
91343 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
91344 list_add_tail(&req->list, &ctrl->list);
91345 spin_unlock_bh(&ctrl->info_list_lock);
91346 }
91347 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
91348 if (p != first)
91349 pr_warn("Requests are not received in order\n");
91350
91351 - atomic_set(&ctrl->rsp_seq_no,
91352 + atomic_set_unchecked(&ctrl->rsp_seq_no,
91353 p->sequence_no);
91354 list_del(&p->list);
91355 goto out;
91356 diff --git a/net/can/af_can.c b/net/can/af_can.c
91357 index 3ab8dd2..b9aef13 100644
91358 --- a/net/can/af_can.c
91359 +++ b/net/can/af_can.c
91360 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
91361 };
91362
91363 /* notifier block for netdevice event */
91364 -static struct notifier_block can_netdev_notifier __read_mostly = {
91365 +static struct notifier_block can_netdev_notifier = {
91366 .notifier_call = can_notifier,
91367 };
91368
91369 diff --git a/net/can/gw.c b/net/can/gw.c
91370 index 2f291f9..98c986a 100644
91371 --- a/net/can/gw.c
91372 +++ b/net/can/gw.c
91373 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
91374 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
91375
91376 static HLIST_HEAD(cgw_list);
91377 -static struct notifier_block notifier;
91378
91379 static struct kmem_cache *cgw_cache __read_mostly;
91380
91381 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
91382 return err;
91383 }
91384
91385 +static struct notifier_block notifier = {
91386 + .notifier_call = cgw_notifier
91387 +};
91388 +
91389 static __init int cgw_module_init(void)
91390 {
91391 /* sanitize given module parameter */
91392 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
91393 return -ENOMEM;
91394
91395 /* set notifier */
91396 - notifier.notifier_call = cgw_notifier;
91397 register_netdevice_notifier(&notifier);
91398
91399 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
91400 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
91401 index eb0a46a..5f3bae8 100644
91402 --- a/net/ceph/messenger.c
91403 +++ b/net/ceph/messenger.c
91404 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
91405 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
91406
91407 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
91408 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
91409 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
91410
91411 static struct page *zero_page; /* used in certain error cases */
91412
91413 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
91414 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
91415 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
91416
91417 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91418 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
91419 s = addr_str[i];
91420
91421 switch (ss->ss_family) {
91422 diff --git a/net/compat.c b/net/compat.c
91423 index f0a1ba6..24e30e5 100644
91424 --- a/net/compat.c
91425 +++ b/net/compat.c
91426 @@ -71,9 +71,11 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
91427 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
91428 __get_user(kmsg->msg_flags, &umsg->msg_flags))
91429 return -EFAULT;
91430 - kmsg->msg_name = compat_ptr(tmp1);
91431 - kmsg->msg_iov = compat_ptr(tmp2);
91432 - kmsg->msg_control = compat_ptr(tmp3);
91433 + if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
91434 + return -EINVAL;
91435 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
91436 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
91437 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
91438 return 0;
91439 }
91440
91441 @@ -85,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91442
91443 if (kern_msg->msg_namelen) {
91444 if (mode == VERIFY_READ) {
91445 - int err = move_addr_to_kernel(kern_msg->msg_name,
91446 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
91447 kern_msg->msg_namelen,
91448 kern_address);
91449 if (err < 0)
91450 @@ -96,7 +98,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91451 kern_msg->msg_name = NULL;
91452
91453 tot_len = iov_from_user_compat_to_kern(kern_iov,
91454 - (struct compat_iovec __user *)kern_msg->msg_iov,
91455 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
91456 kern_msg->msg_iovlen);
91457 if (tot_len >= 0)
91458 kern_msg->msg_iov = kern_iov;
91459 @@ -116,20 +118,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
91460
91461 #define CMSG_COMPAT_FIRSTHDR(msg) \
91462 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
91463 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
91464 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
91465 (struct compat_cmsghdr __user *)NULL)
91466
91467 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
91468 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
91469 (ucmlen) <= (unsigned long) \
91470 ((mhdr)->msg_controllen - \
91471 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
91472 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
91473
91474 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
91475 struct compat_cmsghdr __user *cmsg, int cmsg_len)
91476 {
91477 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
91478 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
91479 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
91480 msg->msg_controllen)
91481 return NULL;
91482 return (struct compat_cmsghdr __user *)ptr;
91483 @@ -219,7 +221,7 @@ Efault:
91484
91485 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
91486 {
91487 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91488 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91489 struct compat_cmsghdr cmhdr;
91490 struct compat_timeval ctv;
91491 struct compat_timespec cts[3];
91492 @@ -275,7 +277,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
91493
91494 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
91495 {
91496 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
91497 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
91498 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
91499 int fdnum = scm->fp->count;
91500 struct file **fp = scm->fp->fp;
91501 @@ -363,7 +365,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
91502 return -EFAULT;
91503 old_fs = get_fs();
91504 set_fs(KERNEL_DS);
91505 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
91506 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
91507 set_fs(old_fs);
91508
91509 return err;
91510 @@ -424,7 +426,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
91511 len = sizeof(ktime);
91512 old_fs = get_fs();
91513 set_fs(KERNEL_DS);
91514 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
91515 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
91516 set_fs(old_fs);
91517
91518 if (!err) {
91519 @@ -567,7 +569,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91520 case MCAST_JOIN_GROUP:
91521 case MCAST_LEAVE_GROUP:
91522 {
91523 - struct compat_group_req __user *gr32 = (void *)optval;
91524 + struct compat_group_req __user *gr32 = (void __user *)optval;
91525 struct group_req __user *kgr =
91526 compat_alloc_user_space(sizeof(struct group_req));
91527 u32 interface;
91528 @@ -588,7 +590,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91529 case MCAST_BLOCK_SOURCE:
91530 case MCAST_UNBLOCK_SOURCE:
91531 {
91532 - struct compat_group_source_req __user *gsr32 = (void *)optval;
91533 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
91534 struct group_source_req __user *kgsr = compat_alloc_user_space(
91535 sizeof(struct group_source_req));
91536 u32 interface;
91537 @@ -609,7 +611,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
91538 }
91539 case MCAST_MSFILTER:
91540 {
91541 - struct compat_group_filter __user *gf32 = (void *)optval;
91542 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91543 struct group_filter __user *kgf;
91544 u32 interface, fmode, numsrc;
91545
91546 @@ -647,7 +649,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
91547 char __user *optval, int __user *optlen,
91548 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
91549 {
91550 - struct compat_group_filter __user *gf32 = (void *)optval;
91551 + struct compat_group_filter __user *gf32 = (void __user *)optval;
91552 struct group_filter __user *kgf;
91553 int __user *koptlen;
91554 u32 interface, fmode, numsrc;
91555 @@ -805,7 +807,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
91556
91557 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
91558 return -EINVAL;
91559 - if (copy_from_user(a, args, nas[call]))
91560 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
91561 return -EFAULT;
91562 a0 = a[0];
91563 a1 = a[1];
91564 diff --git a/net/core/datagram.c b/net/core/datagram.c
91565 index 8ab48cd..57b1a80 100644
91566 --- a/net/core/datagram.c
91567 +++ b/net/core/datagram.c
91568 @@ -300,7 +300,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
91569 }
91570
91571 kfree_skb(skb);
91572 - atomic_inc(&sk->sk_drops);
91573 + atomic_inc_unchecked(&sk->sk_drops);
91574 sk_mem_reclaim_partial(sk);
91575
91576 return err;
91577 diff --git a/net/core/dev.c b/net/core/dev.c
91578 index 26755dd..2a232de 100644
91579 --- a/net/core/dev.c
91580 +++ b/net/core/dev.c
91581 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
91582 {
91583 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
91584 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
91585 - atomic_long_inc(&dev->rx_dropped);
91586 + atomic_long_inc_unchecked(&dev->rx_dropped);
91587 kfree_skb(skb);
91588 return NET_RX_DROP;
91589 }
91590 }
91591
91592 if (unlikely(!is_skb_forwardable(dev, skb))) {
91593 - atomic_long_inc(&dev->rx_dropped);
91594 + atomic_long_inc_unchecked(&dev->rx_dropped);
91595 kfree_skb(skb);
91596 return NET_RX_DROP;
91597 }
91598 @@ -2431,7 +2431,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
91599
91600 struct dev_gso_cb {
91601 void (*destructor)(struct sk_buff *skb);
91602 -};
91603 +} __no_const;
91604
91605 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
91606
91607 @@ -3206,7 +3206,7 @@ enqueue:
91608
91609 local_irq_restore(flags);
91610
91611 - atomic_long_inc(&skb->dev->rx_dropped);
91612 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91613 kfree_skb(skb);
91614 return NET_RX_DROP;
91615 }
91616 @@ -3278,7 +3278,7 @@ int netif_rx_ni(struct sk_buff *skb)
91617 }
91618 EXPORT_SYMBOL(netif_rx_ni);
91619
91620 -static void net_tx_action(struct softirq_action *h)
91621 +static __latent_entropy void net_tx_action(void)
91622 {
91623 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91624
91625 @@ -3612,7 +3612,7 @@ ncls:
91626 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
91627 } else {
91628 drop:
91629 - atomic_long_inc(&skb->dev->rx_dropped);
91630 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
91631 kfree_skb(skb);
91632 /* Jamal, now you will not able to escape explaining
91633 * me how you were going to use this. :-)
91634 @@ -4272,7 +4272,7 @@ void netif_napi_del(struct napi_struct *napi)
91635 }
91636 EXPORT_SYMBOL(netif_napi_del);
91637
91638 -static void net_rx_action(struct softirq_action *h)
91639 +static __latent_entropy void net_rx_action(void)
91640 {
91641 struct softnet_data *sd = &__get_cpu_var(softnet_data);
91642 unsigned long time_limit = jiffies + 2;
91643 @@ -5730,7 +5730,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
91644 } else {
91645 netdev_stats_to_stats64(storage, &dev->stats);
91646 }
91647 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
91648 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
91649 return storage;
91650 }
91651 EXPORT_SYMBOL(dev_get_stats);
91652 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
91653 index 5b7d0e1..cb960fc 100644
91654 --- a/net/core/dev_ioctl.c
91655 +++ b/net/core/dev_ioctl.c
91656 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
91657 if (no_module && capable(CAP_NET_ADMIN))
91658 no_module = request_module("netdev-%s", name);
91659 if (no_module && capable(CAP_SYS_MODULE)) {
91660 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
91661 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
91662 +#else
91663 if (!request_module("%s", name))
91664 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
91665 name);
91666 +#endif
91667 }
91668 }
91669 EXPORT_SYMBOL(dev_load);
91670 diff --git a/net/core/flow.c b/net/core/flow.c
91671 index dfa602c..3103d88 100644
91672 --- a/net/core/flow.c
91673 +++ b/net/core/flow.c
91674 @@ -61,7 +61,7 @@ struct flow_cache {
91675 struct timer_list rnd_timer;
91676 };
91677
91678 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
91679 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
91680 EXPORT_SYMBOL(flow_cache_genid);
91681 static struct flow_cache flow_cache_global;
91682 static struct kmem_cache *flow_cachep __read_mostly;
91683 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
91684
91685 static int flow_entry_valid(struct flow_cache_entry *fle)
91686 {
91687 - if (atomic_read(&flow_cache_genid) != fle->genid)
91688 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
91689 return 0;
91690 if (fle->object && !fle->object->ops->check(fle->object))
91691 return 0;
91692 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
91693 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
91694 fcp->hash_count++;
91695 }
91696 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
91697 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
91698 flo = fle->object;
91699 if (!flo)
91700 goto ret_object;
91701 @@ -279,7 +279,7 @@ nocache:
91702 }
91703 flo = resolver(net, key, family, dir, flo, ctx);
91704 if (fle) {
91705 - fle->genid = atomic_read(&flow_cache_genid);
91706 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
91707 if (!IS_ERR(flo))
91708 fle->object = flo;
91709 else
91710 diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
91711 index 52d0f83..4a1d064 100644
91712 --- a/net/core/flow_dissector.c
91713 +++ b/net/core/flow_dissector.c
91714 @@ -40,7 +40,7 @@ again:
91715 struct iphdr _iph;
91716 ip:
91717 iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph);
91718 - if (!iph)
91719 + if (!iph || iph->ihl < 5)
91720 return false;
91721
91722 if (ip_is_fragment(iph))
91723 diff --git a/net/core/iovec.c b/net/core/iovec.c
91724 index de178e4..1dabd8b 100644
91725 --- a/net/core/iovec.c
91726 +++ b/net/core/iovec.c
91727 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91728 if (m->msg_namelen) {
91729 if (mode == VERIFY_READ) {
91730 void __user *namep;
91731 - namep = (void __user __force *) m->msg_name;
91732 + namep = (void __force_user *) m->msg_name;
91733 err = move_addr_to_kernel(namep, m->msg_namelen,
91734 address);
91735 if (err < 0)
91736 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
91737 }
91738
91739 size = m->msg_iovlen * sizeof(struct iovec);
91740 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
91741 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
91742 return -EFAULT;
91743
91744 m->msg_iov = iov;
91745 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
91746 index 60533db..14842cc 100644
91747 --- a/net/core/neighbour.c
91748 +++ b/net/core/neighbour.c
91749 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
91750 void __user *buffer, size_t *lenp, loff_t *ppos)
91751 {
91752 int size, ret;
91753 - struct ctl_table tmp = *ctl;
91754 + ctl_table_no_const tmp = *ctl;
91755
91756 tmp.extra1 = &zero;
91757 tmp.extra2 = &unres_qlen_max;
91758 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
91759 index 2bf8329..7960607 100644
91760 --- a/net/core/net-procfs.c
91761 +++ b/net/core/net-procfs.c
91762 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
91763 else
91764 seq_printf(seq, "%04x", ntohs(pt->type));
91765
91766 +#ifdef CONFIG_GRKERNSEC_HIDESYM
91767 + seq_printf(seq, " %-8s %pf\n",
91768 + pt->dev ? pt->dev->name : "", NULL);
91769 +#else
91770 seq_printf(seq, " %-8s %pf\n",
91771 pt->dev ? pt->dev->name : "", pt->func);
91772 +#endif
91773 }
91774
91775 return 0;
91776 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
91777 index 981fed3..536af34 100644
91778 --- a/net/core/net-sysfs.c
91779 +++ b/net/core/net-sysfs.c
91780 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
91781 }
91782 EXPORT_SYMBOL(netdev_class_remove_file);
91783
91784 -int netdev_kobject_init(void)
91785 +int __init netdev_kobject_init(void)
91786 {
91787 kobj_ns_type_register(&net_ns_type_operations);
91788 return class_register(&net_class);
91789 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
91790 index f9765203..9feaef8 100644
91791 --- a/net/core/net_namespace.c
91792 +++ b/net/core/net_namespace.c
91793 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
91794 int error;
91795 LIST_HEAD(net_exit_list);
91796
91797 - list_add_tail(&ops->list, list);
91798 + pax_list_add_tail((struct list_head *)&ops->list, list);
91799 if (ops->init || (ops->id && ops->size)) {
91800 for_each_net(net) {
91801 error = ops_init(ops, net);
91802 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
91803
91804 out_undo:
91805 /* If I have an error cleanup all namespaces I initialized */
91806 - list_del(&ops->list);
91807 + pax_list_del((struct list_head *)&ops->list);
91808 ops_exit_list(ops, &net_exit_list);
91809 ops_free_list(ops, &net_exit_list);
91810 return error;
91811 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
91812 struct net *net;
91813 LIST_HEAD(net_exit_list);
91814
91815 - list_del(&ops->list);
91816 + pax_list_del((struct list_head *)&ops->list);
91817 for_each_net(net)
91818 list_add_tail(&net->exit_list, &net_exit_list);
91819 ops_exit_list(ops, &net_exit_list);
91820 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
91821 mutex_lock(&net_mutex);
91822 error = register_pernet_operations(&pernet_list, ops);
91823 if (!error && (first_device == &pernet_list))
91824 - first_device = &ops->list;
91825 + first_device = (struct list_head *)&ops->list;
91826 mutex_unlock(&net_mutex);
91827 return error;
91828 }
91829 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
91830 index fc75c9e..8c8e9be 100644
91831 --- a/net/core/netpoll.c
91832 +++ b/net/core/netpoll.c
91833 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91834 struct udphdr *udph;
91835 struct iphdr *iph;
91836 struct ethhdr *eth;
91837 - static atomic_t ip_ident;
91838 + static atomic_unchecked_t ip_ident;
91839 struct ipv6hdr *ip6h;
91840
91841 udp_len = len + sizeof(*udph);
91842 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
91843 put_unaligned(0x45, (unsigned char *)iph);
91844 iph->tos = 0;
91845 put_unaligned(htons(ip_len), &(iph->tot_len));
91846 - iph->id = htons(atomic_inc_return(&ip_ident));
91847 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
91848 iph->frag_off = 0;
91849 iph->ttl = 64;
91850 iph->protocol = IPPROTO_UDP;
91851 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
91852 index ca198c1d1..125372f 100644
91853 --- a/net/core/rtnetlink.c
91854 +++ b/net/core/rtnetlink.c
91855 @@ -58,7 +58,7 @@ struct rtnl_link {
91856 rtnl_doit_func doit;
91857 rtnl_dumpit_func dumpit;
91858 rtnl_calcit_func calcit;
91859 -};
91860 +} __no_const;
91861
91862 static DEFINE_MUTEX(rtnl_mutex);
91863
91864 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
91865 if (rtnl_link_ops_get(ops->kind))
91866 return -EEXIST;
91867
91868 - if (!ops->dellink)
91869 - ops->dellink = unregister_netdevice_queue;
91870 + if (!ops->dellink) {
91871 + pax_open_kernel();
91872 + *(void **)&ops->dellink = unregister_netdevice_queue;
91873 + pax_close_kernel();
91874 + }
91875
91876 - list_add_tail(&ops->list, &link_ops);
91877 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
91878 return 0;
91879 }
91880 EXPORT_SYMBOL_GPL(__rtnl_link_register);
91881 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
91882 for_each_net(net) {
91883 __rtnl_kill_links(net, ops);
91884 }
91885 - list_del(&ops->list);
91886 + pax_list_del((struct list_head *)&ops->list);
91887 }
91888 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
91889
91890 diff --git a/net/core/scm.c b/net/core/scm.c
91891 index b4da80b..98d6bdb 100644
91892 --- a/net/core/scm.c
91893 +++ b/net/core/scm.c
91894 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
91895 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91896 {
91897 struct cmsghdr __user *cm
91898 - = (__force struct cmsghdr __user *)msg->msg_control;
91899 + = (struct cmsghdr __force_user *)msg->msg_control;
91900 struct cmsghdr cmhdr;
91901 int cmlen = CMSG_LEN(len);
91902 int err;
91903 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
91904 err = -EFAULT;
91905 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
91906 goto out;
91907 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
91908 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
91909 goto out;
91910 cmlen = CMSG_SPACE(len);
91911 if (msg->msg_controllen < cmlen)
91912 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
91913 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91914 {
91915 struct cmsghdr __user *cm
91916 - = (__force struct cmsghdr __user*)msg->msg_control;
91917 + = (struct cmsghdr __force_user *)msg->msg_control;
91918
91919 int fdmax = 0;
91920 int fdnum = scm->fp->count;
91921 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
91922 if (fdnum < fdmax)
91923 fdmax = fdnum;
91924
91925 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
91926 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
91927 i++, cmfptr++)
91928 {
91929 struct socket *sock;
91930 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
91931 index 2c3d0f5..f5a326f 100644
91932 --- a/net/core/skbuff.c
91933 +++ b/net/core/skbuff.c
91934 @@ -3082,13 +3082,15 @@ void __init skb_init(void)
91935 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
91936 sizeof(struct sk_buff),
91937 0,
91938 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91939 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91940 + SLAB_NO_SANITIZE,
91941 NULL);
91942 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
91943 (2*sizeof(struct sk_buff)) +
91944 sizeof(atomic_t),
91945 0,
91946 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
91947 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
91948 + SLAB_NO_SANITIZE,
91949 NULL);
91950 }
91951
91952 diff --git a/net/core/sock.c b/net/core/sock.c
91953 index 2c097c5..bf72858 100644
91954 --- a/net/core/sock.c
91955 +++ b/net/core/sock.c
91956 @@ -392,7 +392,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91957 struct sk_buff_head *list = &sk->sk_receive_queue;
91958
91959 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
91960 - atomic_inc(&sk->sk_drops);
91961 + atomic_inc_unchecked(&sk->sk_drops);
91962 trace_sock_rcvqueue_full(sk, skb);
91963 return -ENOMEM;
91964 }
91965 @@ -402,7 +402,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91966 return err;
91967
91968 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
91969 - atomic_inc(&sk->sk_drops);
91970 + atomic_inc_unchecked(&sk->sk_drops);
91971 return -ENOBUFS;
91972 }
91973
91974 @@ -422,7 +422,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
91975 skb_dst_force(skb);
91976
91977 spin_lock_irqsave(&list->lock, flags);
91978 - skb->dropcount = atomic_read(&sk->sk_drops);
91979 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
91980 __skb_queue_tail(list, skb);
91981 spin_unlock_irqrestore(&list->lock, flags);
91982
91983 @@ -442,7 +442,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91984 skb->dev = NULL;
91985
91986 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
91987 - atomic_inc(&sk->sk_drops);
91988 + atomic_inc_unchecked(&sk->sk_drops);
91989 goto discard_and_relse;
91990 }
91991 if (nested)
91992 @@ -460,7 +460,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
91993 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
91994 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
91995 bh_unlock_sock(sk);
91996 - atomic_inc(&sk->sk_drops);
91997 + atomic_inc_unchecked(&sk->sk_drops);
91998 goto discard_and_relse;
91999 }
92000
92001 @@ -948,12 +948,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92002 struct timeval tm;
92003 } v;
92004
92005 - int lv = sizeof(int);
92006 - int len;
92007 + unsigned int lv = sizeof(int);
92008 + unsigned int len;
92009
92010 if (get_user(len, optlen))
92011 return -EFAULT;
92012 - if (len < 0)
92013 + if (len > INT_MAX)
92014 return -EINVAL;
92015
92016 memset(&v, 0, sizeof(v));
92017 @@ -1105,11 +1105,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92018
92019 case SO_PEERNAME:
92020 {
92021 - char address[128];
92022 + char address[_K_SS_MAXSIZE];
92023
92024 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
92025 return -ENOTCONN;
92026 - if (lv < len)
92027 + if (lv < len || sizeof address < len)
92028 return -EINVAL;
92029 if (copy_to_user(optval, address, len))
92030 return -EFAULT;
92031 @@ -1182,7 +1182,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
92032
92033 if (len > lv)
92034 len = lv;
92035 - if (copy_to_user(optval, &v, len))
92036 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
92037 return -EFAULT;
92038 lenout:
92039 if (put_user(len, optlen))
92040 @@ -2303,7 +2303,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
92041 */
92042 smp_wmb();
92043 atomic_set(&sk->sk_refcnt, 1);
92044 - atomic_set(&sk->sk_drops, 0);
92045 + atomic_set_unchecked(&sk->sk_drops, 0);
92046 }
92047 EXPORT_SYMBOL(sock_init_data);
92048
92049 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
92050 index a0e9cf6..ef7f9ed 100644
92051 --- a/net/core/sock_diag.c
92052 +++ b/net/core/sock_diag.c
92053 @@ -9,26 +9,33 @@
92054 #include <linux/inet_diag.h>
92055 #include <linux/sock_diag.h>
92056
92057 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
92058 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
92059 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
92060 static DEFINE_MUTEX(sock_diag_table_mutex);
92061
92062 int sock_diag_check_cookie(void *sk, __u32 *cookie)
92063 {
92064 +#ifndef CONFIG_GRKERNSEC_HIDESYM
92065 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
92066 cookie[1] != INET_DIAG_NOCOOKIE) &&
92067 ((u32)(unsigned long)sk != cookie[0] ||
92068 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
92069 return -ESTALE;
92070 else
92071 +#endif
92072 return 0;
92073 }
92074 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
92075
92076 void sock_diag_save_cookie(void *sk, __u32 *cookie)
92077 {
92078 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92079 + cookie[0] = 0;
92080 + cookie[1] = 0;
92081 +#else
92082 cookie[0] = (u32)(unsigned long)sk;
92083 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
92084 +#endif
92085 }
92086 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
92087
92088 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
92089 mutex_lock(&sock_diag_table_mutex);
92090 if (sock_diag_handlers[hndl->family])
92091 err = -EBUSY;
92092 - else
92093 + else {
92094 + pax_open_kernel();
92095 sock_diag_handlers[hndl->family] = hndl;
92096 + pax_close_kernel();
92097 + }
92098 mutex_unlock(&sock_diag_table_mutex);
92099
92100 return err;
92101 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
92102
92103 mutex_lock(&sock_diag_table_mutex);
92104 BUG_ON(sock_diag_handlers[family] != hnld);
92105 + pax_open_kernel();
92106 sock_diag_handlers[family] = NULL;
92107 + pax_close_kernel();
92108 mutex_unlock(&sock_diag_table_mutex);
92109 }
92110 EXPORT_SYMBOL_GPL(sock_diag_unregister);
92111 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
92112 index 31107ab..ae03d5a 100644
92113 --- a/net/core/sysctl_net_core.c
92114 +++ b/net/core/sysctl_net_core.c
92115 @@ -31,7 +31,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
92116 {
92117 unsigned int orig_size, size;
92118 int ret, i;
92119 - struct ctl_table tmp = {
92120 + ctl_table_no_const tmp = {
92121 .data = &size,
92122 .maxlen = sizeof(size),
92123 .mode = table->mode
92124 @@ -350,13 +350,12 @@ static struct ctl_table netns_core_table[] = {
92125
92126 static __net_init int sysctl_core_net_init(struct net *net)
92127 {
92128 - struct ctl_table *tbl;
92129 + ctl_table_no_const *tbl = NULL;
92130
92131 net->core.sysctl_somaxconn = SOMAXCONN;
92132
92133 - tbl = netns_core_table;
92134 if (!net_eq(net, &init_net)) {
92135 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
92136 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
92137 if (tbl == NULL)
92138 goto err_dup;
92139
92140 @@ -366,17 +365,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
92141 if (net->user_ns != &init_user_ns) {
92142 tbl[0].procname = NULL;
92143 }
92144 - }
92145 -
92146 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92147 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
92148 + } else
92149 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
92150 if (net->core.sysctl_hdr == NULL)
92151 goto err_reg;
92152
92153 return 0;
92154
92155 err_reg:
92156 - if (tbl != netns_core_table)
92157 - kfree(tbl);
92158 + kfree(tbl);
92159 err_dup:
92160 return -ENOMEM;
92161 }
92162 @@ -391,7 +389,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
92163 kfree(tbl);
92164 }
92165
92166 -static __net_initdata struct pernet_operations sysctl_core_ops = {
92167 +static __net_initconst struct pernet_operations sysctl_core_ops = {
92168 .init = sysctl_core_net_init,
92169 .exit = sysctl_core_net_exit,
92170 };
92171 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
92172 index dd4d506..fb2fb87 100644
92173 --- a/net/decnet/af_decnet.c
92174 +++ b/net/decnet/af_decnet.c
92175 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
92176 .sysctl_rmem = sysctl_decnet_rmem,
92177 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
92178 .obj_size = sizeof(struct dn_sock),
92179 + .slab_flags = SLAB_USERCOPY,
92180 };
92181
92182 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
92183 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
92184 index 5325b54..a0d4d69 100644
92185 --- a/net/decnet/sysctl_net_decnet.c
92186 +++ b/net/decnet/sysctl_net_decnet.c
92187 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
92188
92189 if (len > *lenp) len = *lenp;
92190
92191 - if (copy_to_user(buffer, addr, len))
92192 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
92193 return -EFAULT;
92194
92195 *lenp = len;
92196 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
92197
92198 if (len > *lenp) len = *lenp;
92199
92200 - if (copy_to_user(buffer, devname, len))
92201 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
92202 return -EFAULT;
92203
92204 *lenp = len;
92205 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
92206 index 3b9d5f2..d7015c6 100644
92207 --- a/net/ieee802154/6lowpan.c
92208 +++ b/net/ieee802154/6lowpan.c
92209 @@ -459,7 +459,7 @@ static int lowpan_header_create(struct sk_buff *skb,
92210 hc06_ptr += 3;
92211 } else {
92212 /* compress nothing */
92213 - memcpy(hc06_ptr, &hdr, 4);
92214 + memcpy(hc06_ptr, hdr, 4);
92215 /* replace the top byte with new ECN | DSCP format */
92216 *hc06_ptr = tmp;
92217 hc06_ptr += 4;
92218 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
92219 index dd6b523..dfe558f 100644
92220 --- a/net/ipv4/af_inet.c
92221 +++ b/net/ipv4/af_inet.c
92222 @@ -1687,13 +1687,9 @@ static int __init inet_init(void)
92223
92224 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
92225
92226 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
92227 - if (!sysctl_local_reserved_ports)
92228 - goto out;
92229 -
92230 rc = proto_register(&tcp_prot, 1);
92231 if (rc)
92232 - goto out_free_reserved_ports;
92233 + goto out;
92234
92235 rc = proto_register(&udp_prot, 1);
92236 if (rc)
92237 @@ -1802,8 +1798,6 @@ out_unregister_udp_proto:
92238 proto_unregister(&udp_prot);
92239 out_unregister_tcp_proto:
92240 proto_unregister(&tcp_prot);
92241 -out_free_reserved_ports:
92242 - kfree(sysctl_local_reserved_ports);
92243 goto out;
92244 }
92245
92246 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
92247 index 34ca6d5..b6421e8 100644
92248 --- a/net/ipv4/devinet.c
92249 +++ b/net/ipv4/devinet.c
92250 @@ -1532,7 +1532,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
92251 idx = 0;
92252 head = &net->dev_index_head[h];
92253 rcu_read_lock();
92254 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92255 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92256 net->dev_base_seq;
92257 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92258 if (idx < s_idx)
92259 @@ -1843,7 +1843,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
92260 idx = 0;
92261 head = &net->dev_index_head[h];
92262 rcu_read_lock();
92263 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
92264 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
92265 net->dev_base_seq;
92266 hlist_for_each_entry_rcu(dev, head, index_hlist) {
92267 if (idx < s_idx)
92268 @@ -2068,7 +2068,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
92269 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
92270 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
92271
92272 -static struct devinet_sysctl_table {
92273 +static const struct devinet_sysctl_table {
92274 struct ctl_table_header *sysctl_header;
92275 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
92276 } devinet_sysctl = {
92277 @@ -2186,7 +2186,7 @@ static __net_init int devinet_init_net(struct net *net)
92278 int err;
92279 struct ipv4_devconf *all, *dflt;
92280 #ifdef CONFIG_SYSCTL
92281 - struct ctl_table *tbl = ctl_forward_entry;
92282 + ctl_table_no_const *tbl = NULL;
92283 struct ctl_table_header *forw_hdr;
92284 #endif
92285
92286 @@ -2204,7 +2204,7 @@ static __net_init int devinet_init_net(struct net *net)
92287 goto err_alloc_dflt;
92288
92289 #ifdef CONFIG_SYSCTL
92290 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
92291 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
92292 if (tbl == NULL)
92293 goto err_alloc_ctl;
92294
92295 @@ -2224,7 +2224,10 @@ static __net_init int devinet_init_net(struct net *net)
92296 goto err_reg_dflt;
92297
92298 err = -ENOMEM;
92299 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92300 + if (!net_eq(net, &init_net))
92301 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
92302 + else
92303 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
92304 if (forw_hdr == NULL)
92305 goto err_reg_ctl;
92306 net->ipv4.forw_hdr = forw_hdr;
92307 @@ -2240,8 +2243,7 @@ err_reg_ctl:
92308 err_reg_dflt:
92309 __devinet_sysctl_unregister(all);
92310 err_reg_all:
92311 - if (tbl != ctl_forward_entry)
92312 - kfree(tbl);
92313 + kfree(tbl);
92314 err_alloc_ctl:
92315 #endif
92316 if (dflt != &ipv4_devconf_dflt)
92317 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
92318 index b3f627a..b0f3e99 100644
92319 --- a/net/ipv4/fib_frontend.c
92320 +++ b/net/ipv4/fib_frontend.c
92321 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
92322 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92323 fib_sync_up(dev);
92324 #endif
92325 - atomic_inc(&net->ipv4.dev_addr_genid);
92326 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92327 rt_cache_flush(dev_net(dev));
92328 break;
92329 case NETDEV_DOWN:
92330 fib_del_ifaddr(ifa, NULL);
92331 - atomic_inc(&net->ipv4.dev_addr_genid);
92332 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92333 if (ifa->ifa_dev->ifa_list == NULL) {
92334 /* Last address was deleted from this interface.
92335 * Disable IP.
92336 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
92337 #ifdef CONFIG_IP_ROUTE_MULTIPATH
92338 fib_sync_up(dev);
92339 #endif
92340 - atomic_inc(&net->ipv4.dev_addr_genid);
92341 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
92342 rt_cache_flush(net);
92343 break;
92344 case NETDEV_DOWN:
92345 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
92346 index d5dbca5..6251d5f 100644
92347 --- a/net/ipv4/fib_semantics.c
92348 +++ b/net/ipv4/fib_semantics.c
92349 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
92350 nh->nh_saddr = inet_select_addr(nh->nh_dev,
92351 nh->nh_gw,
92352 nh->nh_parent->fib_scope);
92353 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
92354 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
92355
92356 return nh->nh_saddr;
92357 }
92358 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
92359 index 6acb541..9ea617d 100644
92360 --- a/net/ipv4/inet_connection_sock.c
92361 +++ b/net/ipv4/inet_connection_sock.c
92362 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
92363 .range = { 32768, 61000 },
92364 };
92365
92366 -unsigned long *sysctl_local_reserved_ports;
92367 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
92368 EXPORT_SYMBOL(sysctl_local_reserved_ports);
92369
92370 void inet_get_local_port_range(int *low, int *high)
92371 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
92372 index 7bd8983..b956690 100644
92373 --- a/net/ipv4/inet_hashtables.c
92374 +++ b/net/ipv4/inet_hashtables.c
92375 @@ -18,12 +18,15 @@
92376 #include <linux/sched.h>
92377 #include <linux/slab.h>
92378 #include <linux/wait.h>
92379 +#include <linux/security.h>
92380
92381 #include <net/inet_connection_sock.h>
92382 #include <net/inet_hashtables.h>
92383 #include <net/secure_seq.h>
92384 #include <net/ip.h>
92385
92386 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
92387 +
92388 /*
92389 * Allocate and initialize a new local port bind bucket.
92390 * The bindhash mutex for snum's hash chain must be held here.
92391 @@ -287,7 +290,7 @@ begintw:
92392 if (unlikely(!INET_TW_MATCH(sk, net, acookie,
92393 saddr, daddr, ports,
92394 dif))) {
92395 - sock_put(sk);
92396 + inet_twsk_put(inet_twsk(sk));
92397 goto begintw;
92398 }
92399 goto out;
92400 @@ -554,6 +557,8 @@ ok:
92401 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
92402 spin_unlock(&head->lock);
92403
92404 + gr_update_task_in_ip_table(current, inet_sk(sk));
92405 +
92406 if (tw) {
92407 inet_twsk_deschedule(tw, death_row);
92408 while (twrefcnt) {
92409 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
92410 index 33d5537..da337a4 100644
92411 --- a/net/ipv4/inetpeer.c
92412 +++ b/net/ipv4/inetpeer.c
92413 @@ -503,8 +503,8 @@ relookup:
92414 if (p) {
92415 p->daddr = *daddr;
92416 atomic_set(&p->refcnt, 1);
92417 - atomic_set(&p->rid, 0);
92418 - atomic_set(&p->ip_id_count,
92419 + atomic_set_unchecked(&p->rid, 0);
92420 + atomic_set_unchecked(&p->ip_id_count,
92421 (daddr->family == AF_INET) ?
92422 secure_ip_id(daddr->addr.a4) :
92423 secure_ipv6_id(daddr->addr.a6));
92424 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
92425 index b66910a..cfe416e 100644
92426 --- a/net/ipv4/ip_fragment.c
92427 +++ b/net/ipv4/ip_fragment.c
92428 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
92429 return 0;
92430
92431 start = qp->rid;
92432 - end = atomic_inc_return(&peer->rid);
92433 + end = atomic_inc_return_unchecked(&peer->rid);
92434 qp->rid = end;
92435
92436 rc = qp->q.fragments && (end - start) > max;
92437 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
92438
92439 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92440 {
92441 - struct ctl_table *table;
92442 + ctl_table_no_const *table = NULL;
92443 struct ctl_table_header *hdr;
92444
92445 - table = ip4_frags_ns_ctl_table;
92446 if (!net_eq(net, &init_net)) {
92447 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92448 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
92449 if (table == NULL)
92450 goto err_alloc;
92451
92452 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92453 /* Don't export sysctls to unprivileged users */
92454 if (net->user_ns != &init_user_ns)
92455 table[0].procname = NULL;
92456 - }
92457 + hdr = register_net_sysctl(net, "net/ipv4", table);
92458 + } else
92459 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
92460
92461 - hdr = register_net_sysctl(net, "net/ipv4", table);
92462 if (hdr == NULL)
92463 goto err_reg;
92464
92465 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
92466 return 0;
92467
92468 err_reg:
92469 - if (!net_eq(net, &init_net))
92470 - kfree(table);
92471 + kfree(table);
92472 err_alloc:
92473 return -ENOMEM;
92474 }
92475 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
92476 index 8d6939e..19d0a95 100644
92477 --- a/net/ipv4/ip_gre.c
92478 +++ b/net/ipv4/ip_gre.c
92479 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
92480 module_param(log_ecn_error, bool, 0644);
92481 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92482
92483 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
92484 +static struct rtnl_link_ops ipgre_link_ops;
92485 static int ipgre_tunnel_init(struct net_device *dev);
92486
92487 static int ipgre_net_id __read_mostly;
92488 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
92489 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
92490 };
92491
92492 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92493 +static struct rtnl_link_ops ipgre_link_ops = {
92494 .kind = "gre",
92495 .maxtype = IFLA_GRE_MAX,
92496 .policy = ipgre_policy,
92497 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
92498 .fill_info = ipgre_fill_info,
92499 };
92500
92501 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
92502 +static struct rtnl_link_ops ipgre_tap_ops = {
92503 .kind = "gretap",
92504 .maxtype = IFLA_GRE_MAX,
92505 .policy = ipgre_policy,
92506 diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
92507 index a04d872..7f4ab5d 100644
92508 --- a/net/ipv4/ip_output.c
92509 +++ b/net/ipv4/ip_output.c
92510 @@ -836,7 +836,7 @@ static int __ip_append_data(struct sock *sk,
92511 csummode = CHECKSUM_PARTIAL;
92512
92513 cork->length += length;
92514 - if (((length > mtu) || (skb && skb_is_gso(skb))) &&
92515 + if (((length > mtu) || (skb && skb_has_frags(skb))) &&
92516 (sk->sk_protocol == IPPROTO_UDP) &&
92517 (rt->dst.dev->features & NETIF_F_UFO) && !rt->dst.header_len) {
92518 err = ip_ufo_append_data(sk, queue, getfrag, from, length,
92519 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
92520 index d9c4f11..02b82dbc 100644
92521 --- a/net/ipv4/ip_sockglue.c
92522 +++ b/net/ipv4/ip_sockglue.c
92523 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92524 len = min_t(unsigned int, len, opt->optlen);
92525 if (put_user(len, optlen))
92526 return -EFAULT;
92527 - if (copy_to_user(optval, opt->__data, len))
92528 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
92529 + copy_to_user(optval, opt->__data, len))
92530 return -EFAULT;
92531 return 0;
92532 }
92533 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
92534 if (sk->sk_type != SOCK_STREAM)
92535 return -ENOPROTOOPT;
92536
92537 - msg.msg_control = optval;
92538 + msg.msg_control = (void __force_kernel *)optval;
92539 msg.msg_controllen = len;
92540 msg.msg_flags = flags;
92541
92542 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
92543 index 17cc0ff..63856c4 100644
92544 --- a/net/ipv4/ip_vti.c
92545 +++ b/net/ipv4/ip_vti.c
92546 @@ -47,7 +47,7 @@
92547 #define HASH_SIZE 16
92548 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
92549
92550 -static struct rtnl_link_ops vti_link_ops __read_mostly;
92551 +static struct rtnl_link_ops vti_link_ops;
92552
92553 static int vti_net_id __read_mostly;
92554 struct vti_net {
92555 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
92556 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
92557 };
92558
92559 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
92560 +static struct rtnl_link_ops vti_link_ops = {
92561 .kind = "vti",
92562 .maxtype = IFLA_VTI_MAX,
92563 .policy = vti_policy,
92564 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
92565 index efa1138..20dbba0 100644
92566 --- a/net/ipv4/ipconfig.c
92567 +++ b/net/ipv4/ipconfig.c
92568 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
92569
92570 mm_segment_t oldfs = get_fs();
92571 set_fs(get_ds());
92572 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92573 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92574 set_fs(oldfs);
92575 return res;
92576 }
92577 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
92578
92579 mm_segment_t oldfs = get_fs();
92580 set_fs(get_ds());
92581 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
92582 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
92583 set_fs(oldfs);
92584 return res;
92585 }
92586 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
92587
92588 mm_segment_t oldfs = get_fs();
92589 set_fs(get_ds());
92590 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
92591 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
92592 set_fs(oldfs);
92593 return res;
92594 }
92595 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
92596 index b3ac3c3..ec6bd95 100644
92597 --- a/net/ipv4/ipip.c
92598 +++ b/net/ipv4/ipip.c
92599 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
92600 static int ipip_net_id __read_mostly;
92601
92602 static int ipip_tunnel_init(struct net_device *dev);
92603 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
92604 +static struct rtnl_link_ops ipip_link_ops;
92605
92606 static int ipip_err(struct sk_buff *skb, u32 info)
92607 {
92608 @@ -409,7 +409,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
92609 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
92610 };
92611
92612 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
92613 +static struct rtnl_link_ops ipip_link_ops = {
92614 .kind = "ipip",
92615 .maxtype = IFLA_IPTUN_MAX,
92616 .policy = ipip_policy,
92617 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
92618 index 85a4f21..1beb1f5 100644
92619 --- a/net/ipv4/netfilter/arp_tables.c
92620 +++ b/net/ipv4/netfilter/arp_tables.c
92621 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
92622 #endif
92623
92624 static int get_info(struct net *net, void __user *user,
92625 - const int *len, int compat)
92626 + int len, int compat)
92627 {
92628 char name[XT_TABLE_MAXNAMELEN];
92629 struct xt_table *t;
92630 int ret;
92631
92632 - if (*len != sizeof(struct arpt_getinfo)) {
92633 - duprintf("length %u != %Zu\n", *len,
92634 + if (len != sizeof(struct arpt_getinfo)) {
92635 + duprintf("length %u != %Zu\n", len,
92636 sizeof(struct arpt_getinfo));
92637 return -EINVAL;
92638 }
92639 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
92640 info.size = private->size;
92641 strcpy(info.name, name);
92642
92643 - if (copy_to_user(user, &info, *len) != 0)
92644 + if (copy_to_user(user, &info, len) != 0)
92645 ret = -EFAULT;
92646 else
92647 ret = 0;
92648 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
92649
92650 switch (cmd) {
92651 case ARPT_SO_GET_INFO:
92652 - ret = get_info(sock_net(sk), user, len, 1);
92653 + ret = get_info(sock_net(sk), user, *len, 1);
92654 break;
92655 case ARPT_SO_GET_ENTRIES:
92656 ret = compat_get_entries(sock_net(sk), user, len);
92657 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
92658
92659 switch (cmd) {
92660 case ARPT_SO_GET_INFO:
92661 - ret = get_info(sock_net(sk), user, len, 0);
92662 + ret = get_info(sock_net(sk), user, *len, 0);
92663 break;
92664
92665 case ARPT_SO_GET_ENTRIES:
92666 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
92667 index d23118d..6ad7277 100644
92668 --- a/net/ipv4/netfilter/ip_tables.c
92669 +++ b/net/ipv4/netfilter/ip_tables.c
92670 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
92671 #endif
92672
92673 static int get_info(struct net *net, void __user *user,
92674 - const int *len, int compat)
92675 + int len, int compat)
92676 {
92677 char name[XT_TABLE_MAXNAMELEN];
92678 struct xt_table *t;
92679 int ret;
92680
92681 - if (*len != sizeof(struct ipt_getinfo)) {
92682 - duprintf("length %u != %zu\n", *len,
92683 + if (len != sizeof(struct ipt_getinfo)) {
92684 + duprintf("length %u != %zu\n", len,
92685 sizeof(struct ipt_getinfo));
92686 return -EINVAL;
92687 }
92688 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
92689 info.size = private->size;
92690 strcpy(info.name, name);
92691
92692 - if (copy_to_user(user, &info, *len) != 0)
92693 + if (copy_to_user(user, &info, len) != 0)
92694 ret = -EFAULT;
92695 else
92696 ret = 0;
92697 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92698
92699 switch (cmd) {
92700 case IPT_SO_GET_INFO:
92701 - ret = get_info(sock_net(sk), user, len, 1);
92702 + ret = get_info(sock_net(sk), user, *len, 1);
92703 break;
92704 case IPT_SO_GET_ENTRIES:
92705 ret = compat_get_entries(sock_net(sk), user, len);
92706 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
92707
92708 switch (cmd) {
92709 case IPT_SO_GET_INFO:
92710 - ret = get_info(sock_net(sk), user, len, 0);
92711 + ret = get_info(sock_net(sk), user, *len, 0);
92712 break;
92713
92714 case IPT_SO_GET_ENTRIES:
92715 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
92716 index cbc2215..9cb993c 100644
92717 --- a/net/ipv4/netfilter/ipt_ULOG.c
92718 +++ b/net/ipv4/netfilter/ipt_ULOG.c
92719 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
92720 ub->qlen++;
92721
92722 pm = nlmsg_data(nlh);
92723 + memset(pm, 0, sizeof(*pm));
92724
92725 /* We might not have a timestamp, get one */
92726 if (skb->tstamp.tv64 == 0)
92727 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
92728 }
92729 else if (loginfo->prefix[0] != '\0')
92730 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
92731 - else
92732 - *(pm->prefix) = '\0';
92733
92734 if (in && in->hard_header_len > 0 &&
92735 skb->mac_header != skb->network_header &&
92736 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
92737
92738 if (in)
92739 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
92740 - else
92741 - pm->indev_name[0] = '\0';
92742
92743 if (out)
92744 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
92745 - else
92746 - pm->outdev_name[0] = '\0';
92747
92748 /* copy_len <= skb->len, so can't fail. */
92749 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
92750 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
92751 index 746427c..80eab72 100644
92752 --- a/net/ipv4/ping.c
92753 +++ b/net/ipv4/ping.c
92754 @@ -55,7 +55,7 @@
92755
92756
92757 struct ping_table ping_table;
92758 -struct pingv6_ops pingv6_ops;
92759 +struct pingv6_ops *pingv6_ops;
92760 EXPORT_SYMBOL_GPL(pingv6_ops);
92761
92762 static u16 ping_port_rover;
92763 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
92764 return -ENODEV;
92765 }
92766 }
92767 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
92768 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
92769 scoped);
92770 rcu_read_unlock();
92771
92772 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92773 }
92774 #if IS_ENABLED(CONFIG_IPV6)
92775 } else if (skb->protocol == htons(ETH_P_IPV6)) {
92776 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
92777 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
92778 #endif
92779 }
92780
92781 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
92782 info, (u8 *)icmph);
92783 #if IS_ENABLED(CONFIG_IPV6)
92784 } else if (family == AF_INET6) {
92785 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
92786 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
92787 info, (u8 *)icmph);
92788 #endif
92789 }
92790 @@ -850,7 +850,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92791 return ip_recv_error(sk, msg, len);
92792 #if IS_ENABLED(CONFIG_IPV6)
92793 } else if (family == AF_INET6) {
92794 - return pingv6_ops.ipv6_recv_error(sk, msg, len);
92795 + return pingv6_ops->ipv6_recv_error(sk, msg, len);
92796 #endif
92797 }
92798 }
92799 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
92800 IP6CB(skb)->iif);
92801
92802 if (inet6_sk(sk)->rxopt.all)
92803 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
92804 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
92805 #endif
92806 } else {
92807 BUG();
92808 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
92809 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
92810 0, sock_i_ino(sp),
92811 atomic_read(&sp->sk_refcnt), sp,
92812 - atomic_read(&sp->sk_drops), len);
92813 + atomic_read_unchecked(&sp->sk_drops), len);
92814 }
92815
92816 static int ping_v4_seq_show(struct seq_file *seq, void *v)
92817 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
92818 index 6fb2337..9cd6b20 100644
92819 --- a/net/ipv4/raw.c
92820 +++ b/net/ipv4/raw.c
92821 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
92822 int raw_rcv(struct sock *sk, struct sk_buff *skb)
92823 {
92824 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
92825 - atomic_inc(&sk->sk_drops);
92826 + atomic_inc_unchecked(&sk->sk_drops);
92827 kfree_skb(skb);
92828 return NET_RX_DROP;
92829 }
92830 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
92831
92832 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
92833 {
92834 + struct icmp_filter filter;
92835 +
92836 if (optlen > sizeof(struct icmp_filter))
92837 optlen = sizeof(struct icmp_filter);
92838 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
92839 + if (copy_from_user(&filter, optval, optlen))
92840 return -EFAULT;
92841 + raw_sk(sk)->filter = filter;
92842 return 0;
92843 }
92844
92845 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
92846 {
92847 int len, ret = -EFAULT;
92848 + struct icmp_filter filter;
92849
92850 if (get_user(len, optlen))
92851 goto out;
92852 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
92853 if (len > sizeof(struct icmp_filter))
92854 len = sizeof(struct icmp_filter);
92855 ret = -EFAULT;
92856 - if (put_user(len, optlen) ||
92857 - copy_to_user(optval, &raw_sk(sk)->filter, len))
92858 + filter = raw_sk(sk)->filter;
92859 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
92860 goto out;
92861 ret = 0;
92862 out: return ret;
92863 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92864 0, 0L, 0,
92865 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92866 0, sock_i_ino(sp),
92867 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92868 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92869 }
92870
92871 static int raw_seq_show(struct seq_file *seq, void *v)
92872 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
92873 index a9a54a2..647316e 100644
92874 --- a/net/ipv4/route.c
92875 +++ b/net/ipv4/route.c
92876 @@ -2615,34 +2615,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
92877 .maxlen = sizeof(int),
92878 .mode = 0200,
92879 .proc_handler = ipv4_sysctl_rtcache_flush,
92880 + .extra1 = &init_net,
92881 },
92882 { },
92883 };
92884
92885 static __net_init int sysctl_route_net_init(struct net *net)
92886 {
92887 - struct ctl_table *tbl;
92888 + ctl_table_no_const *tbl = NULL;
92889
92890 - tbl = ipv4_route_flush_table;
92891 if (!net_eq(net, &init_net)) {
92892 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92893 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
92894 if (tbl == NULL)
92895 goto err_dup;
92896
92897 /* Don't export sysctls to unprivileged users */
92898 if (net->user_ns != &init_user_ns)
92899 tbl[0].procname = NULL;
92900 - }
92901 - tbl[0].extra1 = net;
92902 + tbl[0].extra1 = net;
92903 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92904 + } else
92905 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
92906
92907 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
92908 if (net->ipv4.route_hdr == NULL)
92909 goto err_reg;
92910 return 0;
92911
92912 err_reg:
92913 - if (tbl != ipv4_route_flush_table)
92914 - kfree(tbl);
92915 + kfree(tbl);
92916 err_dup:
92917 return -ENOMEM;
92918 }
92919 @@ -2665,8 +2665,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
92920
92921 static __net_init int rt_genid_init(struct net *net)
92922 {
92923 - atomic_set(&net->rt_genid, 0);
92924 - atomic_set(&net->fnhe_genid, 0);
92925 + atomic_set_unchecked(&net->rt_genid, 0);
92926 + atomic_set_unchecked(&net->fnhe_genid, 0);
92927 get_random_bytes(&net->ipv4.dev_addr_genid,
92928 sizeof(net->ipv4.dev_addr_genid));
92929 return 0;
92930 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
92931 index 610e324..fd42e75 100644
92932 --- a/net/ipv4/sysctl_net_ipv4.c
92933 +++ b/net/ipv4/sysctl_net_ipv4.c
92934 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
92935 {
92936 int ret;
92937 int range[2];
92938 - struct ctl_table tmp = {
92939 + ctl_table_no_const tmp = {
92940 .data = &range,
92941 .maxlen = sizeof(range),
92942 .mode = table->mode,
92943 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
92944 int ret;
92945 gid_t urange[2];
92946 kgid_t low, high;
92947 - struct ctl_table tmp = {
92948 + ctl_table_no_const tmp = {
92949 .data = &urange,
92950 .maxlen = sizeof(urange),
92951 .mode = table->mode,
92952 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
92953 void __user *buffer, size_t *lenp, loff_t *ppos)
92954 {
92955 char val[TCP_CA_NAME_MAX];
92956 - struct ctl_table tbl = {
92957 + ctl_table_no_const tbl = {
92958 .data = val,
92959 .maxlen = TCP_CA_NAME_MAX,
92960 };
92961 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
92962 void __user *buffer, size_t *lenp,
92963 loff_t *ppos)
92964 {
92965 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
92966 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
92967 int ret;
92968
92969 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92970 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
92971 void __user *buffer, size_t *lenp,
92972 loff_t *ppos)
92973 {
92974 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
92975 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
92976 int ret;
92977
92978 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
92979 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
92980 struct mem_cgroup *memcg;
92981 #endif
92982
92983 - struct ctl_table tmp = {
92984 + ctl_table_no_const tmp = {
92985 .data = &vec,
92986 .maxlen = sizeof(vec),
92987 .mode = ctl->mode,
92988 };
92989
92990 if (!write) {
92991 - ctl->data = &net->ipv4.sysctl_tcp_mem;
92992 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
92993 + ctl_table_no_const tcp_mem = *ctl;
92994 +
92995 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
92996 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
92997 }
92998
92999 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
93000 @@ -239,7 +241,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
93001 void __user *buffer, size_t *lenp,
93002 loff_t *ppos)
93003 {
93004 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93005 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
93006 struct tcp_fastopen_context *ctxt;
93007 int ret;
93008 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
93009 @@ -482,7 +484,7 @@ static struct ctl_table ipv4_table[] = {
93010 },
93011 {
93012 .procname = "ip_local_reserved_ports",
93013 - .data = NULL, /* initialized in sysctl_ipv4_init */
93014 + .data = sysctl_local_reserved_ports,
93015 .maxlen = 65536,
93016 .mode = 0644,
93017 .proc_handler = proc_do_large_bitmap,
93018 @@ -847,11 +849,10 @@ static struct ctl_table ipv4_net_table[] = {
93019
93020 static __net_init int ipv4_sysctl_init_net(struct net *net)
93021 {
93022 - struct ctl_table *table;
93023 + ctl_table_no_const *table = NULL;
93024
93025 - table = ipv4_net_table;
93026 if (!net_eq(net, &init_net)) {
93027 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
93028 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
93029 if (table == NULL)
93030 goto err_alloc;
93031
93032 @@ -886,15 +887,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
93033
93034 tcp_init_mem(net);
93035
93036 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93037 + if (!net_eq(net, &init_net))
93038 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
93039 + else
93040 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
93041 if (net->ipv4.ipv4_hdr == NULL)
93042 goto err_reg;
93043
93044 return 0;
93045
93046 err_reg:
93047 - if (!net_eq(net, &init_net))
93048 - kfree(table);
93049 + kfree(table);
93050 err_alloc:
93051 return -ENOMEM;
93052 }
93053 @@ -916,16 +919,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
93054 static __init int sysctl_ipv4_init(void)
93055 {
93056 struct ctl_table_header *hdr;
93057 - struct ctl_table *i;
93058 -
93059 - for (i = ipv4_table; i->procname; i++) {
93060 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
93061 - i->data = sysctl_local_reserved_ports;
93062 - break;
93063 - }
93064 - }
93065 - if (!i->procname)
93066 - return -EINVAL;
93067
93068 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
93069 if (hdr == NULL)
93070 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
93071 index 3ca2139..c4cc060 100644
93072 --- a/net/ipv4/tcp_input.c
93073 +++ b/net/ipv4/tcp_input.c
93074 @@ -4379,7 +4379,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
93075 * simplifies code)
93076 */
93077 static void
93078 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93079 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
93080 struct sk_buff *head, struct sk_buff *tail,
93081 u32 start, u32 end)
93082 {
93083 @@ -5465,6 +5465,7 @@ discard:
93084 tcp_paws_reject(&tp->rx_opt, 0))
93085 goto discard_and_undo;
93086
93087 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
93088 if (th->syn) {
93089 /* We see SYN without ACK. It is attempt of
93090 * simultaneous connect with crossed SYNs.
93091 @@ -5515,6 +5516,7 @@ discard:
93092 goto discard;
93093 #endif
93094 }
93095 +#endif
93096 /* "fifth, if neither of the SYN or RST bits is set then
93097 * drop the segment and return."
93098 */
93099 @@ -5560,7 +5562,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
93100 goto discard;
93101
93102 if (th->syn) {
93103 - if (th->fin)
93104 + if (th->fin || th->urg || th->psh)
93105 goto discard;
93106 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
93107 return 1;
93108 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
93109 index b299da5..097db06 100644
93110 --- a/net/ipv4/tcp_ipv4.c
93111 +++ b/net/ipv4/tcp_ipv4.c
93112 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
93113 EXPORT_SYMBOL(sysctl_tcp_low_latency);
93114
93115
93116 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93117 +extern int grsec_enable_blackhole;
93118 +#endif
93119 +
93120 #ifdef CONFIG_TCP_MD5SIG
93121 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
93122 __be32 daddr, __be32 saddr, const struct tcphdr *th);
93123 @@ -1830,6 +1834,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
93124 return 0;
93125
93126 reset:
93127 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93128 + if (!grsec_enable_blackhole)
93129 +#endif
93130 tcp_v4_send_reset(rsk, skb);
93131 discard:
93132 kfree_skb(skb);
93133 @@ -1975,12 +1982,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
93134 TCP_SKB_CB(skb)->sacked = 0;
93135
93136 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
93137 - if (!sk)
93138 + if (!sk) {
93139 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93140 + ret = 1;
93141 +#endif
93142 goto no_tcp_socket;
93143 -
93144 + }
93145 process:
93146 - if (sk->sk_state == TCP_TIME_WAIT)
93147 + if (sk->sk_state == TCP_TIME_WAIT) {
93148 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93149 + ret = 2;
93150 +#endif
93151 goto do_time_wait;
93152 + }
93153
93154 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
93155 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
93156 @@ -2034,6 +2048,10 @@ csum_error:
93157 bad_packet:
93158 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
93159 } else {
93160 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93161 + if (!grsec_enable_blackhole || (ret == 1 &&
93162 + (skb->dev->flags & IFF_LOOPBACK)))
93163 +#endif
93164 tcp_v4_send_reset(NULL, skb);
93165 }
93166
93167 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
93168 index ab1c086..2a8d76b 100644
93169 --- a/net/ipv4/tcp_minisocks.c
93170 +++ b/net/ipv4/tcp_minisocks.c
93171 @@ -27,6 +27,10 @@
93172 #include <net/inet_common.h>
93173 #include <net/xfrm.h>
93174
93175 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93176 +extern int grsec_enable_blackhole;
93177 +#endif
93178 +
93179 int sysctl_tcp_syncookies __read_mostly = 1;
93180 EXPORT_SYMBOL(sysctl_tcp_syncookies);
93181
93182 @@ -715,7 +719,10 @@ embryonic_reset:
93183 * avoid becoming vulnerable to outside attack aiming at
93184 * resetting legit local connections.
93185 */
93186 - req->rsk_ops->send_reset(sk, skb);
93187 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93188 + if (!grsec_enable_blackhole)
93189 +#endif
93190 + req->rsk_ops->send_reset(sk, skb);
93191 } else if (fastopen) { /* received a valid RST pkt */
93192 reqsk_fastopen_remove(sk, req, true);
93193 tcp_reset(sk);
93194 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
93195 index 170737a..75cbd26 100644
93196 --- a/net/ipv4/tcp_output.c
93197 +++ b/net/ipv4/tcp_output.c
93198 @@ -982,6 +982,9 @@ static void tcp_queue_skb(struct sock *sk, struct sk_buff *skb)
93199 static void tcp_set_skb_tso_segs(const struct sock *sk, struct sk_buff *skb,
93200 unsigned int mss_now)
93201 {
93202 + /* Make sure we own this skb before messing gso_size/gso_segs */
93203 + WARN_ON_ONCE(skb_cloned(skb));
93204 +
93205 if (skb->len <= mss_now || !sk_can_gso(sk) ||
93206 skb->ip_summed == CHECKSUM_NONE) {
93207 /* Avoid the costly divide in the normal
93208 @@ -1063,9 +1066,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len,
93209 if (nsize < 0)
93210 nsize = 0;
93211
93212 - if (skb_cloned(skb) &&
93213 - skb_is_nonlinear(skb) &&
93214 - pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
93215 + if (skb_unclone(skb, GFP_ATOMIC))
93216 return -ENOMEM;
93217
93218 /* Get a new skb... force flag on. */
93219 @@ -2334,6 +2335,8 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
93220 int oldpcount = tcp_skb_pcount(skb);
93221
93222 if (unlikely(oldpcount > 1)) {
93223 + if (skb_unclone(skb, GFP_ATOMIC))
93224 + return -ENOMEM;
93225 tcp_init_tso_segs(sk, skb, cur_mss);
93226 tcp_adjust_pcount(sk, skb, oldpcount - tcp_skb_pcount(skb));
93227 }
93228 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
93229 index d4943f6..e7a74a5 100644
93230 --- a/net/ipv4/tcp_probe.c
93231 +++ b/net/ipv4/tcp_probe.c
93232 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
93233 if (cnt + width >= len)
93234 break;
93235
93236 - if (copy_to_user(buf + cnt, tbuf, width))
93237 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
93238 return -EFAULT;
93239 cnt += width;
93240 }
93241 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
93242 index 4b85e6f..22f9ac9 100644
93243 --- a/net/ipv4/tcp_timer.c
93244 +++ b/net/ipv4/tcp_timer.c
93245 @@ -22,6 +22,10 @@
93246 #include <linux/gfp.h>
93247 #include <net/tcp.h>
93248
93249 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93250 +extern int grsec_lastack_retries;
93251 +#endif
93252 +
93253 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
93254 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
93255 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
93256 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
93257 }
93258 }
93259
93260 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93261 + if ((sk->sk_state == TCP_LAST_ACK) &&
93262 + (grsec_lastack_retries > 0) &&
93263 + (grsec_lastack_retries < retry_until))
93264 + retry_until = grsec_lastack_retries;
93265 +#endif
93266 +
93267 if (retransmits_timed_out(sk, retry_until,
93268 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
93269 /* Has it gone just too far? */
93270 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
93271 index 766e6ba..aff2f8d 100644
93272 --- a/net/ipv4/udp.c
93273 +++ b/net/ipv4/udp.c
93274 @@ -87,6 +87,7 @@
93275 #include <linux/types.h>
93276 #include <linux/fcntl.h>
93277 #include <linux/module.h>
93278 +#include <linux/security.h>
93279 #include <linux/socket.h>
93280 #include <linux/sockios.h>
93281 #include <linux/igmp.h>
93282 @@ -112,6 +113,10 @@
93283 #include <net/busy_poll.h>
93284 #include "udp_impl.h"
93285
93286 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93287 +extern int grsec_enable_blackhole;
93288 +#endif
93289 +
93290 struct udp_table udp_table __read_mostly;
93291 EXPORT_SYMBOL(udp_table);
93292
93293 @@ -595,6 +600,9 @@ found:
93294 return s;
93295 }
93296
93297 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
93298 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
93299 +
93300 /*
93301 * This routine is called by the ICMP module when it gets some
93302 * sort of error condition. If err < 0 then the socket should
93303 @@ -891,9 +899,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
93304 dport = usin->sin_port;
93305 if (dport == 0)
93306 return -EINVAL;
93307 +
93308 + err = gr_search_udp_sendmsg(sk, usin);
93309 + if (err)
93310 + return err;
93311 } else {
93312 if (sk->sk_state != TCP_ESTABLISHED)
93313 return -EDESTADDRREQ;
93314 +
93315 + err = gr_search_udp_sendmsg(sk, NULL);
93316 + if (err)
93317 + return err;
93318 +
93319 daddr = inet->inet_daddr;
93320 dport = inet->inet_dport;
93321 /* Open fast path for connected socket.
93322 @@ -1137,7 +1154,7 @@ static unsigned int first_packet_length(struct sock *sk)
93323 IS_UDPLITE(sk));
93324 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93325 IS_UDPLITE(sk));
93326 - atomic_inc(&sk->sk_drops);
93327 + atomic_inc_unchecked(&sk->sk_drops);
93328 __skb_unlink(skb, rcvq);
93329 __skb_queue_tail(&list_kill, skb);
93330 }
93331 @@ -1223,6 +1240,10 @@ try_again:
93332 if (!skb)
93333 goto out;
93334
93335 + err = gr_search_udp_recvmsg(sk, skb);
93336 + if (err)
93337 + goto out_free;
93338 +
93339 ulen = skb->len - sizeof(struct udphdr);
93340 copied = len;
93341 if (copied > ulen)
93342 @@ -1256,7 +1277,7 @@ try_again:
93343 if (unlikely(err)) {
93344 trace_kfree_skb(skb, udp_recvmsg);
93345 if (!peeked) {
93346 - atomic_inc(&sk->sk_drops);
93347 + atomic_inc_unchecked(&sk->sk_drops);
93348 UDP_INC_STATS_USER(sock_net(sk),
93349 UDP_MIB_INERRORS, is_udplite);
93350 }
93351 @@ -1543,7 +1564,7 @@ csum_error:
93352 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
93353 drop:
93354 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
93355 - atomic_inc(&sk->sk_drops);
93356 + atomic_inc_unchecked(&sk->sk_drops);
93357 kfree_skb(skb);
93358 return -1;
93359 }
93360 @@ -1562,7 +1583,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
93361 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
93362
93363 if (!skb1) {
93364 - atomic_inc(&sk->sk_drops);
93365 + atomic_inc_unchecked(&sk->sk_drops);
93366 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
93367 IS_UDPLITE(sk));
93368 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
93369 @@ -1734,6 +1755,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
93370 goto csum_error;
93371
93372 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
93373 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93374 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
93375 +#endif
93376 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
93377
93378 /*
93379 @@ -2166,7 +2190,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
93380 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
93381 0, sock_i_ino(sp),
93382 atomic_read(&sp->sk_refcnt), sp,
93383 - atomic_read(&sp->sk_drops), len);
93384 + atomic_read_unchecked(&sp->sk_drops), len);
93385 }
93386
93387 int udp4_seq_show(struct seq_file *seq, void *v)
93388 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
93389 index 9a459be..c7bc04c 100644
93390 --- a/net/ipv4/xfrm4_policy.c
93391 +++ b/net/ipv4/xfrm4_policy.c
93392 @@ -181,11 +181,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
93393 fl4->flowi4_tos = iph->tos;
93394 }
93395
93396 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
93397 +static int xfrm4_garbage_collect(struct dst_ops *ops)
93398 {
93399 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
93400
93401 - xfrm4_policy_afinfo.garbage_collect(net);
93402 + xfrm_garbage_collect_deferred(net);
93403 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
93404 }
93405
93406 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
93407
93408 static int __net_init xfrm4_net_init(struct net *net)
93409 {
93410 - struct ctl_table *table;
93411 + ctl_table_no_const *table = NULL;
93412 struct ctl_table_header *hdr;
93413
93414 - table = xfrm4_policy_table;
93415 if (!net_eq(net, &init_net)) {
93416 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93417 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
93418 if (!table)
93419 goto err_alloc;
93420
93421 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
93422 - }
93423 -
93424 - hdr = register_net_sysctl(net, "net/ipv4", table);
93425 + hdr = register_net_sysctl(net, "net/ipv4", table);
93426 + } else
93427 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
93428 if (!hdr)
93429 goto err_reg;
93430
93431 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
93432 return 0;
93433
93434 err_reg:
93435 - if (!net_eq(net, &init_net))
93436 - kfree(table);
93437 + kfree(table);
93438 err_alloc:
93439 return -ENOMEM;
93440 }
93441 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
93442 index 0f99f7b..9375cf5 100644
93443 --- a/net/ipv6/addrconf.c
93444 +++ b/net/ipv6/addrconf.c
93445 @@ -618,7 +618,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
93446 idx = 0;
93447 head = &net->dev_index_head[h];
93448 rcu_read_lock();
93449 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
93450 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
93451 net->dev_base_seq;
93452 hlist_for_each_entry_rcu(dev, head, index_hlist) {
93453 if (idx < s_idx)
93454 @@ -2408,7 +2408,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
93455 p.iph.ihl = 5;
93456 p.iph.protocol = IPPROTO_IPV6;
93457 p.iph.ttl = 64;
93458 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
93459 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
93460
93461 if (ops->ndo_do_ioctl) {
93462 mm_segment_t oldfs = get_fs();
93463 @@ -4057,7 +4057,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
93464 s_ip_idx = ip_idx = cb->args[2];
93465
93466 rcu_read_lock();
93467 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93468 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
93469 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
93470 idx = 0;
93471 head = &net->dev_index_head[h];
93472 @@ -4678,7 +4678,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93473 dst_free(&ifp->rt->dst);
93474 break;
93475 }
93476 - atomic_inc(&net->ipv6.dev_addr_genid);
93477 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
93478 }
93479
93480 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
93481 @@ -4698,7 +4698,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
93482 int *valp = ctl->data;
93483 int val = *valp;
93484 loff_t pos = *ppos;
93485 - struct ctl_table lctl;
93486 + ctl_table_no_const lctl;
93487 int ret;
93488
93489 /*
93490 @@ -4783,7 +4783,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
93491 int *valp = ctl->data;
93492 int val = *valp;
93493 loff_t pos = *ppos;
93494 - struct ctl_table lctl;
93495 + ctl_table_no_const lctl;
93496 int ret;
93497
93498 /*
93499 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
93500 index 197e6f4..16d8396 100644
93501 --- a/net/ipv6/datagram.c
93502 +++ b/net/ipv6/datagram.c
93503 @@ -904,5 +904,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
93504 0,
93505 sock_i_ino(sp),
93506 atomic_read(&sp->sk_refcnt), sp,
93507 - atomic_read(&sp->sk_drops));
93508 + atomic_read_unchecked(&sp->sk_drops));
93509 }
93510 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
93511 index 7cfc8d2..c5394b6 100644
93512 --- a/net/ipv6/icmp.c
93513 +++ b/net/ipv6/icmp.c
93514 @@ -989,7 +989,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
93515
93516 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
93517 {
93518 - struct ctl_table *table;
93519 + ctl_table_no_const *table;
93520
93521 table = kmemdup(ipv6_icmp_table_template,
93522 sizeof(ipv6_icmp_table_template),
93523 diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
93524 index 32b4a16..066640e 100644
93525 --- a/net/ipv6/inet6_hashtables.c
93526 +++ b/net/ipv6/inet6_hashtables.c
93527 @@ -116,7 +116,7 @@ begintw:
93528 }
93529 if (unlikely(!INET6_TW_MATCH(sk, net, saddr, daddr,
93530 ports, dif))) {
93531 - sock_put(sk);
93532 + inet_twsk_put(inet_twsk(sk));
93533 goto begintw;
93534 }
93535 goto out;
93536 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
93537 index 8bc717b..76fbb5d 100644
93538 --- a/net/ipv6/ip6_gre.c
93539 +++ b/net/ipv6/ip6_gre.c
93540 @@ -74,7 +74,7 @@ struct ip6gre_net {
93541 struct net_device *fb_tunnel_dev;
93542 };
93543
93544 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
93545 +static struct rtnl_link_ops ip6gre_link_ops;
93546 static int ip6gre_tunnel_init(struct net_device *dev);
93547 static void ip6gre_tunnel_setup(struct net_device *dev);
93548 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
93549 @@ -1288,7 +1288,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
93550 }
93551
93552
93553 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
93554 +static struct inet6_protocol ip6gre_protocol = {
93555 .handler = ip6gre_rcv,
93556 .err_handler = ip6gre_err,
93557 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
93558 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
93559 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
93560 };
93561
93562 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93563 +static struct rtnl_link_ops ip6gre_link_ops = {
93564 .kind = "ip6gre",
93565 .maxtype = IFLA_GRE_MAX,
93566 .policy = ip6gre_policy,
93567 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
93568 .fill_info = ip6gre_fill_info,
93569 };
93570
93571 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
93572 +static struct rtnl_link_ops ip6gre_tap_ops = {
93573 .kind = "ip6gretap",
93574 .maxtype = IFLA_GRE_MAX,
93575 .policy = ip6gre_policy,
93576 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
93577 index 44df1c9..2e542d0 100644
93578 --- a/net/ipv6/ip6_output.c
93579 +++ b/net/ipv6/ip6_output.c
93580 @@ -1252,7 +1252,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
93581 skb = skb_peek_tail(&sk->sk_write_queue);
93582 cork->length += length;
93583 if (((length > mtu) ||
93584 - (skb && skb_is_gso(skb))) &&
93585 + (skb && skb_has_frags(skb))) &&
93586 (sk->sk_protocol == IPPROTO_UDP) &&
93587 (rt->dst.dev->features & NETIF_F_UFO)) {
93588 err = ip6_ufo_append_data(sk, getfrag, from, length,
93589 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
93590 index cf5d490..30946f0 100644
93591 --- a/net/ipv6/ip6_tunnel.c
93592 +++ b/net/ipv6/ip6_tunnel.c
93593 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
93594
93595 static int ip6_tnl_dev_init(struct net_device *dev);
93596 static void ip6_tnl_dev_setup(struct net_device *dev);
93597 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
93598 +static struct rtnl_link_ops ip6_link_ops;
93599
93600 static int ip6_tnl_net_id __read_mostly;
93601 struct ip6_tnl_net {
93602 @@ -1678,7 +1678,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
93603 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
93604 };
93605
93606 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
93607 +static struct rtnl_link_ops ip6_link_ops = {
93608 .kind = "ip6tnl",
93609 .maxtype = IFLA_IPTUN_MAX,
93610 .policy = ip6_tnl_policy,
93611 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
93612 index d1e2e8e..51c19ae 100644
93613 --- a/net/ipv6/ipv6_sockglue.c
93614 +++ b/net/ipv6/ipv6_sockglue.c
93615 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
93616 if (sk->sk_type != SOCK_STREAM)
93617 return -ENOPROTOOPT;
93618
93619 - msg.msg_control = optval;
93620 + msg.msg_control = (void __force_kernel *)optval;
93621 msg.msg_controllen = len;
93622 msg.msg_flags = flags;
93623
93624 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
93625 index 44400c2..8e11f52 100644
93626 --- a/net/ipv6/netfilter/ip6_tables.c
93627 +++ b/net/ipv6/netfilter/ip6_tables.c
93628 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
93629 #endif
93630
93631 static int get_info(struct net *net, void __user *user,
93632 - const int *len, int compat)
93633 + int len, int compat)
93634 {
93635 char name[XT_TABLE_MAXNAMELEN];
93636 struct xt_table *t;
93637 int ret;
93638
93639 - if (*len != sizeof(struct ip6t_getinfo)) {
93640 - duprintf("length %u != %zu\n", *len,
93641 + if (len != sizeof(struct ip6t_getinfo)) {
93642 + duprintf("length %u != %zu\n", len,
93643 sizeof(struct ip6t_getinfo));
93644 return -EINVAL;
93645 }
93646 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
93647 info.size = private->size;
93648 strcpy(info.name, name);
93649
93650 - if (copy_to_user(user, &info, *len) != 0)
93651 + if (copy_to_user(user, &info, len) != 0)
93652 ret = -EFAULT;
93653 else
93654 ret = 0;
93655 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93656
93657 switch (cmd) {
93658 case IP6T_SO_GET_INFO:
93659 - ret = get_info(sock_net(sk), user, len, 1);
93660 + ret = get_info(sock_net(sk), user, *len, 1);
93661 break;
93662 case IP6T_SO_GET_ENTRIES:
93663 ret = compat_get_entries(sock_net(sk), user, len);
93664 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93665
93666 switch (cmd) {
93667 case IP6T_SO_GET_INFO:
93668 - ret = get_info(sock_net(sk), user, len, 0);
93669 + ret = get_info(sock_net(sk), user, *len, 0);
93670 break;
93671
93672 case IP6T_SO_GET_ENTRIES:
93673 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
93674 index dffdc1a..ccc6678 100644
93675 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
93676 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
93677 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
93678
93679 static int nf_ct_frag6_sysctl_register(struct net *net)
93680 {
93681 - struct ctl_table *table;
93682 + ctl_table_no_const *table = NULL;
93683 struct ctl_table_header *hdr;
93684
93685 - table = nf_ct_frag6_sysctl_table;
93686 if (!net_eq(net, &init_net)) {
93687 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
93688 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
93689 GFP_KERNEL);
93690 if (table == NULL)
93691 goto err_alloc;
93692 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93693 table[0].data = &net->nf_frag.frags.timeout;
93694 table[1].data = &net->nf_frag.frags.low_thresh;
93695 table[2].data = &net->nf_frag.frags.high_thresh;
93696 - }
93697 -
93698 - hdr = register_net_sysctl(net, "net/netfilter", table);
93699 + hdr = register_net_sysctl(net, "net/netfilter", table);
93700 + } else
93701 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
93702 if (hdr == NULL)
93703 goto err_reg;
93704
93705 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
93706 return 0;
93707
93708 err_reg:
93709 - if (!net_eq(net, &init_net))
93710 - kfree(table);
93711 + kfree(table);
93712 err_alloc:
93713 return -ENOMEM;
93714 }
93715 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
93716 index ab92a36..bb4a528 100644
93717 --- a/net/ipv6/output_core.c
93718 +++ b/net/ipv6/output_core.c
93719 @@ -8,8 +8,8 @@
93720
93721 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93722 {
93723 - static atomic_t ipv6_fragmentation_id;
93724 - int old, new;
93725 + static atomic_unchecked_t ipv6_fragmentation_id;
93726 + int id;
93727
93728 #if IS_ENABLED(CONFIG_IPV6)
93729 if (rt && !(rt->dst.flags & DST_NOPEER)) {
93730 @@ -25,13 +25,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
93731 }
93732 }
93733 #endif
93734 - do {
93735 - old = atomic_read(&ipv6_fragmentation_id);
93736 - new = old + 1;
93737 - if (!new)
93738 - new = 1;
93739 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
93740 - fhdr->identification = htonl(new);
93741 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93742 + if (!id)
93743 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
93744 + fhdr->identification = htonl(id);
93745 }
93746 EXPORT_SYMBOL(ipv6_select_ident);
93747
93748 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
93749 index 18f19df..b46ada1 100644
93750 --- a/net/ipv6/ping.c
93751 +++ b/net/ipv6/ping.c
93752 @@ -245,6 +245,22 @@ static struct pernet_operations ping_v6_net_ops = {
93753 };
93754 #endif
93755
93756 +static struct pingv6_ops real_pingv6_ops = {
93757 + .ipv6_recv_error = ipv6_recv_error,
93758 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
93759 + .icmpv6_err_convert = icmpv6_err_convert,
93760 + .ipv6_icmp_error = ipv6_icmp_error,
93761 + .ipv6_chk_addr = ipv6_chk_addr,
93762 +};
93763 +
93764 +static struct pingv6_ops dummy_pingv6_ops = {
93765 + .ipv6_recv_error = dummy_ipv6_recv_error,
93766 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
93767 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
93768 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
93769 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
93770 +};
93771 +
93772 int __init pingv6_init(void)
93773 {
93774 #ifdef CONFIG_PROC_FS
93775 @@ -252,11 +268,7 @@ int __init pingv6_init(void)
93776 if (ret)
93777 return ret;
93778 #endif
93779 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
93780 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
93781 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
93782 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
93783 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
93784 + pingv6_ops = &real_pingv6_ops;
93785 return inet6_register_protosw(&pingv6_protosw);
93786 }
93787
93788 @@ -265,11 +277,7 @@ int __init pingv6_init(void)
93789 */
93790 void pingv6_exit(void)
93791 {
93792 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
93793 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
93794 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
93795 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
93796 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
93797 + pingv6_ops = &dummy_pingv6_ops;
93798 #ifdef CONFIG_PROC_FS
93799 unregister_pernet_subsys(&ping_v6_net_ops);
93800 #endif
93801 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
93802 index cdaed47..515edde9 100644
93803 --- a/net/ipv6/raw.c
93804 +++ b/net/ipv6/raw.c
93805 @@ -108,7 +108,7 @@ found:
93806 */
93807 static int icmpv6_filter(const struct sock *sk, const struct sk_buff *skb)
93808 {
93809 - struct icmp6hdr *_hdr;
93810 + struct icmp6hdr _hdr;
93811 const struct icmp6hdr *hdr;
93812
93813 hdr = skb_header_pointer(skb, skb_transport_offset(skb),
93814 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
93815 {
93816 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
93817 skb_checksum_complete(skb)) {
93818 - atomic_inc(&sk->sk_drops);
93819 + atomic_inc_unchecked(&sk->sk_drops);
93820 kfree_skb(skb);
93821 return NET_RX_DROP;
93822 }
93823 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93824 struct raw6_sock *rp = raw6_sk(sk);
93825
93826 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
93827 - atomic_inc(&sk->sk_drops);
93828 + atomic_inc_unchecked(&sk->sk_drops);
93829 kfree_skb(skb);
93830 return NET_RX_DROP;
93831 }
93832 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
93833
93834 if (inet->hdrincl) {
93835 if (skb_checksum_complete(skb)) {
93836 - atomic_inc(&sk->sk_drops);
93837 + atomic_inc_unchecked(&sk->sk_drops);
93838 kfree_skb(skb);
93839 return NET_RX_DROP;
93840 }
93841 @@ -602,7 +602,7 @@ out:
93842 return err;
93843 }
93844
93845 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
93846 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
93847 struct flowi6 *fl6, struct dst_entry **dstp,
93848 unsigned int flags)
93849 {
93850 @@ -915,12 +915,15 @@ do_confirm:
93851 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
93852 char __user *optval, int optlen)
93853 {
93854 + struct icmp6_filter filter;
93855 +
93856 switch (optname) {
93857 case ICMPV6_FILTER:
93858 if (optlen > sizeof(struct icmp6_filter))
93859 optlen = sizeof(struct icmp6_filter);
93860 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
93861 + if (copy_from_user(&filter, optval, optlen))
93862 return -EFAULT;
93863 + raw6_sk(sk)->filter = filter;
93864 return 0;
93865 default:
93866 return -ENOPROTOOPT;
93867 @@ -933,6 +936,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93868 char __user *optval, int __user *optlen)
93869 {
93870 int len;
93871 + struct icmp6_filter filter;
93872
93873 switch (optname) {
93874 case ICMPV6_FILTER:
93875 @@ -944,7 +948,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
93876 len = sizeof(struct icmp6_filter);
93877 if (put_user(len, optlen))
93878 return -EFAULT;
93879 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
93880 + filter = raw6_sk(sk)->filter;
93881 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
93882 return -EFAULT;
93883 return 0;
93884 default:
93885 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
93886 index 1aeb473..bea761c 100644
93887 --- a/net/ipv6/reassembly.c
93888 +++ b/net/ipv6/reassembly.c
93889 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
93890
93891 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93892 {
93893 - struct ctl_table *table;
93894 + ctl_table_no_const *table = NULL;
93895 struct ctl_table_header *hdr;
93896
93897 - table = ip6_frags_ns_ctl_table;
93898 if (!net_eq(net, &init_net)) {
93899 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93900 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
93901 if (table == NULL)
93902 goto err_alloc;
93903
93904 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93905 /* Don't export sysctls to unprivileged users */
93906 if (net->user_ns != &init_user_ns)
93907 table[0].procname = NULL;
93908 - }
93909 + hdr = register_net_sysctl(net, "net/ipv6", table);
93910 + } else
93911 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
93912
93913 - hdr = register_net_sysctl(net, "net/ipv6", table);
93914 if (hdr == NULL)
93915 goto err_reg;
93916
93917 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
93918 return 0;
93919
93920 err_reg:
93921 - if (!net_eq(net, &init_net))
93922 - kfree(table);
93923 + kfree(table);
93924 err_alloc:
93925 return -ENOMEM;
93926 }
93927 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
93928 index 8d9a93ed..cd89616 100644
93929 --- a/net/ipv6/route.c
93930 +++ b/net/ipv6/route.c
93931 @@ -2926,7 +2926,7 @@ struct ctl_table ipv6_route_table_template[] = {
93932
93933 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
93934 {
93935 - struct ctl_table *table;
93936 + ctl_table_no_const *table;
93937
93938 table = kmemdup(ipv6_route_table_template,
93939 sizeof(ipv6_route_table_template),
93940 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
93941 index 86f639b..71e355e 100644
93942 --- a/net/ipv6/sit.c
93943 +++ b/net/ipv6/sit.c
93944 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
93945 static void ipip6_dev_free(struct net_device *dev);
93946 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
93947 __be32 *v4dst);
93948 -static struct rtnl_link_ops sit_link_ops __read_mostly;
93949 +static struct rtnl_link_ops sit_link_ops;
93950
93951 static int sit_net_id __read_mostly;
93952 struct sit_net {
93953 @@ -1601,7 +1601,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
93954 #endif
93955 };
93956
93957 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
93958 +static struct rtnl_link_ops sit_link_ops = {
93959 .kind = "sit",
93960 .maxtype = IFLA_IPTUN_MAX,
93961 .policy = ipip6_policy,
93962 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
93963 index 107b2f1..72741a9 100644
93964 --- a/net/ipv6/sysctl_net_ipv6.c
93965 +++ b/net/ipv6/sysctl_net_ipv6.c
93966 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
93967
93968 static int __net_init ipv6_sysctl_net_init(struct net *net)
93969 {
93970 - struct ctl_table *ipv6_table;
93971 + ctl_table_no_const *ipv6_table;
93972 struct ctl_table *ipv6_route_table;
93973 struct ctl_table *ipv6_icmp_table;
93974 int err;
93975 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
93976 index 6e1649d..75ddb4c 100644
93977 --- a/net/ipv6/tcp_ipv6.c
93978 +++ b/net/ipv6/tcp_ipv6.c
93979 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
93980 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
93981 }
93982
93983 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93984 +extern int grsec_enable_blackhole;
93985 +#endif
93986 +
93987 static void tcp_v6_hash(struct sock *sk)
93988 {
93989 if (sk->sk_state != TCP_CLOSE) {
93990 @@ -1399,6 +1403,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
93991 return 0;
93992
93993 reset:
93994 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
93995 + if (!grsec_enable_blackhole)
93996 +#endif
93997 tcp_v6_send_reset(sk, skb);
93998 discard:
93999 if (opt_skb)
94000 @@ -1427,7 +1434,7 @@ ipv6_pktoptions:
94001 if (np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim)
94002 np->mcast_hops = ipv6_hdr(opt_skb)->hop_limit;
94003 if (np->rxopt.bits.rxtclass)
94004 - np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(skb));
94005 + np->rcv_tclass = ipv6_get_dsfield(ipv6_hdr(opt_skb));
94006 if (ipv6_opt_accepted(sk, opt_skb)) {
94007 skb_set_owner_r(opt_skb, sk);
94008 opt_skb = xchg(&np->pktoptions, opt_skb);
94009 @@ -1481,12 +1488,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
94010 TCP_SKB_CB(skb)->sacked = 0;
94011
94012 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
94013 - if (!sk)
94014 + if (!sk) {
94015 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94016 + ret = 1;
94017 +#endif
94018 goto no_tcp_socket;
94019 + }
94020
94021 process:
94022 - if (sk->sk_state == TCP_TIME_WAIT)
94023 + if (sk->sk_state == TCP_TIME_WAIT) {
94024 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94025 + ret = 2;
94026 +#endif
94027 goto do_time_wait;
94028 + }
94029
94030 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
94031 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
94032 @@ -1538,6 +1553,10 @@ csum_error:
94033 bad_packet:
94034 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
94035 } else {
94036 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94037 + if (!grsec_enable_blackhole || (ret == 1 &&
94038 + (skb->dev->flags & IFF_LOOPBACK)))
94039 +#endif
94040 tcp_v6_send_reset(NULL, skb);
94041 }
94042
94043 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
94044 index f405815..45a68a6 100644
94045 --- a/net/ipv6/udp.c
94046 +++ b/net/ipv6/udp.c
94047 @@ -53,6 +53,10 @@
94048 #include <trace/events/skb.h>
94049 #include "udp_impl.h"
94050
94051 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94052 +extern int grsec_enable_blackhole;
94053 +#endif
94054 +
94055 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
94056 {
94057 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
94058 @@ -420,7 +424,7 @@ try_again:
94059 if (unlikely(err)) {
94060 trace_kfree_skb(skb, udpv6_recvmsg);
94061 if (!peeked) {
94062 - atomic_inc(&sk->sk_drops);
94063 + atomic_inc_unchecked(&sk->sk_drops);
94064 if (is_udp4)
94065 UDP_INC_STATS_USER(sock_net(sk),
94066 UDP_MIB_INERRORS,
94067 @@ -666,7 +670,7 @@ csum_error:
94068 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
94069 drop:
94070 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
94071 - atomic_inc(&sk->sk_drops);
94072 + atomic_inc_unchecked(&sk->sk_drops);
94073 kfree_skb(skb);
94074 return -1;
94075 }
94076 @@ -724,7 +728,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
94077 if (likely(skb1 == NULL))
94078 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
94079 if (!skb1) {
94080 - atomic_inc(&sk->sk_drops);
94081 + atomic_inc_unchecked(&sk->sk_drops);
94082 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
94083 IS_UDPLITE(sk));
94084 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
94085 @@ -864,6 +868,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
94086 goto csum_error;
94087
94088 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
94089 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
94090 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
94091 +#endif
94092 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
94093
94094 kfree_skb(skb);
94095 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
94096 index 23ed03d..6532e67 100644
94097 --- a/net/ipv6/xfrm6_policy.c
94098 +++ b/net/ipv6/xfrm6_policy.c
94099 @@ -207,11 +207,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
94100 }
94101 }
94102
94103 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
94104 +static int xfrm6_garbage_collect(struct dst_ops *ops)
94105 {
94106 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
94107
94108 - xfrm6_policy_afinfo.garbage_collect(net);
94109 + xfrm_garbage_collect_deferred(net);
94110 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
94111 }
94112
94113 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
94114
94115 static int __net_init xfrm6_net_init(struct net *net)
94116 {
94117 - struct ctl_table *table;
94118 + ctl_table_no_const *table = NULL;
94119 struct ctl_table_header *hdr;
94120
94121 - table = xfrm6_policy_table;
94122 if (!net_eq(net, &init_net)) {
94123 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94124 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
94125 if (!table)
94126 goto err_alloc;
94127
94128 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
94129 - }
94130 + hdr = register_net_sysctl(net, "net/ipv6", table);
94131 + } else
94132 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
94133
94134 - hdr = register_net_sysctl(net, "net/ipv6", table);
94135 if (!hdr)
94136 goto err_reg;
94137
94138 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
94139 return 0;
94140
94141 err_reg:
94142 - if (!net_eq(net, &init_net))
94143 - kfree(table);
94144 + kfree(table);
94145 err_alloc:
94146 return -ENOMEM;
94147 }
94148 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
94149 index 41ac7938..75e3bb1 100644
94150 --- a/net/irda/ircomm/ircomm_tty.c
94151 +++ b/net/irda/ircomm/ircomm_tty.c
94152 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94153 add_wait_queue(&port->open_wait, &wait);
94154
94155 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
94156 - __FILE__, __LINE__, tty->driver->name, port->count);
94157 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94158
94159 spin_lock_irqsave(&port->lock, flags);
94160 if (!tty_hung_up_p(filp))
94161 - port->count--;
94162 + atomic_dec(&port->count);
94163 port->blocked_open++;
94164 spin_unlock_irqrestore(&port->lock, flags);
94165
94166 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94167 }
94168
94169 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
94170 - __FILE__, __LINE__, tty->driver->name, port->count);
94171 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94172
94173 schedule();
94174 }
94175 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
94176
94177 spin_lock_irqsave(&port->lock, flags);
94178 if (!tty_hung_up_p(filp))
94179 - port->count++;
94180 + atomic_inc(&port->count);
94181 port->blocked_open--;
94182 spin_unlock_irqrestore(&port->lock, flags);
94183
94184 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
94185 - __FILE__, __LINE__, tty->driver->name, port->count);
94186 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
94187
94188 if (!retval)
94189 port->flags |= ASYNC_NORMAL_ACTIVE;
94190 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
94191
94192 /* ++ is not atomic, so this should be protected - Jean II */
94193 spin_lock_irqsave(&self->port.lock, flags);
94194 - self->port.count++;
94195 + atomic_inc(&self->port.count);
94196 spin_unlock_irqrestore(&self->port.lock, flags);
94197 tty_port_tty_set(&self->port, tty);
94198
94199 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
94200 - self->line, self->port.count);
94201 + self->line, atomic_read(&self->port.count));
94202
94203 /* Not really used by us, but lets do it anyway */
94204 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
94205 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
94206 tty_kref_put(port->tty);
94207 }
94208 port->tty = NULL;
94209 - port->count = 0;
94210 + atomic_set(&port->count, 0);
94211 spin_unlock_irqrestore(&port->lock, flags);
94212
94213 wake_up_interruptible(&port->open_wait);
94214 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
94215 seq_putc(m, '\n');
94216
94217 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
94218 - seq_printf(m, "Open count: %d\n", self->port.count);
94219 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
94220 seq_printf(m, "Max data size: %d\n", self->max_data_size);
94221 seq_printf(m, "Max header size: %d\n", self->max_header_size);
94222
94223 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
94224 index 168aff5..9d43132 100644
94225 --- a/net/iucv/af_iucv.c
94226 +++ b/net/iucv/af_iucv.c
94227 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
94228
94229 write_lock_bh(&iucv_sk_list.lock);
94230
94231 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
94232 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94233 while (__iucv_get_sock_by_name(name)) {
94234 sprintf(name, "%08x",
94235 - atomic_inc_return(&iucv_sk_list.autobind_name));
94236 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
94237 }
94238
94239 write_unlock_bh(&iucv_sk_list.lock);
94240 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
94241 index cd5b8ec..f205e6b 100644
94242 --- a/net/iucv/iucv.c
94243 +++ b/net/iucv/iucv.c
94244 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
94245 return NOTIFY_OK;
94246 }
94247
94248 -static struct notifier_block __refdata iucv_cpu_notifier = {
94249 +static struct notifier_block iucv_cpu_notifier = {
94250 .notifier_call = iucv_cpu_notify,
94251 };
94252
94253 diff --git a/net/key/af_key.c b/net/key/af_key.c
94254 index ab8bd2c..3a3eb81 100644
94255 --- a/net/key/af_key.c
94256 +++ b/net/key/af_key.c
94257 @@ -1098,7 +1098,8 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
94258
94259 x->id.proto = proto;
94260 x->id.spi = sa->sadb_sa_spi;
94261 - x->props.replay_window = sa->sadb_sa_replay;
94262 + x->props.replay_window = min_t(unsigned int, sa->sadb_sa_replay,
94263 + (sizeof(x->replay.bitmap) * 8));
94264 if (sa->sadb_sa_flags & SADB_SAFLAGS_NOECN)
94265 x->props.flags |= XFRM_STATE_NOECN;
94266 if (sa->sadb_sa_flags & SADB_SAFLAGS_DECAP_DSCP)
94267 @@ -3048,10 +3049,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
94268 static u32 get_acqseq(void)
94269 {
94270 u32 res;
94271 - static atomic_t acqseq;
94272 + static atomic_unchecked_t acqseq;
94273
94274 do {
94275 - res = atomic_inc_return(&acqseq);
94276 + res = atomic_inc_return_unchecked(&acqseq);
94277 } while (!res);
94278 return res;
94279 }
94280 diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
94281 index feae495..aedaa2c 100644
94282 --- a/net/l2tp/l2tp_core.c
94283 +++ b/net/l2tp/l2tp_core.c
94284 @@ -496,6 +496,7 @@ out:
94285 static inline int l2tp_verify_udp_checksum(struct sock *sk,
94286 struct sk_buff *skb)
94287 {
94288 + struct l2tp_tunnel *tunnel = (struct l2tp_tunnel *)sk->sk_user_data;
94289 struct udphdr *uh = udp_hdr(skb);
94290 u16 ulen = ntohs(uh->len);
94291 __wsum psum;
94292 @@ -504,7 +505,7 @@ static inline int l2tp_verify_udp_checksum(struct sock *sk,
94293 return 0;
94294
94295 #if IS_ENABLED(CONFIG_IPV6)
94296 - if (sk->sk_family == PF_INET6) {
94297 + if (sk->sk_family == PF_INET6 && !tunnel->v4mapped) {
94298 if (!uh->check) {
94299 LIMIT_NETDEBUG(KERN_INFO "L2TP: IPv6: checksum is 0\n");
94300 return 1;
94301 @@ -1128,7 +1129,7 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
94302 /* Queue the packet to IP for output */
94303 skb->local_df = 1;
94304 #if IS_ENABLED(CONFIG_IPV6)
94305 - if (skb->sk->sk_family == PF_INET6)
94306 + if (skb->sk->sk_family == PF_INET6 && !tunnel->v4mapped)
94307 error = inet6_csk_xmit(skb, NULL);
94308 else
94309 #endif
94310 @@ -1255,7 +1256,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len
94311
94312 /* Calculate UDP checksum if configured to do so */
94313 #if IS_ENABLED(CONFIG_IPV6)
94314 - if (sk->sk_family == PF_INET6)
94315 + if (sk->sk_family == PF_INET6 && !tunnel->v4mapped)
94316 l2tp_xmit_ipv6_csum(sk, skb, udp_len);
94317 else
94318 #endif
94319 @@ -1704,6 +1705,24 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
94320 if (cfg != NULL)
94321 tunnel->debug = cfg->debug;
94322
94323 +#if IS_ENABLED(CONFIG_IPV6)
94324 + if (sk->sk_family == PF_INET6) {
94325 + struct ipv6_pinfo *np = inet6_sk(sk);
94326 +
94327 + if (ipv6_addr_v4mapped(&np->saddr) &&
94328 + ipv6_addr_v4mapped(&np->daddr)) {
94329 + struct inet_sock *inet = inet_sk(sk);
94330 +
94331 + tunnel->v4mapped = true;
94332 + inet->inet_saddr = np->saddr.s6_addr32[3];
94333 + inet->inet_rcv_saddr = np->rcv_saddr.s6_addr32[3];
94334 + inet->inet_daddr = np->daddr.s6_addr32[3];
94335 + } else {
94336 + tunnel->v4mapped = false;
94337 + }
94338 + }
94339 +#endif
94340 +
94341 /* Mark socket as an encapsulation socket. See net/ipv4/udp.c */
94342 tunnel->encap = encap;
94343 if (encap == L2TP_ENCAPTYPE_UDP) {
94344 @@ -1712,7 +1731,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
94345 udp_sk(sk)->encap_rcv = l2tp_udp_encap_recv;
94346 udp_sk(sk)->encap_destroy = l2tp_udp_encap_destroy;
94347 #if IS_ENABLED(CONFIG_IPV6)
94348 - if (sk->sk_family == PF_INET6)
94349 + if (sk->sk_family == PF_INET6 && !tunnel->v4mapped)
94350 udpv6_encap_enable();
94351 else
94352 #endif
94353 diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
94354 index 66a559b..6f251cb 100644
94355 --- a/net/l2tp/l2tp_core.h
94356 +++ b/net/l2tp/l2tp_core.h
94357 @@ -194,6 +194,9 @@ struct l2tp_tunnel {
94358 struct sock *sock; /* Parent socket */
94359 int fd; /* Parent fd, if tunnel socket
94360 * was created by userspace */
94361 +#if IS_ENABLED(CONFIG_IPV6)
94362 + bool v4mapped;
94363 +#endif
94364
94365 struct work_struct del_work;
94366
94367 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
94368 index 43dd752..63a23bc 100644
94369 --- a/net/mac80211/cfg.c
94370 +++ b/net/mac80211/cfg.c
94371 @@ -820,7 +820,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
94372 ret = ieee80211_vif_use_channel(sdata, chandef,
94373 IEEE80211_CHANCTX_EXCLUSIVE);
94374 }
94375 - } else if (local->open_count == local->monitors) {
94376 + } else if (local_read(&local->open_count) == local->monitors) {
94377 local->_oper_chandef = *chandef;
94378 ieee80211_hw_config(local, 0);
94379 }
94380 @@ -2941,7 +2941,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
94381 else
94382 local->probe_req_reg--;
94383
94384 - if (!local->open_count)
94385 + if (!local_read(&local->open_count))
94386 break;
94387
94388 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
94389 @@ -3404,8 +3404,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
94390 if (chanctx_conf) {
94391 *chandef = chanctx_conf->def;
94392 ret = 0;
94393 - } else if (local->open_count > 0 &&
94394 - local->open_count == local->monitors &&
94395 + } else if (local_read(&local->open_count) > 0 &&
94396 + local_read(&local->open_count) == local->monitors &&
94397 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
94398 if (local->use_chanctx)
94399 *chandef = local->monitor_chandef;
94400 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
94401 index 8412a30..6e00181 100644
94402 --- a/net/mac80211/ieee80211_i.h
94403 +++ b/net/mac80211/ieee80211_i.h
94404 @@ -28,6 +28,7 @@
94405 #include <net/ieee80211_radiotap.h>
94406 #include <net/cfg80211.h>
94407 #include <net/mac80211.h>
94408 +#include <asm/local.h>
94409 #include "key.h"
94410 #include "sta_info.h"
94411 #include "debug.h"
94412 @@ -907,7 +908,7 @@ struct ieee80211_local {
94413 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
94414 spinlock_t queue_stop_reason_lock;
94415
94416 - int open_count;
94417 + local_t open_count;
94418 int monitors, cooked_mntrs;
94419 /* number of interfaces with corresponding FIF_ flags */
94420 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
94421 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
94422 index cc11759..11d5541 100644
94423 --- a/net/mac80211/iface.c
94424 +++ b/net/mac80211/iface.c
94425 @@ -511,7 +511,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94426 break;
94427 }
94428
94429 - if (local->open_count == 0) {
94430 + if (local_read(&local->open_count) == 0) {
94431 res = drv_start(local);
94432 if (res)
94433 goto err_del_bss;
94434 @@ -558,7 +558,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94435 res = drv_add_interface(local, sdata);
94436 if (res)
94437 goto err_stop;
94438 - } else if (local->monitors == 0 && local->open_count == 0) {
94439 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
94440 res = ieee80211_add_virtual_monitor(local);
94441 if (res)
94442 goto err_stop;
94443 @@ -666,7 +666,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94444 atomic_inc(&local->iff_promiscs);
94445
94446 if (coming_up)
94447 - local->open_count++;
94448 + local_inc(&local->open_count);
94449
94450 if (hw_reconf_flags)
94451 ieee80211_hw_config(local, hw_reconf_flags);
94452 @@ -704,7 +704,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
94453 err_del_interface:
94454 drv_remove_interface(local, sdata);
94455 err_stop:
94456 - if (!local->open_count)
94457 + if (!local_read(&local->open_count))
94458 drv_stop(local);
94459 err_del_bss:
94460 sdata->bss = NULL;
94461 @@ -841,7 +841,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94462 }
94463
94464 if (going_down)
94465 - local->open_count--;
94466 + local_dec(&local->open_count);
94467
94468 switch (sdata->vif.type) {
94469 case NL80211_IFTYPE_AP_VLAN:
94470 @@ -908,7 +908,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94471 }
94472 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
94473
94474 - if (local->open_count == 0)
94475 + if (local_read(&local->open_count) == 0)
94476 ieee80211_clear_tx_pending(local);
94477
94478 /*
94479 @@ -948,7 +948,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94480
94481 ieee80211_recalc_ps(local, -1);
94482
94483 - if (local->open_count == 0) {
94484 + if (local_read(&local->open_count) == 0) {
94485 ieee80211_stop_device(local);
94486
94487 /* no reconfiguring after stop! */
94488 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
94489 ieee80211_configure_filter(local);
94490 ieee80211_hw_config(local, hw_reconf_flags);
94491
94492 - if (local->monitors == local->open_count)
94493 + if (local->monitors == local_read(&local->open_count))
94494 ieee80211_add_virtual_monitor(local);
94495 }
94496
94497 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
94498 index 091088a..daf43c7 100644
94499 --- a/net/mac80211/main.c
94500 +++ b/net/mac80211/main.c
94501 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
94502 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
94503 IEEE80211_CONF_CHANGE_POWER);
94504
94505 - if (changed && local->open_count) {
94506 + if (changed && local_read(&local->open_count)) {
94507 ret = drv_config(local, changed);
94508 /*
94509 * Goal:
94510 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
94511 index 3401262..d5cd68d 100644
94512 --- a/net/mac80211/pm.c
94513 +++ b/net/mac80211/pm.c
94514 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94515 struct ieee80211_sub_if_data *sdata;
94516 struct sta_info *sta;
94517
94518 - if (!local->open_count)
94519 + if (!local_read(&local->open_count))
94520 goto suspend;
94521
94522 ieee80211_scan_cancel(local);
94523 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94524 cancel_work_sync(&local->dynamic_ps_enable_work);
94525 del_timer_sync(&local->dynamic_ps_timer);
94526
94527 - local->wowlan = wowlan && local->open_count;
94528 + local->wowlan = wowlan && local_read(&local->open_count);
94529 if (local->wowlan) {
94530 int err = drv_suspend(local, wowlan);
94531 if (err < 0) {
94532 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
94533 WARN_ON(!list_empty(&local->chanctx_list));
94534
94535 /* stop hardware - this must stop RX */
94536 - if (local->open_count)
94537 + if (local_read(&local->open_count))
94538 ieee80211_stop_device(local);
94539
94540 suspend:
94541 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
94542 index 30d58d2..449ac8e 100644
94543 --- a/net/mac80211/rate.c
94544 +++ b/net/mac80211/rate.c
94545 @@ -718,7 +718,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
94546
94547 ASSERT_RTNL();
94548
94549 - if (local->open_count)
94550 + if (local_read(&local->open_count))
94551 return -EBUSY;
94552
94553 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
94554 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
94555 index c97a065..ff61928 100644
94556 --- a/net/mac80211/rc80211_pid_debugfs.c
94557 +++ b/net/mac80211/rc80211_pid_debugfs.c
94558 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
94559
94560 spin_unlock_irqrestore(&events->lock, status);
94561
94562 - if (copy_to_user(buf, pb, p))
94563 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
94564 return -EFAULT;
94565
94566 return p;
94567 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
94568 index 2265445..ba14971 100644
94569 --- a/net/mac80211/util.c
94570 +++ b/net/mac80211/util.c
94571 @@ -1452,7 +1452,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94572 }
94573 #endif
94574 /* everything else happens only if HW was up & running */
94575 - if (!local->open_count)
94576 + if (!local_read(&local->open_count))
94577 goto wake_up;
94578
94579 /*
94580 @@ -1677,7 +1677,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
94581 local->in_reconfig = false;
94582 barrier();
94583
94584 - if (local->monitors == local->open_count && local->monitors > 0)
94585 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
94586 ieee80211_add_virtual_monitor(local);
94587
94588 /*
94589 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
94590 index 56d22ca..87c778f 100644
94591 --- a/net/netfilter/Kconfig
94592 +++ b/net/netfilter/Kconfig
94593 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
94594
94595 To compile it as a module, choose M here. If unsure, say N.
94596
94597 +config NETFILTER_XT_MATCH_GRADM
94598 + tristate '"gradm" match support'
94599 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
94600 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
94601 + ---help---
94602 + The gradm match allows to match on grsecurity RBAC being enabled.
94603 + It is useful when iptables rules are applied early on bootup to
94604 + prevent connections to the machine (except from a trusted host)
94605 + while the RBAC system is disabled.
94606 +
94607 config NETFILTER_XT_MATCH_HASHLIMIT
94608 tristate '"hashlimit" match support'
94609 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
94610 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
94611 index a1abf87..dbcb7ee 100644
94612 --- a/net/netfilter/Makefile
94613 +++ b/net/netfilter/Makefile
94614 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
94615 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
94616 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
94617 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
94618 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
94619 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
94620 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
94621 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
94622 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
94623 index f771390..145b765 100644
94624 --- a/net/netfilter/ipset/ip_set_core.c
94625 +++ b/net/netfilter/ipset/ip_set_core.c
94626 @@ -1820,7 +1820,7 @@ done:
94627 return ret;
94628 }
94629
94630 -static struct nf_sockopt_ops so_set __read_mostly = {
94631 +static struct nf_sockopt_ops so_set = {
94632 .pf = PF_INET,
94633 .get_optmin = SO_IP_SET,
94634 .get_optmax = SO_IP_SET + 1,
94635 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
94636 index 4c8e5c0..5a79b4d 100644
94637 --- a/net/netfilter/ipvs/ip_vs_conn.c
94638 +++ b/net/netfilter/ipvs/ip_vs_conn.c
94639 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
94640 /* Increase the refcnt counter of the dest */
94641 ip_vs_dest_hold(dest);
94642
94643 - conn_flags = atomic_read(&dest->conn_flags);
94644 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
94645 if (cp->protocol != IPPROTO_UDP)
94646 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
94647 flags = cp->flags;
94648 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
94649
94650 cp->control = NULL;
94651 atomic_set(&cp->n_control, 0);
94652 - atomic_set(&cp->in_pkts, 0);
94653 + atomic_set_unchecked(&cp->in_pkts, 0);
94654
94655 cp->packet_xmit = NULL;
94656 cp->app = NULL;
94657 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
94658
94659 /* Don't drop the entry if its number of incoming packets is not
94660 located in [0, 8] */
94661 - i = atomic_read(&cp->in_pkts);
94662 + i = atomic_read_unchecked(&cp->in_pkts);
94663 if (i > 8 || i < 0) return 0;
94664
94665 if (!todrop_rate[i]) return 0;
94666 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
94667 index 4f69e83..da2d8bf 100644
94668 --- a/net/netfilter/ipvs/ip_vs_core.c
94669 +++ b/net/netfilter/ipvs/ip_vs_core.c
94670 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
94671 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
94672 /* do not touch skb anymore */
94673
94674 - atomic_inc(&cp->in_pkts);
94675 + atomic_inc_unchecked(&cp->in_pkts);
94676 ip_vs_conn_put(cp);
94677 return ret;
94678 }
94679 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
94680 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
94681 pkts = sysctl_sync_threshold(ipvs);
94682 else
94683 - pkts = atomic_add_return(1, &cp->in_pkts);
94684 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94685
94686 if (ipvs->sync_state & IP_VS_STATE_MASTER)
94687 ip_vs_sync_conn(net, cp, pkts);
94688 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
94689 index c8148e4..eff604f 100644
94690 --- a/net/netfilter/ipvs/ip_vs_ctl.c
94691 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
94692 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
94693 */
94694 ip_vs_rs_hash(ipvs, dest);
94695 }
94696 - atomic_set(&dest->conn_flags, conn_flags);
94697 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
94698
94699 /* bind the service */
94700 if (!dest->svc) {
94701 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
94702 * align with netns init in ip_vs_control_net_init()
94703 */
94704
94705 -static struct ctl_table vs_vars[] = {
94706 +static ctl_table_no_const vs_vars[] __read_only = {
94707 {
94708 .procname = "amemthresh",
94709 .maxlen = sizeof(int),
94710 @@ -2078,7 +2078,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94711 " %-7s %-6d %-10d %-10d\n",
94712 &dest->addr.in6,
94713 ntohs(dest->port),
94714 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94715 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94716 atomic_read(&dest->weight),
94717 atomic_read(&dest->activeconns),
94718 atomic_read(&dest->inactconns));
94719 @@ -2089,7 +2089,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
94720 "%-7s %-6d %-10d %-10d\n",
94721 ntohl(dest->addr.ip),
94722 ntohs(dest->port),
94723 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
94724 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
94725 atomic_read(&dest->weight),
94726 atomic_read(&dest->activeconns),
94727 atomic_read(&dest->inactconns));
94728 @@ -2567,7 +2567,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
94729
94730 entry.addr = dest->addr.ip;
94731 entry.port = dest->port;
94732 - entry.conn_flags = atomic_read(&dest->conn_flags);
94733 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
94734 entry.weight = atomic_read(&dest->weight);
94735 entry.u_threshold = dest->u_threshold;
94736 entry.l_threshold = dest->l_threshold;
94737 @@ -3110,7 +3110,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
94738 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
94739 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
94740 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
94741 - (atomic_read(&dest->conn_flags) &
94742 + (atomic_read_unchecked(&dest->conn_flags) &
94743 IP_VS_CONN_F_FWD_MASK)) ||
94744 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
94745 atomic_read(&dest->weight)) ||
94746 @@ -3700,7 +3700,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
94747 {
94748 int idx;
94749 struct netns_ipvs *ipvs = net_ipvs(net);
94750 - struct ctl_table *tbl;
94751 + ctl_table_no_const *tbl;
94752
94753 atomic_set(&ipvs->dropentry, 0);
94754 spin_lock_init(&ipvs->dropentry_lock);
94755 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
94756 index 1383b0e..a486da1 100644
94757 --- a/net/netfilter/ipvs/ip_vs_lblc.c
94758 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
94759 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
94760 * IPVS LBLC sysctl table
94761 */
94762 #ifdef CONFIG_SYSCTL
94763 -static struct ctl_table vs_vars_table[] = {
94764 +static ctl_table_no_const vs_vars_table[] __read_only = {
94765 {
94766 .procname = "lblc_expiration",
94767 .data = NULL,
94768 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
94769 index 3cd85b2..dfab2b8 100644
94770 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
94771 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
94772 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
94773 * IPVS LBLCR sysctl table
94774 */
94775
94776 -static struct ctl_table vs_vars_table[] = {
94777 +static ctl_table_no_const vs_vars_table[] __read_only = {
94778 {
94779 .procname = "lblcr_expiration",
94780 .data = NULL,
94781 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
94782 index f448471..995f131 100644
94783 --- a/net/netfilter/ipvs/ip_vs_sync.c
94784 +++ b/net/netfilter/ipvs/ip_vs_sync.c
94785 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
94786 cp = cp->control;
94787 if (cp) {
94788 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94789 - pkts = atomic_add_return(1, &cp->in_pkts);
94790 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94791 else
94792 pkts = sysctl_sync_threshold(ipvs);
94793 ip_vs_sync_conn(net, cp->control, pkts);
94794 @@ -771,7 +771,7 @@ control:
94795 if (!cp)
94796 return;
94797 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
94798 - pkts = atomic_add_return(1, &cp->in_pkts);
94799 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
94800 else
94801 pkts = sysctl_sync_threshold(ipvs);
94802 goto sloop;
94803 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
94804
94805 if (opt)
94806 memcpy(&cp->in_seq, opt, sizeof(*opt));
94807 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94808 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
94809 cp->state = state;
94810 cp->old_state = cp->state;
94811 /*
94812 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
94813 index c47444e..b0961c6 100644
94814 --- a/net/netfilter/ipvs/ip_vs_xmit.c
94815 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
94816 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
94817 else
94818 rc = NF_ACCEPT;
94819 /* do not touch skb anymore */
94820 - atomic_inc(&cp->in_pkts);
94821 + atomic_inc_unchecked(&cp->in_pkts);
94822 goto out;
94823 }
94824
94825 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
94826 else
94827 rc = NF_ACCEPT;
94828 /* do not touch skb anymore */
94829 - atomic_inc(&cp->in_pkts);
94830 + atomic_inc_unchecked(&cp->in_pkts);
94831 goto out;
94832 }
94833
94834 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
94835 index 2d3030a..7ba1c0a 100644
94836 --- a/net/netfilter/nf_conntrack_acct.c
94837 +++ b/net/netfilter/nf_conntrack_acct.c
94838 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
94839 #ifdef CONFIG_SYSCTL
94840 static int nf_conntrack_acct_init_sysctl(struct net *net)
94841 {
94842 - struct ctl_table *table;
94843 + ctl_table_no_const *table;
94844
94845 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
94846 GFP_KERNEL);
94847 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
94848 index 0283bae..5febcb0 100644
94849 --- a/net/netfilter/nf_conntrack_core.c
94850 +++ b/net/netfilter/nf_conntrack_core.c
94851 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
94852 #define DYING_NULLS_VAL ((1<<30)+1)
94853 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
94854
94855 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94856 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
94857 +#endif
94858 +
94859 int nf_conntrack_init_net(struct net *net)
94860 {
94861 int ret;
94862 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
94863 goto err_stat;
94864 }
94865
94866 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94867 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
94868 +#else
94869 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
94870 +#endif
94871 if (!net->ct.slabname) {
94872 ret = -ENOMEM;
94873 goto err_slabname;
94874 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
94875 index 1df1761..ce8b88a 100644
94876 --- a/net/netfilter/nf_conntrack_ecache.c
94877 +++ b/net/netfilter/nf_conntrack_ecache.c
94878 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
94879 #ifdef CONFIG_SYSCTL
94880 static int nf_conntrack_event_init_sysctl(struct net *net)
94881 {
94882 - struct ctl_table *table;
94883 + ctl_table_no_const *table;
94884
94885 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
94886 GFP_KERNEL);
94887 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
94888 index 974a2a4..52cc6ff 100644
94889 --- a/net/netfilter/nf_conntrack_helper.c
94890 +++ b/net/netfilter/nf_conntrack_helper.c
94891 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
94892
94893 static int nf_conntrack_helper_init_sysctl(struct net *net)
94894 {
94895 - struct ctl_table *table;
94896 + ctl_table_no_const *table;
94897
94898 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
94899 GFP_KERNEL);
94900 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
94901 index 0ab9636..cea3c6a 100644
94902 --- a/net/netfilter/nf_conntrack_proto.c
94903 +++ b/net/netfilter/nf_conntrack_proto.c
94904 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
94905
94906 static void
94907 nf_ct_unregister_sysctl(struct ctl_table_header **header,
94908 - struct ctl_table **table,
94909 + ctl_table_no_const **table,
94910 unsigned int users)
94911 {
94912 if (users > 0)
94913 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
94914 index a99b6c3..cb372f9 100644
94915 --- a/net/netfilter/nf_conntrack_proto_dccp.c
94916 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
94917 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94918 const char *msg;
94919 u_int8_t state;
94920
94921 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94922 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94923 BUG_ON(dh == NULL);
94924
94925 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
94926 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
94927 out_invalid:
94928 if (LOG_INVALID(net, IPPROTO_DCCP))
94929 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
94930 - NULL, msg);
94931 + NULL, "%s", msg);
94932 return false;
94933 }
94934
94935 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
94936 u_int8_t type, old_state, new_state;
94937 enum ct_dccp_roles role;
94938
94939 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94940 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94941 BUG_ON(dh == NULL);
94942 type = dh->dccph_type;
94943
94944 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94945 unsigned int cscov;
94946 const char *msg;
94947
94948 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
94949 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
94950 if (dh == NULL) {
94951 msg = "nf_ct_dccp: short packet ";
94952 goto out_invalid;
94953 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
94954
94955 out_invalid:
94956 if (LOG_INVALID(net, IPPROTO_DCCP))
94957 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
94958 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
94959 return -NF_ACCEPT;
94960 }
94961
94962 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
94963 index f641751..d3c5b51 100644
94964 --- a/net/netfilter/nf_conntrack_standalone.c
94965 +++ b/net/netfilter/nf_conntrack_standalone.c
94966 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
94967
94968 static int nf_conntrack_standalone_init_sysctl(struct net *net)
94969 {
94970 - struct ctl_table *table;
94971 + ctl_table_no_const *table;
94972
94973 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
94974 GFP_KERNEL);
94975 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
94976 index 902fb0a..87f7fdb 100644
94977 --- a/net/netfilter/nf_conntrack_timestamp.c
94978 +++ b/net/netfilter/nf_conntrack_timestamp.c
94979 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
94980 #ifdef CONFIG_SYSCTL
94981 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
94982 {
94983 - struct ctl_table *table;
94984 + ctl_table_no_const *table;
94985
94986 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
94987 GFP_KERNEL);
94988 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
94989 index 85296d4..8becdec 100644
94990 --- a/net/netfilter/nf_log.c
94991 +++ b/net/netfilter/nf_log.c
94992 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
94993
94994 #ifdef CONFIG_SYSCTL
94995 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
94996 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
94997 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
94998
94999 static int nf_log_proc_dostring(struct ctl_table *table, int write,
95000 void __user *buffer, size_t *lenp, loff_t *ppos)
95001 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
95002 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
95003 mutex_unlock(&nf_log_mutex);
95004 } else {
95005 + ctl_table_no_const nf_log_table = *table;
95006 +
95007 mutex_lock(&nf_log_mutex);
95008 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
95009 lockdep_is_held(&nf_log_mutex));
95010 if (!logger)
95011 - table->data = "NONE";
95012 + nf_log_table.data = "NONE";
95013 else
95014 - table->data = logger->name;
95015 - r = proc_dostring(table, write, buffer, lenp, ppos);
95016 + nf_log_table.data = logger->name;
95017 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
95018 mutex_unlock(&nf_log_mutex);
95019 }
95020
95021 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
95022 index f042ae5..30ea486 100644
95023 --- a/net/netfilter/nf_sockopt.c
95024 +++ b/net/netfilter/nf_sockopt.c
95025 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
95026 }
95027 }
95028
95029 - list_add(&reg->list, &nf_sockopts);
95030 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
95031 out:
95032 mutex_unlock(&nf_sockopt_mutex);
95033 return ret;
95034 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
95035 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
95036 {
95037 mutex_lock(&nf_sockopt_mutex);
95038 - list_del(&reg->list);
95039 + pax_list_del((struct list_head *)&reg->list);
95040 mutex_unlock(&nf_sockopt_mutex);
95041 }
95042 EXPORT_SYMBOL(nf_unregister_sockopt);
95043 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
95044 index d92cc31..e46f350 100644
95045 --- a/net/netfilter/nfnetlink_log.c
95046 +++ b/net/netfilter/nfnetlink_log.c
95047 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
95048 struct nfnl_log_net {
95049 spinlock_t instances_lock;
95050 struct hlist_head instance_table[INSTANCE_BUCKETS];
95051 - atomic_t global_seq;
95052 + atomic_unchecked_t global_seq;
95053 };
95054
95055 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
95056 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
95057 /* global sequence number */
95058 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
95059 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
95060 - htonl(atomic_inc_return(&log->global_seq))))
95061 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
95062 goto nla_put_failure;
95063
95064 if (data_len) {
95065 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
95066 new file mode 100644
95067 index 0000000..c566332
95068 --- /dev/null
95069 +++ b/net/netfilter/xt_gradm.c
95070 @@ -0,0 +1,51 @@
95071 +/*
95072 + * gradm match for netfilter
95073 + * Copyright © Zbigniew Krzystolik, 2010
95074 + *
95075 + * This program is free software; you can redistribute it and/or modify
95076 + * it under the terms of the GNU General Public License; either version
95077 + * 2 or 3 as published by the Free Software Foundation.
95078 + */
95079 +#include <linux/module.h>
95080 +#include <linux/moduleparam.h>
95081 +#include <linux/skbuff.h>
95082 +#include <linux/netfilter/x_tables.h>
95083 +#include <linux/grsecurity.h>
95084 +#include <linux/netfilter/xt_gradm.h>
95085 +
95086 +static bool
95087 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
95088 +{
95089 + const struct xt_gradm_mtinfo *info = par->matchinfo;
95090 + bool retval = false;
95091 + if (gr_acl_is_enabled())
95092 + retval = true;
95093 + return retval ^ info->invflags;
95094 +}
95095 +
95096 +static struct xt_match gradm_mt_reg __read_mostly = {
95097 + .name = "gradm",
95098 + .revision = 0,
95099 + .family = NFPROTO_UNSPEC,
95100 + .match = gradm_mt,
95101 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
95102 + .me = THIS_MODULE,
95103 +};
95104 +
95105 +static int __init gradm_mt_init(void)
95106 +{
95107 + return xt_register_match(&gradm_mt_reg);
95108 +}
95109 +
95110 +static void __exit gradm_mt_exit(void)
95111 +{
95112 + xt_unregister_match(&gradm_mt_reg);
95113 +}
95114 +
95115 +module_init(gradm_mt_init);
95116 +module_exit(gradm_mt_exit);
95117 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
95118 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
95119 +MODULE_LICENSE("GPL");
95120 +MODULE_ALIAS("ipt_gradm");
95121 +MODULE_ALIAS("ip6t_gradm");
95122 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
95123 index 4fe4fb4..87a89e5 100644
95124 --- a/net/netfilter/xt_statistic.c
95125 +++ b/net/netfilter/xt_statistic.c
95126 @@ -19,7 +19,7 @@
95127 #include <linux/module.h>
95128
95129 struct xt_statistic_priv {
95130 - atomic_t count;
95131 + atomic_unchecked_t count;
95132 } ____cacheline_aligned_in_smp;
95133
95134 MODULE_LICENSE("GPL");
95135 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
95136 break;
95137 case XT_STATISTIC_MODE_NTH:
95138 do {
95139 - oval = atomic_read(&info->master->count);
95140 + oval = atomic_read_unchecked(&info->master->count);
95141 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
95142 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
95143 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
95144 if (nval == 0)
95145 ret = !ret;
95146 break;
95147 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
95148 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
95149 if (info->master == NULL)
95150 return -ENOMEM;
95151 - atomic_set(&info->master->count, info->u.nth.count);
95152 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
95153
95154 return 0;
95155 }
95156 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
95157 index 0c61b59..941bddd 100644
95158 --- a/net/netlink/af_netlink.c
95159 +++ b/net/netlink/af_netlink.c
95160 @@ -219,7 +219,7 @@ static void netlink_overrun(struct sock *sk)
95161 sk->sk_error_report(sk);
95162 }
95163 }
95164 - atomic_inc(&sk->sk_drops);
95165 + atomic_inc_unchecked(&sk->sk_drops);
95166 }
95167
95168 static void netlink_rcv_wake(struct sock *sk)
95169 @@ -2925,7 +2925,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
95170 sk_wmem_alloc_get(s),
95171 nlk->cb,
95172 atomic_read(&s->sk_refcnt),
95173 - atomic_read(&s->sk_drops),
95174 + atomic_read_unchecked(&s->sk_drops),
95175 sock_i_ino(s)
95176 );
95177
95178 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
95179 index 0c741ce..f8c8ca7 100644
95180 --- a/net/netlink/genetlink.c
95181 +++ b/net/netlink/genetlink.c
95182 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
95183 goto errout;
95184 }
95185
95186 + pax_open_kernel();
95187 if (ops->dumpit)
95188 - ops->flags |= GENL_CMD_CAP_DUMP;
95189 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
95190 if (ops->doit)
95191 - ops->flags |= GENL_CMD_CAP_DO;
95192 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
95193 if (ops->policy)
95194 - ops->flags |= GENL_CMD_CAP_HASPOL;
95195 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
95196 + pax_close_kernel();
95197
95198 genl_lock_all();
95199 - list_add_tail(&ops->ops_list, &family->ops_list);
95200 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
95201 genl_unlock_all();
95202
95203 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
95204 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
95205 err = 0;
95206 errout:
95207 return err;
95208 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
95209 genl_lock_all();
95210 list_for_each_entry(rc, &family->ops_list, ops_list) {
95211 if (rc == ops) {
95212 - list_del(&ops->ops_list);
95213 + pax_list_del((struct list_head *)&ops->ops_list);
95214 genl_unlock_all();
95215 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
95216 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
95217 return 0;
95218 }
95219 }
95220 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
95221 index 698814b..7cfde4e 100644
95222 --- a/net/netrom/af_netrom.c
95223 +++ b/net/netrom/af_netrom.c
95224 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
95225 *uaddr_len = sizeof(struct full_sockaddr_ax25);
95226 } else {
95227 sax->fsa_ax25.sax25_family = AF_NETROM;
95228 - sax->fsa_ax25.sax25_ndigis = 0;
95229 sax->fsa_ax25.sax25_call = nr->source_addr;
95230 *uaddr_len = sizeof(struct sockaddr_ax25);
95231 }
95232 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
95233 index 75c8bbf..ee9be59 100644
95234 --- a/net/packet/af_packet.c
95235 +++ b/net/packet/af_packet.c
95236 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95237
95238 spin_lock(&sk->sk_receive_queue.lock);
95239 po->stats.stats1.tp_packets++;
95240 - skb->dropcount = atomic_read(&sk->sk_drops);
95241 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
95242 __skb_queue_tail(&sk->sk_receive_queue, skb);
95243 spin_unlock(&sk->sk_receive_queue.lock);
95244 sk->sk_data_ready(sk, skb->len);
95245 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
95246 drop_n_acct:
95247 spin_lock(&sk->sk_receive_queue.lock);
95248 po->stats.stats1.tp_drops++;
95249 - atomic_inc(&sk->sk_drops);
95250 + atomic_inc_unchecked(&sk->sk_drops);
95251 spin_unlock(&sk->sk_receive_queue.lock);
95252
95253 drop_n_restore:
95254 @@ -2640,6 +2640,7 @@ out:
95255
95256 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95257 {
95258 + struct sock_extended_err ee;
95259 struct sock_exterr_skb *serr;
95260 struct sk_buff *skb, *skb2;
95261 int copied, err;
95262 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
95263 sock_recv_timestamp(msg, sk, skb);
95264
95265 serr = SKB_EXT_ERR(skb);
95266 + ee = serr->ee;
95267 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
95268 - sizeof(serr->ee), &serr->ee);
95269 + sizeof ee, &ee);
95270
95271 msg->msg_flags |= MSG_ERRQUEUE;
95272 err = copied;
95273 @@ -3283,7 +3285,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95274 case PACKET_HDRLEN:
95275 if (len > sizeof(int))
95276 len = sizeof(int);
95277 - if (copy_from_user(&val, optval, len))
95278 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
95279 return -EFAULT;
95280 switch (val) {
95281 case TPACKET_V1:
95282 @@ -3326,7 +3328,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
95283 len = lv;
95284 if (put_user(len, optlen))
95285 return -EFAULT;
95286 - if (copy_to_user(optval, data, len))
95287 + if (len > sizeof(st) || copy_to_user(optval, data, len))
95288 return -EFAULT;
95289 return 0;
95290 }
95291 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
95292 index e774117..900b8b7 100644
95293 --- a/net/phonet/pep.c
95294 +++ b/net/phonet/pep.c
95295 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95296
95297 case PNS_PEP_CTRL_REQ:
95298 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
95299 - atomic_inc(&sk->sk_drops);
95300 + atomic_inc_unchecked(&sk->sk_drops);
95301 break;
95302 }
95303 __skb_pull(skb, 4);
95304 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
95305 }
95306
95307 if (pn->rx_credits == 0) {
95308 - atomic_inc(&sk->sk_drops);
95309 + atomic_inc_unchecked(&sk->sk_drops);
95310 err = -ENOBUFS;
95311 break;
95312 }
95313 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
95314 }
95315
95316 if (pn->rx_credits == 0) {
95317 - atomic_inc(&sk->sk_drops);
95318 + atomic_inc_unchecked(&sk->sk_drops);
95319 err = NET_RX_DROP;
95320 break;
95321 }
95322 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
95323 index 1afd138..0b42453 100644
95324 --- a/net/phonet/socket.c
95325 +++ b/net/phonet/socket.c
95326 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
95327 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
95328 sock_i_ino(sk),
95329 atomic_read(&sk->sk_refcnt), sk,
95330 - atomic_read(&sk->sk_drops), &len);
95331 + atomic_read_unchecked(&sk->sk_drops), &len);
95332 }
95333 seq_printf(seq, "%*s\n", 127 - len, "");
95334 return 0;
95335 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
95336 index c02a8c4..3c5b600 100644
95337 --- a/net/phonet/sysctl.c
95338 +++ b/net/phonet/sysctl.c
95339 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
95340 {
95341 int ret;
95342 int range[2] = {local_port_range[0], local_port_range[1]};
95343 - struct ctl_table tmp = {
95344 + ctl_table_no_const tmp = {
95345 .data = &range,
95346 .maxlen = sizeof(range),
95347 .mode = table->mode,
95348 diff --git a/net/rds/cong.c b/net/rds/cong.c
95349 index e5b65ac..f3b6fb7 100644
95350 --- a/net/rds/cong.c
95351 +++ b/net/rds/cong.c
95352 @@ -78,7 +78,7 @@
95353 * finds that the saved generation number is smaller than the global generation
95354 * number, it wakes up the process.
95355 */
95356 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
95357 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
95358
95359 /*
95360 * Congestion monitoring
95361 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
95362 rdsdebug("waking map %p for %pI4\n",
95363 map, &map->m_addr);
95364 rds_stats_inc(s_cong_update_received);
95365 - atomic_inc(&rds_cong_generation);
95366 + atomic_inc_unchecked(&rds_cong_generation);
95367 if (waitqueue_active(&map->m_waitq))
95368 wake_up(&map->m_waitq);
95369 if (waitqueue_active(&rds_poll_waitq))
95370 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
95371
95372 int rds_cong_updated_since(unsigned long *recent)
95373 {
95374 - unsigned long gen = atomic_read(&rds_cong_generation);
95375 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
95376
95377 if (likely(*recent == gen))
95378 return 0;
95379 diff --git a/net/rds/ib.h b/net/rds/ib.h
95380 index 7280ab8..e04f4ea 100644
95381 --- a/net/rds/ib.h
95382 +++ b/net/rds/ib.h
95383 @@ -128,7 +128,7 @@ struct rds_ib_connection {
95384 /* sending acks */
95385 unsigned long i_ack_flags;
95386 #ifdef KERNEL_HAS_ATOMIC64
95387 - atomic64_t i_ack_next; /* next ACK to send */
95388 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95389 #else
95390 spinlock_t i_ack_lock; /* protect i_ack_next */
95391 u64 i_ack_next; /* next ACK to send */
95392 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
95393 index 31b74f5..dc1fbfa 100644
95394 --- a/net/rds/ib_cm.c
95395 +++ b/net/rds/ib_cm.c
95396 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
95397 /* Clear the ACK state */
95398 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95399 #ifdef KERNEL_HAS_ATOMIC64
95400 - atomic64_set(&ic->i_ack_next, 0);
95401 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95402 #else
95403 ic->i_ack_next = 0;
95404 #endif
95405 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
95406 index 8eb9501..0c386ff 100644
95407 --- a/net/rds/ib_recv.c
95408 +++ b/net/rds/ib_recv.c
95409 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95410 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
95411 int ack_required)
95412 {
95413 - atomic64_set(&ic->i_ack_next, seq);
95414 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95415 if (ack_required) {
95416 smp_mb__before_clear_bit();
95417 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95418 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
95419 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95420 smp_mb__after_clear_bit();
95421
95422 - return atomic64_read(&ic->i_ack_next);
95423 + return atomic64_read_unchecked(&ic->i_ack_next);
95424 }
95425 #endif
95426
95427 diff --git a/net/rds/iw.h b/net/rds/iw.h
95428 index 04ce3b1..48119a6 100644
95429 --- a/net/rds/iw.h
95430 +++ b/net/rds/iw.h
95431 @@ -134,7 +134,7 @@ struct rds_iw_connection {
95432 /* sending acks */
95433 unsigned long i_ack_flags;
95434 #ifdef KERNEL_HAS_ATOMIC64
95435 - atomic64_t i_ack_next; /* next ACK to send */
95436 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
95437 #else
95438 spinlock_t i_ack_lock; /* protect i_ack_next */
95439 u64 i_ack_next; /* next ACK to send */
95440 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
95441 index a91e1db..cf3053f 100644
95442 --- a/net/rds/iw_cm.c
95443 +++ b/net/rds/iw_cm.c
95444 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
95445 /* Clear the ACK state */
95446 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
95447 #ifdef KERNEL_HAS_ATOMIC64
95448 - atomic64_set(&ic->i_ack_next, 0);
95449 + atomic64_set_unchecked(&ic->i_ack_next, 0);
95450 #else
95451 ic->i_ack_next = 0;
95452 #endif
95453 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
95454 index 4503335..db566b4 100644
95455 --- a/net/rds/iw_recv.c
95456 +++ b/net/rds/iw_recv.c
95457 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95458 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
95459 int ack_required)
95460 {
95461 - atomic64_set(&ic->i_ack_next, seq);
95462 + atomic64_set_unchecked(&ic->i_ack_next, seq);
95463 if (ack_required) {
95464 smp_mb__before_clear_bit();
95465 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95466 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
95467 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
95468 smp_mb__after_clear_bit();
95469
95470 - return atomic64_read(&ic->i_ack_next);
95471 + return atomic64_read_unchecked(&ic->i_ack_next);
95472 }
95473 #endif
95474
95475 diff --git a/net/rds/rds.h b/net/rds/rds.h
95476 index ec1d731..90a3a8d 100644
95477 --- a/net/rds/rds.h
95478 +++ b/net/rds/rds.h
95479 @@ -449,7 +449,7 @@ struct rds_transport {
95480 void (*sync_mr)(void *trans_private, int direction);
95481 void (*free_mr)(void *trans_private, int invalidate);
95482 void (*flush_mrs)(void);
95483 -};
95484 +} __do_const;
95485
95486 struct rds_sock {
95487 struct sock rs_sk;
95488 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
95489 index edac9ef..16bcb98 100644
95490 --- a/net/rds/tcp.c
95491 +++ b/net/rds/tcp.c
95492 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
95493 int val = 1;
95494
95495 set_fs(KERNEL_DS);
95496 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
95497 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
95498 sizeof(val));
95499 set_fs(oldfs);
95500 }
95501 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
95502 index 81cf5a4..b5826ff 100644
95503 --- a/net/rds/tcp_send.c
95504 +++ b/net/rds/tcp_send.c
95505 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
95506
95507 oldfs = get_fs();
95508 set_fs(KERNEL_DS);
95509 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
95510 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
95511 sizeof(val));
95512 set_fs(oldfs);
95513 }
95514 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
95515 index e61aa60..f07cc89 100644
95516 --- a/net/rxrpc/af_rxrpc.c
95517 +++ b/net/rxrpc/af_rxrpc.c
95518 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
95519 __be32 rxrpc_epoch;
95520
95521 /* current debugging ID */
95522 -atomic_t rxrpc_debug_id;
95523 +atomic_unchecked_t rxrpc_debug_id;
95524
95525 /* count of skbs currently in use */
95526 atomic_t rxrpc_n_skbs;
95527 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
95528 index e4d9cbc..b229649 100644
95529 --- a/net/rxrpc/ar-ack.c
95530 +++ b/net/rxrpc/ar-ack.c
95531 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95532
95533 _enter("{%d,%d,%d,%d},",
95534 call->acks_hard, call->acks_unacked,
95535 - atomic_read(&call->sequence),
95536 + atomic_read_unchecked(&call->sequence),
95537 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
95538
95539 stop = 0;
95540 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
95541
95542 /* each Tx packet has a new serial number */
95543 sp->hdr.serial =
95544 - htonl(atomic_inc_return(&call->conn->serial));
95545 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
95546
95547 hdr = (struct rxrpc_header *) txb->head;
95548 hdr->serial = sp->hdr.serial;
95549 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
95550 */
95551 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
95552 {
95553 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
95554 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
95555 }
95556
95557 /*
95558 @@ -629,7 +629,7 @@ process_further:
95559
95560 latest = ntohl(sp->hdr.serial);
95561 hard = ntohl(ack.firstPacket);
95562 - tx = atomic_read(&call->sequence);
95563 + tx = atomic_read_unchecked(&call->sequence);
95564
95565 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95566 latest,
95567 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
95568 goto maybe_reschedule;
95569
95570 send_ACK_with_skew:
95571 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
95572 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
95573 ntohl(ack.serial));
95574 send_ACK:
95575 mtu = call->conn->trans->peer->if_mtu;
95576 @@ -1173,7 +1173,7 @@ send_ACK:
95577 ackinfo.rxMTU = htonl(5692);
95578 ackinfo.jumbo_max = htonl(4);
95579
95580 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95581 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95582 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
95583 ntohl(hdr.serial),
95584 ntohs(ack.maxSkew),
95585 @@ -1191,7 +1191,7 @@ send_ACK:
95586 send_message:
95587 _debug("send message");
95588
95589 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
95590 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
95591 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
95592 send_message_2:
95593
95594 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
95595 index a3bbb36..3341fb9 100644
95596 --- a/net/rxrpc/ar-call.c
95597 +++ b/net/rxrpc/ar-call.c
95598 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
95599 spin_lock_init(&call->lock);
95600 rwlock_init(&call->state_lock);
95601 atomic_set(&call->usage, 1);
95602 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
95603 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95604 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
95605
95606 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
95607 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
95608 index 4106ca9..a338d7a 100644
95609 --- a/net/rxrpc/ar-connection.c
95610 +++ b/net/rxrpc/ar-connection.c
95611 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
95612 rwlock_init(&conn->lock);
95613 spin_lock_init(&conn->state_lock);
95614 atomic_set(&conn->usage, 1);
95615 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
95616 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95617 conn->avail_calls = RXRPC_MAXCALLS;
95618 conn->size_align = 4;
95619 conn->header_size = sizeof(struct rxrpc_header);
95620 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
95621 index e7ed43a..6afa140 100644
95622 --- a/net/rxrpc/ar-connevent.c
95623 +++ b/net/rxrpc/ar-connevent.c
95624 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
95625
95626 len = iov[0].iov_len + iov[1].iov_len;
95627
95628 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95629 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95630 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
95631
95632 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95633 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
95634 index 529572f..c758ca7 100644
95635 --- a/net/rxrpc/ar-input.c
95636 +++ b/net/rxrpc/ar-input.c
95637 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
95638 /* track the latest serial number on this connection for ACK packet
95639 * information */
95640 serial = ntohl(sp->hdr.serial);
95641 - hi_serial = atomic_read(&call->conn->hi_serial);
95642 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
95643 while (serial > hi_serial)
95644 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
95645 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
95646 serial);
95647
95648 /* request ACK generation for any ACK or DATA packet that requests
95649 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
95650 index a693aca..81e7293 100644
95651 --- a/net/rxrpc/ar-internal.h
95652 +++ b/net/rxrpc/ar-internal.h
95653 @@ -272,8 +272,8 @@ struct rxrpc_connection {
95654 int error; /* error code for local abort */
95655 int debug_id; /* debug ID for printks */
95656 unsigned int call_counter; /* call ID counter */
95657 - atomic_t serial; /* packet serial number counter */
95658 - atomic_t hi_serial; /* highest serial number received */
95659 + atomic_unchecked_t serial; /* packet serial number counter */
95660 + atomic_unchecked_t hi_serial; /* highest serial number received */
95661 u8 avail_calls; /* number of calls available */
95662 u8 size_align; /* data size alignment (for security) */
95663 u8 header_size; /* rxrpc + security header size */
95664 @@ -346,7 +346,7 @@ struct rxrpc_call {
95665 spinlock_t lock;
95666 rwlock_t state_lock; /* lock for state transition */
95667 atomic_t usage;
95668 - atomic_t sequence; /* Tx data packet sequence counter */
95669 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
95670 u32 abort_code; /* local/remote abort code */
95671 enum { /* current state of call */
95672 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
95673 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
95674 */
95675 extern atomic_t rxrpc_n_skbs;
95676 extern __be32 rxrpc_epoch;
95677 -extern atomic_t rxrpc_debug_id;
95678 +extern atomic_unchecked_t rxrpc_debug_id;
95679 extern struct workqueue_struct *rxrpc_workqueue;
95680
95681 /*
95682 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
95683 index 87f7135..74d3703 100644
95684 --- a/net/rxrpc/ar-local.c
95685 +++ b/net/rxrpc/ar-local.c
95686 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
95687 spin_lock_init(&local->lock);
95688 rwlock_init(&local->services_lock);
95689 atomic_set(&local->usage, 1);
95690 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
95691 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95692 memcpy(&local->srx, srx, sizeof(*srx));
95693 }
95694
95695 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
95696 index e1ac183..b43e10e 100644
95697 --- a/net/rxrpc/ar-output.c
95698 +++ b/net/rxrpc/ar-output.c
95699 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
95700 sp->hdr.cid = call->cid;
95701 sp->hdr.callNumber = call->call_id;
95702 sp->hdr.seq =
95703 - htonl(atomic_inc_return(&call->sequence));
95704 + htonl(atomic_inc_return_unchecked(&call->sequence));
95705 sp->hdr.serial =
95706 - htonl(atomic_inc_return(&conn->serial));
95707 + htonl(atomic_inc_return_unchecked(&conn->serial));
95708 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
95709 sp->hdr.userStatus = 0;
95710 sp->hdr.securityIndex = conn->security_ix;
95711 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
95712 index bebaa43..2644591 100644
95713 --- a/net/rxrpc/ar-peer.c
95714 +++ b/net/rxrpc/ar-peer.c
95715 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
95716 INIT_LIST_HEAD(&peer->error_targets);
95717 spin_lock_init(&peer->lock);
95718 atomic_set(&peer->usage, 1);
95719 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
95720 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95721 memcpy(&peer->srx, srx, sizeof(*srx));
95722
95723 rxrpc_assess_MTU_size(peer);
95724 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
95725 index 38047f7..9f48511 100644
95726 --- a/net/rxrpc/ar-proc.c
95727 +++ b/net/rxrpc/ar-proc.c
95728 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
95729 atomic_read(&conn->usage),
95730 rxrpc_conn_states[conn->state],
95731 key_serial(conn->key),
95732 - atomic_read(&conn->serial),
95733 - atomic_read(&conn->hi_serial));
95734 + atomic_read_unchecked(&conn->serial),
95735 + atomic_read_unchecked(&conn->hi_serial));
95736
95737 return 0;
95738 }
95739 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
95740 index 92df566..87ec1bf 100644
95741 --- a/net/rxrpc/ar-transport.c
95742 +++ b/net/rxrpc/ar-transport.c
95743 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
95744 spin_lock_init(&trans->client_lock);
95745 rwlock_init(&trans->conn_lock);
95746 atomic_set(&trans->usage, 1);
95747 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
95748 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
95749
95750 if (peer->srx.transport.family == AF_INET) {
95751 switch (peer->srx.transport_type) {
95752 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
95753 index f226709..0e735a8 100644
95754 --- a/net/rxrpc/rxkad.c
95755 +++ b/net/rxrpc/rxkad.c
95756 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
95757
95758 len = iov[0].iov_len + iov[1].iov_len;
95759
95760 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
95761 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95762 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
95763
95764 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
95765 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
95766
95767 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
95768
95769 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
95770 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
95771 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
95772
95773 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
95774 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
95775 index 547a461e..ea606e3 100644
95776 --- a/net/sctp/ipv6.c
95777 +++ b/net/sctp/ipv6.c
95778 @@ -968,7 +968,7 @@ static const struct inet6_protocol sctpv6_protocol = {
95779 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
95780 };
95781
95782 -static struct sctp_af sctp_af_inet6 = {
95783 +static struct sctp_af sctp_af_inet6 __read_only = {
95784 .sa_family = AF_INET6,
95785 .sctp_xmit = sctp_v6_xmit,
95786 .setsockopt = ipv6_setsockopt,
95787 @@ -1000,7 +1000,7 @@ static struct sctp_af sctp_af_inet6 = {
95788 #endif
95789 };
95790
95791 -static struct sctp_pf sctp_pf_inet6 = {
95792 +static struct sctp_pf sctp_pf_inet6 __read_only = {
95793 .event_msgname = sctp_inet6_event_msgname,
95794 .skb_msgname = sctp_inet6_skb_msgname,
95795 .af_supported = sctp_inet6_af_supported,
95796 @@ -1025,7 +1025,7 @@ void sctp_v6_pf_init(void)
95797
95798 void sctp_v6_pf_exit(void)
95799 {
95800 - list_del(&sctp_af_inet6.list);
95801 + pax_list_del(&sctp_af_inet6.list);
95802 }
95803
95804 /* Initialize IPv6 support and register with socket layer. */
95805 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
95806 index 62526c4..36a13c5 100644
95807 --- a/net/sctp/proc.c
95808 +++ b/net/sctp/proc.c
95809 @@ -343,7 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
95810 seq_printf(seq,
95811 "%8pK %8pK %-3d %-3d %-2d %-4d "
95812 "%4d %8d %8d %7d %5lu %-5d %5d ",
95813 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
95814 + assoc, sk,
95815 + sctp_sk(sk)->type, sk->sk_state,
95816 assoc->state, hash,
95817 assoc->assoc_id,
95818 assoc->sndbuf_used,
95819 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
95820 index 4a17494d..f7e3fa0 100644
95821 --- a/net/sctp/protocol.c
95822 +++ b/net/sctp/protocol.c
95823 @@ -838,8 +838,10 @@ int sctp_register_af(struct sctp_af *af)
95824 return 0;
95825 }
95826
95827 + pax_open_kernel();
95828 INIT_LIST_HEAD(&af->list);
95829 - list_add_tail(&af->list, &sctp_address_families);
95830 + pax_close_kernel();
95831 + pax_list_add_tail(&af->list, &sctp_address_families);
95832 return 1;
95833 }
95834
95835 @@ -969,7 +971,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
95836
95837 static struct sctp_af sctp_af_inet;
95838
95839 -static struct sctp_pf sctp_pf_inet = {
95840 +static struct sctp_pf sctp_pf_inet __read_only = {
95841 .event_msgname = sctp_inet_event_msgname,
95842 .skb_msgname = sctp_inet_skb_msgname,
95843 .af_supported = sctp_inet_af_supported,
95844 @@ -1040,7 +1042,7 @@ static const struct net_protocol sctp_protocol = {
95845 };
95846
95847 /* IPv4 address related functions. */
95848 -static struct sctp_af sctp_af_inet = {
95849 +static struct sctp_af sctp_af_inet __read_only = {
95850 .sa_family = AF_INET,
95851 .sctp_xmit = sctp_v4_xmit,
95852 .setsockopt = ip_setsockopt,
95853 @@ -1125,7 +1127,7 @@ static void sctp_v4_pf_init(void)
95854
95855 static void sctp_v4_pf_exit(void)
95856 {
95857 - list_del(&sctp_af_inet.list);
95858 + pax_list_del(&sctp_af_inet.list);
95859 }
95860
95861 static int sctp_v4_protosw_init(void)
95862 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
95863 index 9da6885..7571898 100644
95864 --- a/net/sctp/sm_sideeffect.c
95865 +++ b/net/sctp/sm_sideeffect.c
95866 @@ -446,7 +446,7 @@ static void sctp_generate_sack_event(unsigned long data)
95867 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
95868 }
95869
95870 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95871 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
95872 NULL,
95873 sctp_generate_t1_cookie_event,
95874 sctp_generate_t1_init_event,
95875 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
95876 index cf6c6b0..b978b65 100644
95877 --- a/net/sctp/socket.c
95878 +++ b/net/sctp/socket.c
95879 @@ -2159,11 +2159,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
95880 {
95881 struct sctp_association *asoc;
95882 struct sctp_ulpevent *event;
95883 + struct sctp_event_subscribe subscribe;
95884
95885 if (optlen > sizeof(struct sctp_event_subscribe))
95886 return -EINVAL;
95887 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
95888 + if (copy_from_user(&subscribe, optval, optlen))
95889 return -EFAULT;
95890 + sctp_sk(sk)->subscribe = subscribe;
95891
95892 /*
95893 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
95894 @@ -4219,13 +4221,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
95895 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95896 int __user *optlen)
95897 {
95898 + struct sctp_event_subscribe subscribe;
95899 +
95900 if (len <= 0)
95901 return -EINVAL;
95902 if (len > sizeof(struct sctp_event_subscribe))
95903 len = sizeof(struct sctp_event_subscribe);
95904 if (put_user(len, optlen))
95905 return -EFAULT;
95906 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
95907 + subscribe = sctp_sk(sk)->subscribe;
95908 + if (copy_to_user(optval, &subscribe, len))
95909 return -EFAULT;
95910 return 0;
95911 }
95912 @@ -4243,6 +4248,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
95913 */
95914 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
95915 {
95916 + __u32 autoclose;
95917 +
95918 /* Applicable to UDP-style socket only */
95919 if (sctp_style(sk, TCP))
95920 return -EOPNOTSUPP;
95921 @@ -4251,7 +4258,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
95922 len = sizeof(int);
95923 if (put_user(len, optlen))
95924 return -EFAULT;
95925 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
95926 + autoclose = sctp_sk(sk)->autoclose;
95927 + if (copy_to_user(optval, &autoclose, sizeof(int)))
95928 return -EFAULT;
95929 return 0;
95930 }
95931 @@ -4623,12 +4631,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
95932 */
95933 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
95934 {
95935 + struct sctp_initmsg initmsg;
95936 +
95937 if (len < sizeof(struct sctp_initmsg))
95938 return -EINVAL;
95939 len = sizeof(struct sctp_initmsg);
95940 if (put_user(len, optlen))
95941 return -EFAULT;
95942 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
95943 + initmsg = sctp_sk(sk)->initmsg;
95944 + if (copy_to_user(optval, &initmsg, len))
95945 return -EFAULT;
95946 return 0;
95947 }
95948 @@ -4669,6 +4680,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
95949 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
95950 if (space_left < addrlen)
95951 return -ENOMEM;
95952 + if (addrlen > sizeof(temp) || addrlen < 0)
95953 + return -EFAULT;
95954 if (copy_to_user(to, &temp, addrlen))
95955 return -EFAULT;
95956 to += addrlen;
95957 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
95958 index 9a5c4c9..46e4b29 100644
95959 --- a/net/sctp/sysctl.c
95960 +++ b/net/sctp/sysctl.c
95961 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95962 {
95963 struct net *net = current->nsproxy->net_ns;
95964 char tmp[8];
95965 - struct ctl_table tbl;
95966 + ctl_table_no_const tbl;
95967 int ret;
95968 int changed = 0;
95969 char *none = "none";
95970 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
95971
95972 int sctp_sysctl_net_register(struct net *net)
95973 {
95974 - struct ctl_table *table;
95975 + ctl_table_no_const *table;
95976 int i;
95977
95978 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
95979 diff --git a/net/socket.c b/net/socket.c
95980 index b2d7c62..f703b02 100644
95981 --- a/net/socket.c
95982 +++ b/net/socket.c
95983 @@ -88,6 +88,7 @@
95984 #include <linux/magic.h>
95985 #include <linux/slab.h>
95986 #include <linux/xattr.h>
95987 +#include <linux/in.h>
95988
95989 #include <asm/uaccess.h>
95990 #include <asm/unistd.h>
95991 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
95992 unsigned int sysctl_net_busy_poll __read_mostly;
95993 #endif
95994
95995 +#include <linux/grsock.h>
95996 +
95997 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
95998 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
95999 unsigned long nr_segs, loff_t pos);
96000 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
96001 */
96002
96003 static DEFINE_SPINLOCK(net_family_lock);
96004 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96005 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
96006
96007 /*
96008 * Statistics counters of the socket lists
96009 @@ -327,7 +330,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
96010 &sockfs_dentry_operations, SOCKFS_MAGIC);
96011 }
96012
96013 -static struct vfsmount *sock_mnt __read_mostly;
96014 +struct vfsmount *sock_mnt __read_mostly;
96015
96016 static struct file_system_type sock_fs_type = {
96017 .name = "sockfs",
96018 @@ -1263,6 +1266,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96019 return -EAFNOSUPPORT;
96020 if (type < 0 || type >= SOCK_MAX)
96021 return -EINVAL;
96022 + if (protocol < 0)
96023 + return -EINVAL;
96024
96025 /* Compatibility.
96026
96027 @@ -1283,6 +1288,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
96028 if (err)
96029 return err;
96030
96031 + if(!kern && !gr_search_socket(family, type, protocol)) {
96032 + if (rcu_access_pointer(net_families[family]) == NULL)
96033 + return -EAFNOSUPPORT;
96034 + else
96035 + return -EACCES;
96036 + }
96037 +
96038 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
96039 + if (rcu_access_pointer(net_families[family]) == NULL)
96040 + return -EAFNOSUPPORT;
96041 + else
96042 + return -EACCES;
96043 + }
96044 +
96045 /*
96046 * Allocate the socket and allow the family to set things up. if
96047 * the protocol is 0, the family is instructed to select an appropriate
96048 @@ -1521,6 +1540,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96049 if (sock) {
96050 err = move_addr_to_kernel(umyaddr, addrlen, &address);
96051 if (err >= 0) {
96052 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
96053 + err = -EACCES;
96054 + goto error;
96055 + }
96056 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
96057 + if (err)
96058 + goto error;
96059 +
96060 err = security_socket_bind(sock,
96061 (struct sockaddr *)&address,
96062 addrlen);
96063 @@ -1529,6 +1556,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
96064 (struct sockaddr *)
96065 &address, addrlen);
96066 }
96067 +error:
96068 fput_light(sock->file, fput_needed);
96069 }
96070 return err;
96071 @@ -1552,10 +1580,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
96072 if ((unsigned int)backlog > somaxconn)
96073 backlog = somaxconn;
96074
96075 + if (gr_handle_sock_server_other(sock->sk)) {
96076 + err = -EPERM;
96077 + goto error;
96078 + }
96079 +
96080 + err = gr_search_listen(sock);
96081 + if (err)
96082 + goto error;
96083 +
96084 err = security_socket_listen(sock, backlog);
96085 if (!err)
96086 err = sock->ops->listen(sock, backlog);
96087
96088 +error:
96089 fput_light(sock->file, fput_needed);
96090 }
96091 return err;
96092 @@ -1599,6 +1637,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96093 newsock->type = sock->type;
96094 newsock->ops = sock->ops;
96095
96096 + if (gr_handle_sock_server_other(sock->sk)) {
96097 + err = -EPERM;
96098 + sock_release(newsock);
96099 + goto out_put;
96100 + }
96101 +
96102 + err = gr_search_accept(sock);
96103 + if (err) {
96104 + sock_release(newsock);
96105 + goto out_put;
96106 + }
96107 +
96108 /*
96109 * We don't need try_module_get here, as the listening socket (sock)
96110 * has the protocol module (sock->ops->owner) held.
96111 @@ -1644,6 +1694,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
96112 fd_install(newfd, newfile);
96113 err = newfd;
96114
96115 + gr_attach_curr_ip(newsock->sk);
96116 +
96117 out_put:
96118 fput_light(sock->file, fput_needed);
96119 out:
96120 @@ -1676,6 +1728,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96121 int, addrlen)
96122 {
96123 struct socket *sock;
96124 + struct sockaddr *sck;
96125 struct sockaddr_storage address;
96126 int err, fput_needed;
96127
96128 @@ -1686,6 +1739,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
96129 if (err < 0)
96130 goto out_put;
96131
96132 + sck = (struct sockaddr *)&address;
96133 +
96134 + if (gr_handle_sock_client(sck)) {
96135 + err = -EACCES;
96136 + goto out_put;
96137 + }
96138 +
96139 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
96140 + if (err)
96141 + goto out_put;
96142 +
96143 err =
96144 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
96145 if (err)
96146 @@ -1767,6 +1831,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
96147 * the protocol.
96148 */
96149
96150 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
96151 +
96152 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
96153 unsigned int, flags, struct sockaddr __user *, addr,
96154 int, addr_len)
96155 @@ -1833,7 +1899,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
96156 struct socket *sock;
96157 struct iovec iov;
96158 struct msghdr msg;
96159 - struct sockaddr_storage address;
96160 + struct sockaddr_storage address = { };
96161 int err, err2;
96162 int fput_needed;
96163
96164 @@ -1973,6 +2039,16 @@ struct used_address {
96165 unsigned int name_len;
96166 };
96167
96168 +static int copy_msghdr_from_user(struct msghdr *kmsg,
96169 + struct msghdr __user *umsg)
96170 +{
96171 + if (copy_from_user(kmsg, umsg, sizeof(struct msghdr)))
96172 + return -EFAULT;
96173 + if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
96174 + return -EINVAL;
96175 + return 0;
96176 +}
96177 +
96178 static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96179 struct msghdr *msg_sys, unsigned int flags,
96180 struct used_address *used_address)
96181 @@ -1991,8 +2067,11 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96182 if (MSG_CMSG_COMPAT & flags) {
96183 if (get_compat_msghdr(msg_sys, msg_compat))
96184 return -EFAULT;
96185 - } else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr)))
96186 - return -EFAULT;
96187 + } else {
96188 + err = copy_msghdr_from_user(msg_sys, msg);
96189 + if (err)
96190 + return err;
96191 + }
96192
96193 if (msg_sys->msg_iovlen > UIO_FASTIOV) {
96194 err = -EMSGSIZE;
96195 @@ -2040,7 +2119,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
96196 * checking falls down on this.
96197 */
96198 if (copy_from_user(ctl_buf,
96199 - (void __user __force *)msg_sys->msg_control,
96200 + (void __force_user *)msg_sys->msg_control,
96201 ctl_len))
96202 goto out_freectl;
96203 msg_sys->msg_control = ctl_buf;
96204 @@ -2191,7 +2270,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96205 int err, total_len, len;
96206
96207 /* kernel mode address */
96208 - struct sockaddr_storage addr;
96209 + struct sockaddr_storage addr = { };
96210
96211 /* user mode address pointers */
96212 struct sockaddr __user *uaddr;
96213 @@ -2200,8 +2279,11 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96214 if (MSG_CMSG_COMPAT & flags) {
96215 if (get_compat_msghdr(msg_sys, msg_compat))
96216 return -EFAULT;
96217 - } else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr)))
96218 - return -EFAULT;
96219 + } else {
96220 + err = copy_msghdr_from_user(msg_sys, msg);
96221 + if (err)
96222 + return err;
96223 + }
96224
96225 if (msg_sys->msg_iovlen > UIO_FASTIOV) {
96226 err = -EMSGSIZE;
96227 @@ -2219,7 +2301,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
96228 * kernel msghdr to use the kernel address space)
96229 */
96230
96231 - uaddr = (__force void __user *)msg_sys->msg_name;
96232 + uaddr = (void __force_user *)msg_sys->msg_name;
96233 uaddr_len = COMPAT_NAMELEN(msg);
96234 if (MSG_CMSG_COMPAT & flags) {
96235 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
96236 @@ -2974,7 +3056,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
96237 old_fs = get_fs();
96238 set_fs(KERNEL_DS);
96239 err = dev_ioctl(net, cmd,
96240 - (struct ifreq __user __force *) &kifr);
96241 + (struct ifreq __force_user *) &kifr);
96242 set_fs(old_fs);
96243
96244 return err;
96245 @@ -3083,7 +3165,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
96246
96247 old_fs = get_fs();
96248 set_fs(KERNEL_DS);
96249 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
96250 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
96251 set_fs(old_fs);
96252
96253 if (cmd == SIOCGIFMAP && !err) {
96254 @@ -3188,7 +3270,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
96255 ret |= __get_user(rtdev, &(ur4->rt_dev));
96256 if (rtdev) {
96257 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
96258 - r4.rt_dev = (char __user __force *)devname;
96259 + r4.rt_dev = (char __force_user *)devname;
96260 devname[15] = 0;
96261 } else
96262 r4.rt_dev = NULL;
96263 @@ -3414,8 +3496,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
96264 int __user *uoptlen;
96265 int err;
96266
96267 - uoptval = (char __user __force *) optval;
96268 - uoptlen = (int __user __force *) optlen;
96269 + uoptval = (char __force_user *) optval;
96270 + uoptlen = (int __force_user *) optlen;
96271
96272 set_fs(KERNEL_DS);
96273 if (level == SOL_SOCKET)
96274 @@ -3435,7 +3517,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
96275 char __user *uoptval;
96276 int err;
96277
96278 - uoptval = (char __user __force *) optval;
96279 + uoptval = (char __force_user *) optval;
96280
96281 set_fs(KERNEL_DS);
96282 if (level == SOL_SOCKET)
96283 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
96284 index 09fb638..2e6a5c5 100644
96285 --- a/net/sunrpc/auth_gss/svcauth_gss.c
96286 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
96287 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96288 uint64_t *handle)
96289 {
96290 struct rsc rsci, *rscp = NULL;
96291 - static atomic64_t ctxhctr;
96292 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
96293 long long ctxh;
96294 struct gss_api_mech *gm = NULL;
96295 time_t expiry;
96296 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
96297 status = -ENOMEM;
96298 /* the handle needs to be just a unique id,
96299 * use a static counter */
96300 - ctxh = atomic64_inc_return(&ctxhctr);
96301 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
96302
96303 /* make a copy for the caller */
96304 *handle = ctxh;
96305 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
96306 index ecbc4e3..ad25df8 100644
96307 --- a/net/sunrpc/clnt.c
96308 +++ b/net/sunrpc/clnt.c
96309 @@ -1304,7 +1304,9 @@ call_start(struct rpc_task *task)
96310 (RPC_IS_ASYNC(task) ? "async" : "sync"));
96311
96312 /* Increment call count */
96313 - task->tk_msg.rpc_proc->p_count++;
96314 + pax_open_kernel();
96315 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
96316 + pax_close_kernel();
96317 clnt->cl_stats->rpccnt++;
96318 task->tk_action = call_reserve;
96319 }
96320 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
96321 index 93a7a4e..3b98b9f 100644
96322 --- a/net/sunrpc/sched.c
96323 +++ b/net/sunrpc/sched.c
96324 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
96325 #ifdef RPC_DEBUG
96326 static void rpc_task_set_debuginfo(struct rpc_task *task)
96327 {
96328 - static atomic_t rpc_pid;
96329 + static atomic_unchecked_t rpc_pid;
96330
96331 - task->tk_pid = atomic_inc_return(&rpc_pid);
96332 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
96333 }
96334 #else
96335 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
96336 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
96337 index b974571..678ed90 100644
96338 --- a/net/sunrpc/svc.c
96339 +++ b/net/sunrpc/svc.c
96340 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
96341 svc_putnl(resv, RPC_SUCCESS);
96342
96343 /* Bump per-procedure stats counter */
96344 - procp->pc_count++;
96345 + pax_open_kernel();
96346 + (*(unsigned int *)&procp->pc_count)++;
96347 + pax_close_kernel();
96348
96349 /* Initialize storage for argp and resp */
96350 memset(rqstp->rq_argp, 0, procp->pc_argsize);
96351 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
96352 index c1b6270..05089c1 100644
96353 --- a/net/sunrpc/xprtrdma/svc_rdma.c
96354 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
96355 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
96356 static unsigned int min_max_inline = 4096;
96357 static unsigned int max_max_inline = 65536;
96358
96359 -atomic_t rdma_stat_recv;
96360 -atomic_t rdma_stat_read;
96361 -atomic_t rdma_stat_write;
96362 -atomic_t rdma_stat_sq_starve;
96363 -atomic_t rdma_stat_rq_starve;
96364 -atomic_t rdma_stat_rq_poll;
96365 -atomic_t rdma_stat_rq_prod;
96366 -atomic_t rdma_stat_sq_poll;
96367 -atomic_t rdma_stat_sq_prod;
96368 +atomic_unchecked_t rdma_stat_recv;
96369 +atomic_unchecked_t rdma_stat_read;
96370 +atomic_unchecked_t rdma_stat_write;
96371 +atomic_unchecked_t rdma_stat_sq_starve;
96372 +atomic_unchecked_t rdma_stat_rq_starve;
96373 +atomic_unchecked_t rdma_stat_rq_poll;
96374 +atomic_unchecked_t rdma_stat_rq_prod;
96375 +atomic_unchecked_t rdma_stat_sq_poll;
96376 +atomic_unchecked_t rdma_stat_sq_prod;
96377
96378 /* Temporary NFS request map and context caches */
96379 struct kmem_cache *svc_rdma_map_cachep;
96380 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
96381 len -= *ppos;
96382 if (len > *lenp)
96383 len = *lenp;
96384 - if (len && copy_to_user(buffer, str_buf, len))
96385 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
96386 return -EFAULT;
96387 *lenp = len;
96388 *ppos += len;
96389 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
96390 {
96391 .procname = "rdma_stat_read",
96392 .data = &rdma_stat_read,
96393 - .maxlen = sizeof(atomic_t),
96394 + .maxlen = sizeof(atomic_unchecked_t),
96395 .mode = 0644,
96396 .proc_handler = read_reset_stat,
96397 },
96398 {
96399 .procname = "rdma_stat_recv",
96400 .data = &rdma_stat_recv,
96401 - .maxlen = sizeof(atomic_t),
96402 + .maxlen = sizeof(atomic_unchecked_t),
96403 .mode = 0644,
96404 .proc_handler = read_reset_stat,
96405 },
96406 {
96407 .procname = "rdma_stat_write",
96408 .data = &rdma_stat_write,
96409 - .maxlen = sizeof(atomic_t),
96410 + .maxlen = sizeof(atomic_unchecked_t),
96411 .mode = 0644,
96412 .proc_handler = read_reset_stat,
96413 },
96414 {
96415 .procname = "rdma_stat_sq_starve",
96416 .data = &rdma_stat_sq_starve,
96417 - .maxlen = sizeof(atomic_t),
96418 + .maxlen = sizeof(atomic_unchecked_t),
96419 .mode = 0644,
96420 .proc_handler = read_reset_stat,
96421 },
96422 {
96423 .procname = "rdma_stat_rq_starve",
96424 .data = &rdma_stat_rq_starve,
96425 - .maxlen = sizeof(atomic_t),
96426 + .maxlen = sizeof(atomic_unchecked_t),
96427 .mode = 0644,
96428 .proc_handler = read_reset_stat,
96429 },
96430 {
96431 .procname = "rdma_stat_rq_poll",
96432 .data = &rdma_stat_rq_poll,
96433 - .maxlen = sizeof(atomic_t),
96434 + .maxlen = sizeof(atomic_unchecked_t),
96435 .mode = 0644,
96436 .proc_handler = read_reset_stat,
96437 },
96438 {
96439 .procname = "rdma_stat_rq_prod",
96440 .data = &rdma_stat_rq_prod,
96441 - .maxlen = sizeof(atomic_t),
96442 + .maxlen = sizeof(atomic_unchecked_t),
96443 .mode = 0644,
96444 .proc_handler = read_reset_stat,
96445 },
96446 {
96447 .procname = "rdma_stat_sq_poll",
96448 .data = &rdma_stat_sq_poll,
96449 - .maxlen = sizeof(atomic_t),
96450 + .maxlen = sizeof(atomic_unchecked_t),
96451 .mode = 0644,
96452 .proc_handler = read_reset_stat,
96453 },
96454 {
96455 .procname = "rdma_stat_sq_prod",
96456 .data = &rdma_stat_sq_prod,
96457 - .maxlen = sizeof(atomic_t),
96458 + .maxlen = sizeof(atomic_unchecked_t),
96459 .mode = 0644,
96460 .proc_handler = read_reset_stat,
96461 },
96462 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96463 index 0ce7552..d074459 100644
96464 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96465 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
96466 @@ -501,7 +501,7 @@ next_sge:
96467 svc_rdma_put_context(ctxt, 0);
96468 goto out;
96469 }
96470 - atomic_inc(&rdma_stat_read);
96471 + atomic_inc_unchecked(&rdma_stat_read);
96472
96473 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
96474 chl_map->ch[ch_no].count -= read_wr.num_sge;
96475 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96476 dto_q);
96477 list_del_init(&ctxt->dto_q);
96478 } else {
96479 - atomic_inc(&rdma_stat_rq_starve);
96480 + atomic_inc_unchecked(&rdma_stat_rq_starve);
96481 clear_bit(XPT_DATA, &xprt->xpt_flags);
96482 ctxt = NULL;
96483 }
96484 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
96485 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
96486 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
96487 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
96488 - atomic_inc(&rdma_stat_recv);
96489 + atomic_inc_unchecked(&rdma_stat_recv);
96490
96491 /* Build up the XDR from the receive buffers. */
96492 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
96493 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96494 index c1d124d..acfc59e 100644
96495 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96496 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
96497 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
96498 write_wr.wr.rdma.remote_addr = to;
96499
96500 /* Post It */
96501 - atomic_inc(&rdma_stat_write);
96502 + atomic_inc_unchecked(&rdma_stat_write);
96503 if (svc_rdma_send(xprt, &write_wr))
96504 goto err;
96505 return 0;
96506 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96507 index 62e4f9b..dd3f2d7 100644
96508 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
96509 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
96510 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96511 return;
96512
96513 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
96514 - atomic_inc(&rdma_stat_rq_poll);
96515 + atomic_inc_unchecked(&rdma_stat_rq_poll);
96516
96517 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
96518 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
96519 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
96520 }
96521
96522 if (ctxt)
96523 - atomic_inc(&rdma_stat_rq_prod);
96524 + atomic_inc_unchecked(&rdma_stat_rq_prod);
96525
96526 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
96527 /*
96528 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96529 return;
96530
96531 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
96532 - atomic_inc(&rdma_stat_sq_poll);
96533 + atomic_inc_unchecked(&rdma_stat_sq_poll);
96534 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
96535 if (wc.status != IB_WC_SUCCESS)
96536 /* Close the transport */
96537 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
96538 }
96539
96540 if (ctxt)
96541 - atomic_inc(&rdma_stat_sq_prod);
96542 + atomic_inc_unchecked(&rdma_stat_sq_prod);
96543 }
96544
96545 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
96546 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
96547 spin_lock_bh(&xprt->sc_lock);
96548 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
96549 spin_unlock_bh(&xprt->sc_lock);
96550 - atomic_inc(&rdma_stat_sq_starve);
96551 + atomic_inc_unchecked(&rdma_stat_sq_starve);
96552
96553 /* See if we can opportunistically reap SQ WR to make room */
96554 sq_cq_reap(xprt);
96555 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
96556 index e7000be..e3b0ba7 100644
96557 --- a/net/sysctl_net.c
96558 +++ b/net/sysctl_net.c
96559 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
96560 kgid_t root_gid = make_kgid(net->user_ns, 0);
96561
96562 /* Allow network administrator to have same access as root. */
96563 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
96564 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
96565 uid_eq(root_uid, current_euid())) {
96566 int mode = (table->mode >> 6) & 7;
96567 return (mode << 6) | (mode << 3) | mode;
96568 diff --git a/net/tipc/link.c b/net/tipc/link.c
96569 index 0cc3d90..cc42021 100644
96570 --- a/net/tipc/link.c
96571 +++ b/net/tipc/link.c
96572 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
96573 struct tipc_msg fragm_hdr;
96574 struct sk_buff *buf, *buf_chain, *prev;
96575 u32 fragm_crs, fragm_rest, hsz, sect_rest;
96576 - const unchar *sect_crs;
96577 + const unchar __user *sect_crs;
96578 int curr_sect;
96579 u32 fragm_no;
96580 int res = 0;
96581 @@ -1207,7 +1207,7 @@ again:
96582
96583 if (!sect_rest) {
96584 sect_rest = msg_sect[++curr_sect].iov_len;
96585 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
96586 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
96587 }
96588
96589 if (sect_rest < fragm_rest)
96590 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
96591 index ced60e2..54eab6c 100644
96592 --- a/net/tipc/msg.c
96593 +++ b/net/tipc/msg.c
96594 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
96595 skb_copy_to_linear_data(*buf, hdr, hsz);
96596 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
96597 skb_copy_to_linear_data_offset(*buf, pos,
96598 - msg_sect[cnt].iov_base,
96599 + (const void __force_kernel *)msg_sect[cnt].iov_base,
96600 msg_sect[cnt].iov_len);
96601 pos += msg_sect[cnt].iov_len;
96602 }
96603 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
96604 index d38bb45..4fd6ac6 100644
96605 --- a/net/tipc/subscr.c
96606 +++ b/net/tipc/subscr.c
96607 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
96608 struct kvec msg_sect;
96609 int ret;
96610
96611 - msg_sect.iov_base = (void *)&sub->evt;
96612 + msg_sect.iov_base = (void __force_user *)&sub->evt;
96613 msg_sect.iov_len = sizeof(struct tipc_event);
96614
96615 sub->evt.event = htohl(event, sub->swap);
96616 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
96617 index c4ce243..2be7c59 100644
96618 --- a/net/unix/af_unix.c
96619 +++ b/net/unix/af_unix.c
96620 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
96621 err = -ECONNREFUSED;
96622 if (!S_ISSOCK(inode->i_mode))
96623 goto put_fail;
96624 +
96625 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
96626 + err = -EACCES;
96627 + goto put_fail;
96628 + }
96629 +
96630 u = unix_find_socket_byinode(inode);
96631 if (!u)
96632 goto put_fail;
96633 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
96634 if (u) {
96635 struct dentry *dentry;
96636 dentry = unix_sk(u)->path.dentry;
96637 +
96638 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
96639 + err = -EPERM;
96640 + sock_put(u);
96641 + goto fail;
96642 + }
96643 +
96644 if (dentry)
96645 touch_atime(&unix_sk(u)->path);
96646 } else
96647 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
96648 */
96649 err = security_path_mknod(&path, dentry, mode, 0);
96650 if (!err) {
96651 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
96652 + err = -EACCES;
96653 + goto out;
96654 + }
96655 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
96656 if (!err) {
96657 res->mnt = mntget(path.mnt);
96658 res->dentry = dget(dentry);
96659 + gr_handle_create(dentry, path.mnt);
96660 }
96661 }
96662 +out:
96663 done_path_create(&path, dentry);
96664 return err;
96665 }
96666 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96667 seq_puts(seq, "Num RefCount Protocol Flags Type St "
96668 "Inode Path\n");
96669 else {
96670 - struct sock *s = v;
96671 + struct sock *s = v, *peer;
96672 struct unix_sock *u = unix_sk(s);
96673 unix_state_lock(s);
96674 + peer = unix_peer(s);
96675 + unix_state_unlock(s);
96676 +
96677 + unix_state_double_lock(s, peer);
96678
96679 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
96680 s,
96681 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
96682 }
96683 for ( ; i < len; i++)
96684 seq_putc(seq, u->addr->name->sun_path[i]);
96685 - }
96686 - unix_state_unlock(s);
96687 + } else if (peer)
96688 + seq_printf(seq, " P%lu", sock_i_ino(peer));
96689 +
96690 + unix_state_double_unlock(s, peer);
96691 seq_putc(seq, '\n');
96692 }
96693
96694 diff --git a/net/unix/diag.c b/net/unix/diag.c
96695 index d591091..86fa0f3 100644
96696 --- a/net/unix/diag.c
96697 +++ b/net/unix/diag.c
96698 @@ -124,6 +124,7 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r
96699 rep->udiag_family = AF_UNIX;
96700 rep->udiag_type = sk->sk_type;
96701 rep->udiag_state = sk->sk_state;
96702 + rep->pad = 0;
96703 rep->udiag_ino = sk_ino;
96704 sock_diag_save_cookie(sk, rep->udiag_cookie);
96705
96706 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
96707 index b3d5150..ff3a837 100644
96708 --- a/net/unix/sysctl_net_unix.c
96709 +++ b/net/unix/sysctl_net_unix.c
96710 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
96711
96712 int __net_init unix_sysctl_register(struct net *net)
96713 {
96714 - struct ctl_table *table;
96715 + ctl_table_no_const *table;
96716
96717 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
96718 if (table == NULL)
96719 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
96720 index c8717c1..08539f5 100644
96721 --- a/net/wireless/wext-core.c
96722 +++ b/net/wireless/wext-core.c
96723 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96724 */
96725
96726 /* Support for very large requests */
96727 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
96728 - (user_length > descr->max_tokens)) {
96729 + if (user_length > descr->max_tokens) {
96730 /* Allow userspace to GET more than max so
96731 * we can support any size GET requests.
96732 * There is still a limit : -ENOMEM.
96733 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
96734 }
96735 }
96736
96737 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
96738 - /*
96739 - * If this is a GET, but not NOMAX, it means that the extra
96740 - * data is not bounded by userspace, but by max_tokens. Thus
96741 - * set the length to max_tokens. This matches the extra data
96742 - * allocation.
96743 - * The driver should fill it with the number of tokens it
96744 - * provided, and it may check iwp->length rather than having
96745 - * knowledge of max_tokens. If the driver doesn't change the
96746 - * iwp->length, this ioctl just copies back max_token tokens
96747 - * filled with zeroes. Hopefully the driver isn't claiming
96748 - * them to be valid data.
96749 - */
96750 - iwp->length = descr->max_tokens;
96751 - }
96752 -
96753 err = handler(dev, info, (union iwreq_data *) iwp, extra);
96754
96755 iwp->length += essid_compat;
96756 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
96757 index f77c371..b0cb010 100644
96758 --- a/net/xfrm/xfrm_policy.c
96759 +++ b/net/xfrm/xfrm_policy.c
96760 @@ -332,9 +332,10 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
96761 {
96762 policy->walk.dead = 1;
96763
96764 - atomic_inc(&policy->genid);
96765 + atomic_inc_unchecked(&policy->genid);
96766
96767 - del_timer(&policy->polq.hold_timer);
96768 + if (del_timer(&policy->polq.hold_timer))
96769 + xfrm_pol_put(policy);
96770 xfrm_queue_purge(&policy->polq.hold_queue);
96771
96772 if (del_timer(&policy->timer))
96773 @@ -589,7 +590,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96774
96775 spin_lock_bh(&pq->hold_queue.lock);
96776 skb_queue_splice_init(&pq->hold_queue, &list);
96777 - del_timer(&pq->hold_timer);
96778 + if (del_timer(&pq->hold_timer))
96779 + xfrm_pol_put(old);
96780 spin_unlock_bh(&pq->hold_queue.lock);
96781
96782 if (skb_queue_empty(&list))
96783 @@ -600,7 +602,8 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
96784 spin_lock_bh(&pq->hold_queue.lock);
96785 skb_queue_splice(&list, &pq->hold_queue);
96786 pq->timeout = XFRM_QUEUE_TMO_MIN;
96787 - mod_timer(&pq->hold_timer, jiffies);
96788 + if (!mod_timer(&pq->hold_timer, jiffies))
96789 + xfrm_pol_hold(new);
96790 spin_unlock_bh(&pq->hold_queue.lock);
96791 }
96792
96793 @@ -657,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
96794 hlist_add_head(&policy->bydst, chain);
96795 xfrm_pol_hold(policy);
96796 net->xfrm.policy_count[dir]++;
96797 - atomic_inc(&flow_cache_genid);
96798 + atomic_inc_unchecked(&flow_cache_genid);
96799 rt_genid_bump(net);
96800 if (delpol) {
96801 xfrm_policy_requeue(delpol, policy);
96802 @@ -1627,7 +1630,7 @@ free_dst:
96803 goto out;
96804 }
96805
96806 -static int inline
96807 +static inline int
96808 xfrm_dst_alloc_copy(void **target, const void *src, int size)
96809 {
96810 if (!*target) {
96811 @@ -1639,7 +1642,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
96812 return 0;
96813 }
96814
96815 -static int inline
96816 +static inline int
96817 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96818 {
96819 #ifdef CONFIG_XFRM_SUB_POLICY
96820 @@ -1651,7 +1654,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
96821 #endif
96822 }
96823
96824 -static int inline
96825 +static inline int
96826 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
96827 {
96828 #ifdef CONFIG_XFRM_SUB_POLICY
96829 @@ -1745,7 +1748,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
96830
96831 xdst->num_pols = num_pols;
96832 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
96833 - xdst->policy_genid = atomic_read(&pols[0]->genid);
96834 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
96835
96836 return xdst;
96837 }
96838 @@ -1763,6 +1766,10 @@ static void xfrm_policy_queue_process(unsigned long arg)
96839
96840 spin_lock(&pq->hold_queue.lock);
96841 skb = skb_peek(&pq->hold_queue);
96842 + if (!skb) {
96843 + spin_unlock(&pq->hold_queue.lock);
96844 + goto out;
96845 + }
96846 dst = skb_dst(skb);
96847 sk = skb->sk;
96848 xfrm_decode_session(skb, &fl, dst->ops->family);
96849 @@ -1781,8 +1788,9 @@ static void xfrm_policy_queue_process(unsigned long arg)
96850 goto purge_queue;
96851
96852 pq->timeout = pq->timeout << 1;
96853 - mod_timer(&pq->hold_timer, jiffies + pq->timeout);
96854 - return;
96855 + if (!mod_timer(&pq->hold_timer, jiffies + pq->timeout))
96856 + xfrm_pol_hold(pol);
96857 + goto out;
96858 }
96859
96860 dst_release(dst);
96861 @@ -1813,11 +1821,14 @@ static void xfrm_policy_queue_process(unsigned long arg)
96862 err = dst_output(skb);
96863 }
96864
96865 +out:
96866 + xfrm_pol_put(pol);
96867 return;
96868
96869 purge_queue:
96870 pq->timeout = 0;
96871 xfrm_queue_purge(&pq->hold_queue);
96872 + xfrm_pol_put(pol);
96873 }
96874
96875 static int xdst_queue_output(struct sk_buff *skb)
96876 @@ -1825,7 +1836,8 @@ static int xdst_queue_output(struct sk_buff *skb)
96877 unsigned long sched_next;
96878 struct dst_entry *dst = skb_dst(skb);
96879 struct xfrm_dst *xdst = (struct xfrm_dst *) dst;
96880 - struct xfrm_policy_queue *pq = &xdst->pols[0]->polq;
96881 + struct xfrm_policy *pol = xdst->pols[0];
96882 + struct xfrm_policy_queue *pq = &pol->polq;
96883
96884 if (pq->hold_queue.qlen > XFRM_MAX_QUEUE_LEN) {
96885 kfree_skb(skb);
96886 @@ -1844,10 +1856,12 @@ static int xdst_queue_output(struct sk_buff *skb)
96887 if (del_timer(&pq->hold_timer)) {
96888 if (time_before(pq->hold_timer.expires, sched_next))
96889 sched_next = pq->hold_timer.expires;
96890 + xfrm_pol_put(pol);
96891 }
96892
96893 __skb_queue_tail(&pq->hold_queue, skb);
96894 - mod_timer(&pq->hold_timer, sched_next);
96895 + if (!mod_timer(&pq->hold_timer, sched_next))
96896 + xfrm_pol_hold(pol);
96897
96898 spin_unlock_bh(&pq->hold_queue.lock);
96899
96900 @@ -2557,11 +2571,12 @@ void xfrm_garbage_collect(struct net *net)
96901 }
96902 EXPORT_SYMBOL(xfrm_garbage_collect);
96903
96904 -static void xfrm_garbage_collect_deferred(struct net *net)
96905 +void xfrm_garbage_collect_deferred(struct net *net)
96906 {
96907 flow_cache_flush_deferred();
96908 __xfrm_garbage_collect(net);
96909 }
96910 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
96911
96912 static void xfrm_init_pmtu(struct dst_entry *dst)
96913 {
96914 @@ -2611,7 +2626,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
96915 if (xdst->xfrm_genid != dst->xfrm->genid)
96916 return 0;
96917 if (xdst->num_pols > 0 &&
96918 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
96919 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
96920 return 0;
96921
96922 mtu = dst_mtu(dst->child);
96923 @@ -2699,8 +2714,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
96924 dst_ops->link_failure = xfrm_link_failure;
96925 if (likely(dst_ops->neigh_lookup == NULL))
96926 dst_ops->neigh_lookup = xfrm_neigh_lookup;
96927 - if (likely(afinfo->garbage_collect == NULL))
96928 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
96929 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
96930 }
96931 spin_unlock(&xfrm_policy_afinfo_lock);
96932 @@ -2754,7 +2767,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
96933 dst_ops->check = NULL;
96934 dst_ops->negative_advice = NULL;
96935 dst_ops->link_failure = NULL;
96936 - afinfo->garbage_collect = NULL;
96937 }
96938 return err;
96939 }
96940 @@ -3137,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
96941 sizeof(pol->xfrm_vec[i].saddr));
96942 pol->xfrm_vec[i].encap_family = mp->new_family;
96943 /* flush bundles */
96944 - atomic_inc(&pol->genid);
96945 + atomic_inc_unchecked(&pol->genid);
96946 }
96947 }
96948
96949 diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c
96950 index 8dafe6d3..dab57da 100644
96951 --- a/net/xfrm/xfrm_replay.c
96952 +++ b/net/xfrm/xfrm_replay.c
96953 @@ -61,9 +61,9 @@ static void xfrm_replay_notify(struct xfrm_state *x, int event)
96954
96955 switch (event) {
96956 case XFRM_REPLAY_UPDATE:
96957 - if (x->replay_maxdiff &&
96958 - (x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96959 - (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff)) {
96960 + if (!x->replay_maxdiff ||
96961 + ((x->replay.seq - x->preplay.seq < x->replay_maxdiff) &&
96962 + (x->replay.oseq - x->preplay.oseq < x->replay_maxdiff))) {
96963 if (x->xflags & XFRM_TIME_DEFER)
96964 event = XFRM_REPLAY_TIMEOUT;
96965 else
96966 @@ -129,8 +129,7 @@ static int xfrm_replay_check(struct xfrm_state *x,
96967 return 0;
96968
96969 diff = x->replay.seq - seq;
96970 - if (diff >= min_t(unsigned int, x->props.replay_window,
96971 - sizeof(x->replay.bitmap) * 8)) {
96972 + if (diff >= x->props.replay_window) {
96973 x->stats.replay_window++;
96974 goto err;
96975 }
96976 @@ -302,9 +301,10 @@ static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event)
96977
96978 switch (event) {
96979 case XFRM_REPLAY_UPDATE:
96980 - if (x->replay_maxdiff &&
96981 - (replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96982 - (replay_esn->oseq - preplay_esn->oseq < x->replay_maxdiff)) {
96983 + if (!x->replay_maxdiff ||
96984 + ((replay_esn->seq - preplay_esn->seq < x->replay_maxdiff) &&
96985 + (replay_esn->oseq - preplay_esn->oseq
96986 + < x->replay_maxdiff))) {
96987 if (x->xflags & XFRM_TIME_DEFER)
96988 event = XFRM_REPLAY_TIMEOUT;
96989 else
96990 @@ -353,28 +353,30 @@ static void xfrm_replay_notify_esn(struct xfrm_state *x, int event)
96991
96992 switch (event) {
96993 case XFRM_REPLAY_UPDATE:
96994 - if (!x->replay_maxdiff)
96995 - break;
96996 -
96997 - if (replay_esn->seq_hi == preplay_esn->seq_hi)
96998 - seq_diff = replay_esn->seq - preplay_esn->seq;
96999 - else
97000 - seq_diff = ~preplay_esn->seq + replay_esn->seq + 1;
97001 -
97002 - if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
97003 - oseq_diff = replay_esn->oseq - preplay_esn->oseq;
97004 - else
97005 - oseq_diff = ~preplay_esn->oseq + replay_esn->oseq + 1;
97006 -
97007 - if (seq_diff < x->replay_maxdiff &&
97008 - oseq_diff < x->replay_maxdiff) {
97009 + if (x->replay_maxdiff) {
97010 + if (replay_esn->seq_hi == preplay_esn->seq_hi)
97011 + seq_diff = replay_esn->seq - preplay_esn->seq;
97012 + else
97013 + seq_diff = ~preplay_esn->seq + replay_esn->seq
97014 + + 1;
97015
97016 - if (x->xflags & XFRM_TIME_DEFER)
97017 - event = XFRM_REPLAY_TIMEOUT;
97018 + if (replay_esn->oseq_hi == preplay_esn->oseq_hi)
97019 + oseq_diff = replay_esn->oseq
97020 + - preplay_esn->oseq;
97021 else
97022 - return;
97023 + oseq_diff = ~preplay_esn->oseq
97024 + + replay_esn->oseq + 1;
97025 +
97026 + if (seq_diff >= x->replay_maxdiff ||
97027 + oseq_diff >= x->replay_maxdiff)
97028 + break;
97029 }
97030
97031 + if (x->xflags & XFRM_TIME_DEFER)
97032 + event = XFRM_REPLAY_TIMEOUT;
97033 + else
97034 + return;
97035 +
97036 break;
97037
97038 case XFRM_REPLAY_TIMEOUT:
97039 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
97040 index 54c0acd..56814bd 100644
97041 --- a/net/xfrm/xfrm_state.c
97042 +++ b/net/xfrm/xfrm_state.c
97043 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
97044
97045 if (unlikely(afinfo == NULL))
97046 return -EAFNOSUPPORT;
97047 - typemap = afinfo->type_map;
97048 + typemap = (const struct xfrm_type **)afinfo->type_map;
97049 spin_lock_bh(&xfrm_type_lock);
97050
97051 - if (likely(typemap[type->proto] == NULL))
97052 + if (likely(typemap[type->proto] == NULL)) {
97053 + pax_open_kernel();
97054 typemap[type->proto] = type;
97055 - else
97056 + pax_close_kernel();
97057 + } else
97058 err = -EEXIST;
97059 spin_unlock_bh(&xfrm_type_lock);
97060 xfrm_state_put_afinfo(afinfo);
97061 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
97062
97063 if (unlikely(afinfo == NULL))
97064 return -EAFNOSUPPORT;
97065 - typemap = afinfo->type_map;
97066 + typemap = (const struct xfrm_type **)afinfo->type_map;
97067 spin_lock_bh(&xfrm_type_lock);
97068
97069 if (unlikely(typemap[type->proto] != type))
97070 err = -ENOENT;
97071 - else
97072 + else {
97073 + pax_open_kernel();
97074 typemap[type->proto] = NULL;
97075 + pax_close_kernel();
97076 + }
97077 spin_unlock_bh(&xfrm_type_lock);
97078 xfrm_state_put_afinfo(afinfo);
97079 return err;
97080 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
97081 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
97082 {
97083 struct xfrm_state_afinfo *afinfo;
97084 - const struct xfrm_type **typemap;
97085 const struct xfrm_type *type;
97086 int modload_attempted = 0;
97087
97088 @@ -219,9 +223,8 @@ retry:
97089 afinfo = xfrm_state_get_afinfo(family);
97090 if (unlikely(afinfo == NULL))
97091 return NULL;
97092 - typemap = afinfo->type_map;
97093
97094 - type = typemap[proto];
97095 + type = afinfo->type_map[proto];
97096 if (unlikely(type && !try_module_get(type->owner)))
97097 type = NULL;
97098 if (!type && !modload_attempted) {
97099 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97100 return -EAFNOSUPPORT;
97101
97102 err = -EEXIST;
97103 - modemap = afinfo->mode_map;
97104 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97105 spin_lock_bh(&xfrm_mode_lock);
97106 if (modemap[mode->encap])
97107 goto out;
97108 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
97109 if (!try_module_get(afinfo->owner))
97110 goto out;
97111
97112 - mode->afinfo = afinfo;
97113 + pax_open_kernel();
97114 + *(const void **)&mode->afinfo = afinfo;
97115 modemap[mode->encap] = mode;
97116 + pax_close_kernel();
97117 err = 0;
97118
97119 out:
97120 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
97121 return -EAFNOSUPPORT;
97122
97123 err = -ENOENT;
97124 - modemap = afinfo->mode_map;
97125 + modemap = (struct xfrm_mode **)afinfo->mode_map;
97126 spin_lock_bh(&xfrm_mode_lock);
97127 if (likely(modemap[mode->encap] == mode)) {
97128 + pax_open_kernel();
97129 modemap[mode->encap] = NULL;
97130 + pax_close_kernel();
97131 module_put(mode->afinfo->owner);
97132 err = 0;
97133 }
97134 @@ -1483,10 +1490,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
97135 u32 xfrm_get_acqseq(void)
97136 {
97137 u32 res;
97138 - static atomic_t acqseq;
97139 + static atomic_unchecked_t acqseq;
97140
97141 do {
97142 - res = atomic_inc_return(&acqseq);
97143 + res = atomic_inc_return_unchecked(&acqseq);
97144 } while (!res);
97145
97146 return res;
97147 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
97148 index 05a6e3d..6716ec9 100644
97149 --- a/net/xfrm/xfrm_sysctl.c
97150 +++ b/net/xfrm/xfrm_sysctl.c
97151 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
97152
97153 int __net_init xfrm_sysctl_init(struct net *net)
97154 {
97155 - struct ctl_table *table;
97156 + ctl_table_no_const *table;
97157
97158 __xfrm_sysctl_init(net);
97159
97160 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
97161 index 3f565e4..f964d4c 100644
97162 --- a/net/xfrm/xfrm_user.c
97163 +++ b/net/xfrm/xfrm_user.c
97164 @@ -446,7 +446,8 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
97165 memcpy(&x->sel, &p->sel, sizeof(x->sel));
97166 memcpy(&x->lft, &p->lft, sizeof(x->lft));
97167 x->props.mode = p->mode;
97168 - x->props.replay_window = p->replay_window;
97169 + x->props.replay_window = min_t(unsigned int, p->replay_window,
97170 + sizeof(x->replay.bitmap) * 8);
97171 x->props.reqid = p->reqid;
97172 x->props.family = p->family;
97173 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
97174 @@ -1856,7 +1857,7 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,
97175 if (x->km.state != XFRM_STATE_VALID)
97176 goto out;
97177
97178 - err = xfrm_replay_verify_len(x->replay_esn, rp);
97179 + err = xfrm_replay_verify_len(x->replay_esn, re);
97180 if (err)
97181 goto out;
97182
97183 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
97184 index d5d859c..781cbcb 100644
97185 --- a/scripts/Makefile.build
97186 +++ b/scripts/Makefile.build
97187 @@ -111,7 +111,7 @@ endif
97188 endif
97189
97190 # Do not include host rules unless needed
97191 -ifneq ($(hostprogs-y)$(hostprogs-m),)
97192 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
97193 include scripts/Makefile.host
97194 endif
97195
97196 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
97197 index 686cb0d..9d653bf 100644
97198 --- a/scripts/Makefile.clean
97199 +++ b/scripts/Makefile.clean
97200 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
97201 __clean-files := $(extra-y) $(always) \
97202 $(targets) $(clean-files) \
97203 $(host-progs) \
97204 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
97205 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
97206 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
97207
97208 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
97209
97210 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
97211 index 1ac414f..38575f7 100644
97212 --- a/scripts/Makefile.host
97213 +++ b/scripts/Makefile.host
97214 @@ -31,6 +31,8 @@
97215 # Note: Shared libraries consisting of C++ files are not supported
97216
97217 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
97218 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
97219 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
97220
97221 # C code
97222 # Executables compiled from a single .c file
97223 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
97224 # Shared libaries (only .c supported)
97225 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
97226 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
97227 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
97228 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
97229 # Remove .so files from "xxx-objs"
97230 host-cobjs := $(filter-out %.so,$(host-cobjs))
97231 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
97232
97233 -#Object (.o) files used by the shared libaries
97234 +# Object (.o) files used by the shared libaries
97235 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
97236 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
97237
97238 # output directory for programs/.o files
97239 # hostprogs-y := tools/build may have been specified. Retrieve directory
97240 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
97241 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
97242 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
97243 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
97244 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
97245 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
97246 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
97247 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
97248
97249 obj-dirs += $(host-objdirs)
97250 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
97251 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
97252 $(call if_changed_dep,host-cshobjs)
97253
97254 +# Compile .c file, create position independent .o file
97255 +# host-cxxshobjs -> .o
97256 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
97257 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
97258 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
97259 + $(call if_changed_dep,host-cxxshobjs)
97260 +
97261 # Link a shared library, based on position independent .o files
97262 # *.o -> .so shared library (host-cshlib)
97263 quiet_cmd_host-cshlib = HOSTLLD -shared $@
97264 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
97265 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
97266 $(call if_changed,host-cshlib)
97267
97268 +# Link a shared library, based on position independent .o files
97269 +# *.o -> .so shared library (host-cxxshlib)
97270 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
97271 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
97272 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
97273 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
97274 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
97275 + $(call if_changed,host-cxxshlib)
97276 +
97277 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
97278 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
97279 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
97280
97281 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
97282 index 078fe1d..fbdb363 100644
97283 --- a/scripts/basic/fixdep.c
97284 +++ b/scripts/basic/fixdep.c
97285 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
97286 /*
97287 * Lookup a value in the configuration string.
97288 */
97289 -static int is_defined_config(const char *name, int len, unsigned int hash)
97290 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
97291 {
97292 struct item *aux;
97293
97294 @@ -211,10 +211,10 @@ static void clear_config(void)
97295 /*
97296 * Record the use of a CONFIG_* word.
97297 */
97298 -static void use_config(const char *m, int slen)
97299 +static void use_config(const char *m, unsigned int slen)
97300 {
97301 unsigned int hash = strhash(m, slen);
97302 - int c, i;
97303 + unsigned int c, i;
97304
97305 if (is_defined_config(m, slen, hash))
97306 return;
97307 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
97308
97309 static void parse_config_file(const char *map, size_t len)
97310 {
97311 - const int *end = (const int *) (map + len);
97312 + const unsigned int *end = (const unsigned int *) (map + len);
97313 /* start at +1, so that p can never be < map */
97314 - const int *m = (const int *) map + 1;
97315 + const unsigned int *m = (const unsigned int *) map + 1;
97316 const char *p, *q;
97317
97318 for (; m < end; m++) {
97319 @@ -435,7 +435,7 @@ static void print_deps(void)
97320 static void traps(void)
97321 {
97322 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
97323 - int *p = (int *)test;
97324 + unsigned int *p = (unsigned int *)test;
97325
97326 if (*p != INT_CONF) {
97327 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
97328 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
97329 new file mode 100644
97330 index 0000000..5e0222d
97331 --- /dev/null
97332 +++ b/scripts/gcc-plugin.sh
97333 @@ -0,0 +1,17 @@
97334 +#!/bin/bash
97335 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
97336 +#include "gcc-plugin.h"
97337 +#include "tree.h"
97338 +#include "tm.h"
97339 +#include "rtl.h"
97340 +#ifdef ENABLE_BUILD_WITH_CXX
97341 +#warning $2
97342 +#else
97343 +#warning $1
97344 +#endif
97345 +EOF`
97346 +if [ $? -eq 0 ]
97347 +then
97348 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
97349 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
97350 +fi
97351 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
97352 index 5de5660..d3deb89 100644
97353 --- a/scripts/headers_install.sh
97354 +++ b/scripts/headers_install.sh
97355 @@ -32,6 +32,7 @@ do
97356 FILE="$(basename "$i")"
97357 sed -r \
97358 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
97359 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
97360 -e 's/__attribute_const__([ \t]|$)/\1/g' \
97361 -e 's@^#include <linux/compiler.h>@@' \
97362 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
97363 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
97364 index 0149949..d482a0d 100644
97365 --- a/scripts/link-vmlinux.sh
97366 +++ b/scripts/link-vmlinux.sh
97367 @@ -158,7 +158,7 @@ else
97368 fi;
97369
97370 # final build of init/
97371 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
97372 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
97373
97374 kallsymso=""
97375 kallsyms_vmlinux=""
97376 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
97377 index 2370863..212fbca 100644
97378 --- a/scripts/mod/file2alias.c
97379 +++ b/scripts/mod/file2alias.c
97380 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
97381 unsigned long size, unsigned long id_size,
97382 void *symval)
97383 {
97384 - int i;
97385 + unsigned int i;
97386
97387 if (size % id_size || size < id_size) {
97388 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
97389 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
97390 /* USB is special because the bcdDevice can be matched against a numeric range */
97391 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
97392 static void do_usb_entry(void *symval,
97393 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
97394 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
97395 unsigned char range_lo, unsigned char range_hi,
97396 unsigned char max, struct module *mod)
97397 {
97398 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
97399 {
97400 unsigned int devlo, devhi;
97401 unsigned char chi, clo, max;
97402 - int ndigits;
97403 + unsigned int ndigits;
97404
97405 DEF_FIELD(symval, usb_device_id, match_flags);
97406 DEF_FIELD(symval, usb_device_id, idVendor);
97407 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
97408 for (i = 0; i < count; i++) {
97409 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
97410 char acpi_id[sizeof(*id)];
97411 - int j;
97412 + unsigned int j;
97413
97414 buf_printf(&mod->dev_table_buf,
97415 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
97416 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97417
97418 for (j = 0; j < PNP_MAX_DEVICES; j++) {
97419 const char *id = (char *)(*devs)[j].id;
97420 - int i2, j2;
97421 + unsigned int i2, j2;
97422 int dup = 0;
97423
97424 if (!id[0])
97425 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
97426 /* add an individual alias for every device entry */
97427 if (!dup) {
97428 char acpi_id[PNP_ID_LEN];
97429 - int k;
97430 + unsigned int k;
97431
97432 buf_printf(&mod->dev_table_buf,
97433 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
97434 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
97435 static int do_dmi_entry(const char *filename, void *symval,
97436 char *alias)
97437 {
97438 - int i, j;
97439 + unsigned int i, j;
97440 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
97441 sprintf(alias, "dmi*");
97442
97443 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
97444 index 6216434..050cf89 100644
97445 --- a/scripts/mod/modpost.c
97446 +++ b/scripts/mod/modpost.c
97447 @@ -930,6 +930,7 @@ enum mismatch {
97448 ANY_INIT_TO_ANY_EXIT,
97449 ANY_EXIT_TO_ANY_INIT,
97450 EXPORT_TO_INIT_EXIT,
97451 + DATA_TO_TEXT
97452 };
97453
97454 struct sectioncheck {
97455 @@ -1016,6 +1017,12 @@ const struct sectioncheck sectioncheck[] = {
97456 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
97457 .mismatch = EXPORT_TO_INIT_EXIT,
97458 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
97459 +},
97460 +/* Do not reference code from writable data */
97461 +{
97462 + .fromsec = { DATA_SECTIONS, NULL },
97463 + .tosec = { TEXT_SECTIONS, NULL },
97464 + .mismatch = DATA_TO_TEXT
97465 }
97466 };
97467
97468 @@ -1136,10 +1143,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
97469 continue;
97470 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
97471 continue;
97472 - if (sym->st_value == addr)
97473 - return sym;
97474 /* Find a symbol nearby - addr are maybe negative */
97475 d = sym->st_value - addr;
97476 + if (d == 0)
97477 + return sym;
97478 if (d < 0)
97479 d = addr - sym->st_value;
97480 if (d < distance) {
97481 @@ -1417,6 +1424,14 @@ static void report_sec_mismatch(const char *modname,
97482 tosym, prl_to, prl_to, tosym);
97483 free(prl_to);
97484 break;
97485 + case DATA_TO_TEXT:
97486 +#if 0
97487 + fprintf(stderr,
97488 + "The %s %s:%s references\n"
97489 + "the %s %s:%s%s\n",
97490 + from, fromsec, fromsym, to, tosec, tosym, to_p);
97491 +#endif
97492 + break;
97493 }
97494 fprintf(stderr, "\n");
97495 }
97496 @@ -1651,7 +1666,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
97497 static void check_sec_ref(struct module *mod, const char *modname,
97498 struct elf_info *elf)
97499 {
97500 - int i;
97501 + unsigned int i;
97502 Elf_Shdr *sechdrs = elf->sechdrs;
97503
97504 /* Walk through all sections */
97505 @@ -1770,7 +1785,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
97506 va_end(ap);
97507 }
97508
97509 -void buf_write(struct buffer *buf, const char *s, int len)
97510 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
97511 {
97512 if (buf->size - buf->pos < len) {
97513 buf->size += len + SZ;
97514 @@ -1989,7 +2004,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
97515 if (fstat(fileno(file), &st) < 0)
97516 goto close_write;
97517
97518 - if (st.st_size != b->pos)
97519 + if (st.st_size != (off_t)b->pos)
97520 goto close_write;
97521
97522 tmp = NOFAIL(malloc(b->pos));
97523 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
97524 index 51207e4..f7d603d 100644
97525 --- a/scripts/mod/modpost.h
97526 +++ b/scripts/mod/modpost.h
97527 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
97528
97529 struct buffer {
97530 char *p;
97531 - int pos;
97532 - int size;
97533 + unsigned int pos;
97534 + unsigned int size;
97535 };
97536
97537 void __attribute__((format(printf, 2, 3)))
97538 buf_printf(struct buffer *buf, const char *fmt, ...);
97539
97540 void
97541 -buf_write(struct buffer *buf, const char *s, int len);
97542 +buf_write(struct buffer *buf, const char *s, unsigned int len);
97543
97544 struct module {
97545 struct module *next;
97546 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
97547 index 9dfcd6d..099068e 100644
97548 --- a/scripts/mod/sumversion.c
97549 +++ b/scripts/mod/sumversion.c
97550 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
97551 goto out;
97552 }
97553
97554 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
97555 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
97556 warn("writing sum in %s failed: %s\n",
97557 filename, strerror(errno));
97558 goto out;
97559 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
97560 index 0865b3e..7235dd4 100644
97561 --- a/scripts/module-common.lds
97562 +++ b/scripts/module-common.lds
97563 @@ -6,6 +6,10 @@
97564 SECTIONS {
97565 /DISCARD/ : { *(.discard) }
97566
97567 + .rodata : {
97568 + *(.rodata) *(.rodata.*)
97569 + *(.data..read_only)
97570 + }
97571 __ksymtab : { *(SORT(___ksymtab+*)) }
97572 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
97573 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
97574 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
97575 index acb8650..b8c5f02 100644
97576 --- a/scripts/package/builddeb
97577 +++ b/scripts/package/builddeb
97578 @@ -246,6 +246,7 @@ fi
97579 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
97580 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
97581 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
97582 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
97583 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
97584 mkdir -p "$destdir"
97585 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
97586 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
97587 index 68bb4ef..2f419e1 100644
97588 --- a/scripts/pnmtologo.c
97589 +++ b/scripts/pnmtologo.c
97590 @@ -244,14 +244,14 @@ static void write_header(void)
97591 fprintf(out, " * Linux logo %s\n", logoname);
97592 fputs(" */\n\n", out);
97593 fputs("#include <linux/linux_logo.h>\n\n", out);
97594 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
97595 + fprintf(out, "static unsigned char %s_data[] = {\n",
97596 logoname);
97597 }
97598
97599 static void write_footer(void)
97600 {
97601 fputs("\n};\n\n", out);
97602 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
97603 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
97604 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
97605 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
97606 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
97607 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
97608 fputs("\n};\n\n", out);
97609
97610 /* write logo clut */
97611 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
97612 + fprintf(out, "static unsigned char %s_clut[] = {\n",
97613 logoname);
97614 write_hex_cnt = 0;
97615 for (i = 0; i < logo_clutsize; i++) {
97616 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
97617 index f5eb43d..1814de8 100644
97618 --- a/scripts/sortextable.h
97619 +++ b/scripts/sortextable.h
97620 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
97621 const char *secstrtab;
97622 const char *strtab;
97623 char *extab_image;
97624 - int extab_index = 0;
97625 - int i;
97626 - int idx;
97627 + unsigned int extab_index = 0;
97628 + unsigned int i;
97629 + unsigned int idx;
97630
97631 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
97632 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
97633 diff --git a/security/Kconfig b/security/Kconfig
97634 index e9c6ac7..5b9d82e 100644
97635 --- a/security/Kconfig
97636 +++ b/security/Kconfig
97637 @@ -4,6 +4,959 @@
97638
97639 menu "Security options"
97640
97641 +menu "Grsecurity"
97642 +
97643 + config ARCH_TRACK_EXEC_LIMIT
97644 + bool
97645 +
97646 + config PAX_KERNEXEC_PLUGIN
97647 + bool
97648 +
97649 + config PAX_PER_CPU_PGD
97650 + bool
97651 +
97652 + config TASK_SIZE_MAX_SHIFT
97653 + int
97654 + depends on X86_64
97655 + default 47 if !PAX_PER_CPU_PGD
97656 + default 42 if PAX_PER_CPU_PGD
97657 +
97658 + config PAX_ENABLE_PAE
97659 + bool
97660 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
97661 +
97662 + config PAX_USERCOPY_SLABS
97663 + bool
97664 +
97665 +config GRKERNSEC
97666 + bool "Grsecurity"
97667 + select CRYPTO
97668 + select CRYPTO_SHA256
97669 + select PROC_FS
97670 + select STOP_MACHINE
97671 + select TTY
97672 + help
97673 + If you say Y here, you will be able to configure many features
97674 + that will enhance the security of your system. It is highly
97675 + recommended that you say Y here and read through the help
97676 + for each option so that you fully understand the features and
97677 + can evaluate their usefulness for your machine.
97678 +
97679 +choice
97680 + prompt "Configuration Method"
97681 + depends on GRKERNSEC
97682 + default GRKERNSEC_CONFIG_CUSTOM
97683 + help
97684 +
97685 +config GRKERNSEC_CONFIG_AUTO
97686 + bool "Automatic"
97687 + help
97688 + If you choose this configuration method, you'll be able to answer a small
97689 + number of simple questions about how you plan to use this kernel.
97690 + The settings of grsecurity and PaX will be automatically configured for
97691 + the highest commonly-used settings within the provided constraints.
97692 +
97693 + If you require additional configuration, custom changes can still be made
97694 + from the "custom configuration" menu.
97695 +
97696 +config GRKERNSEC_CONFIG_CUSTOM
97697 + bool "Custom"
97698 + help
97699 + If you choose this configuration method, you'll be able to configure all
97700 + grsecurity and PaX settings manually. Via this method, no options are
97701 + automatically enabled.
97702 +
97703 +endchoice
97704 +
97705 +choice
97706 + prompt "Usage Type"
97707 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97708 + default GRKERNSEC_CONFIG_SERVER
97709 + help
97710 +
97711 +config GRKERNSEC_CONFIG_SERVER
97712 + bool "Server"
97713 + help
97714 + Choose this option if you plan to use this kernel on a server.
97715 +
97716 +config GRKERNSEC_CONFIG_DESKTOP
97717 + bool "Desktop"
97718 + help
97719 + Choose this option if you plan to use this kernel on a desktop.
97720 +
97721 +endchoice
97722 +
97723 +choice
97724 + prompt "Virtualization Type"
97725 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
97726 + default GRKERNSEC_CONFIG_VIRT_NONE
97727 + help
97728 +
97729 +config GRKERNSEC_CONFIG_VIRT_NONE
97730 + bool "None"
97731 + help
97732 + Choose this option if this kernel will be run on bare metal.
97733 +
97734 +config GRKERNSEC_CONFIG_VIRT_GUEST
97735 + bool "Guest"
97736 + help
97737 + Choose this option if this kernel will be run as a VM guest.
97738 +
97739 +config GRKERNSEC_CONFIG_VIRT_HOST
97740 + bool "Host"
97741 + help
97742 + Choose this option if this kernel will be run as a VM host.
97743 +
97744 +endchoice
97745 +
97746 +choice
97747 + prompt "Virtualization Hardware"
97748 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97749 + help
97750 +
97751 +config GRKERNSEC_CONFIG_VIRT_EPT
97752 + bool "EPT/RVI Processor Support"
97753 + depends on X86
97754 + help
97755 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
97756 + hardware virtualization. This allows for additional kernel hardening protections
97757 + to operate without additional performance impact.
97758 +
97759 + To see if your Intel processor supports EPT, see:
97760 + http://ark.intel.com/Products/VirtualizationTechnology
97761 + (Most Core i3/5/7 support EPT)
97762 +
97763 + To see if your AMD processor supports RVI, see:
97764 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
97765 +
97766 +config GRKERNSEC_CONFIG_VIRT_SOFT
97767 + bool "First-gen/No Hardware Virtualization"
97768 + help
97769 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
97770 + support hardware virtualization or doesn't support the EPT/RVI extensions.
97771 +
97772 +endchoice
97773 +
97774 +choice
97775 + prompt "Virtualization Software"
97776 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
97777 + help
97778 +
97779 +config GRKERNSEC_CONFIG_VIRT_XEN
97780 + bool "Xen"
97781 + help
97782 + Choose this option if this kernel is running as a Xen guest or host.
97783 +
97784 +config GRKERNSEC_CONFIG_VIRT_VMWARE
97785 + bool "VMWare"
97786 + help
97787 + Choose this option if this kernel is running as a VMWare guest or host.
97788 +
97789 +config GRKERNSEC_CONFIG_VIRT_KVM
97790 + bool "KVM"
97791 + help
97792 + Choose this option if this kernel is running as a KVM guest or host.
97793 +
97794 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
97795 + bool "VirtualBox"
97796 + help
97797 + Choose this option if this kernel is running as a VirtualBox guest or host.
97798 +
97799 +endchoice
97800 +
97801 +choice
97802 + prompt "Required Priorities"
97803 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97804 + default GRKERNSEC_CONFIG_PRIORITY_PERF
97805 + help
97806 +
97807 +config GRKERNSEC_CONFIG_PRIORITY_PERF
97808 + bool "Performance"
97809 + help
97810 + Choose this option if performance is of highest priority for this deployment
97811 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
97812 + clearing of structures intended for userland, and freed memory sanitizing will
97813 + be disabled.
97814 +
97815 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
97816 + bool "Security"
97817 + help
97818 + Choose this option if security is of highest priority for this deployment of
97819 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
97820 + for userland, and freed memory sanitizing will be enabled for this kernel.
97821 + In a worst-case scenario, these features can introduce a 20% performance hit
97822 + (UDEREF on x64 contributing half of this hit).
97823 +
97824 +endchoice
97825 +
97826 +menu "Default Special Groups"
97827 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
97828 +
97829 +config GRKERNSEC_PROC_GID
97830 + int "GID exempted from /proc restrictions"
97831 + default 1001
97832 + help
97833 + Setting this GID determines which group will be exempted from
97834 + grsecurity's /proc restrictions, allowing users of the specified
97835 + group to view network statistics and the existence of other users'
97836 + processes on the system. This GID may also be chosen at boot time
97837 + via "grsec_proc_gid=" on the kernel commandline.
97838 +
97839 +config GRKERNSEC_TPE_UNTRUSTED_GID
97840 + int "GID for TPE-untrusted users"
97841 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
97842 + default 1005
97843 + help
97844 + Setting this GID determines which group untrusted users should
97845 + be added to. These users will be placed under grsecurity's Trusted Path
97846 + Execution mechanism, preventing them from executing their own binaries.
97847 + The users will only be able to execute binaries in directories owned and
97848 + writable only by the root user. If the sysctl option is enabled, a sysctl
97849 + option with name "tpe_gid" is created.
97850 +
97851 +config GRKERNSEC_TPE_TRUSTED_GID
97852 + int "GID for TPE-trusted users"
97853 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
97854 + default 1005
97855 + help
97856 + Setting this GID determines what group TPE restrictions will be
97857 + *disabled* for. If the sysctl option is enabled, a sysctl option
97858 + with name "tpe_gid" is created.
97859 +
97860 +config GRKERNSEC_SYMLINKOWN_GID
97861 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
97862 + depends on GRKERNSEC_CONFIG_SERVER
97863 + default 1006
97864 + help
97865 + Setting this GID determines what group kernel-enforced
97866 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
97867 + is enabled, a sysctl option with name "symlinkown_gid" is created.
97868 +
97869 +
97870 +endmenu
97871 +
97872 +menu "Customize Configuration"
97873 +depends on GRKERNSEC
97874 +
97875 +menu "PaX"
97876 +
97877 +config PAX
97878 + bool "Enable various PaX features"
97879 + default y if GRKERNSEC_CONFIG_AUTO
97880 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
97881 + help
97882 + This allows you to enable various PaX features. PaX adds
97883 + intrusion prevention mechanisms to the kernel that reduce
97884 + the risks posed by exploitable memory corruption bugs.
97885 +
97886 +menu "PaX Control"
97887 + depends on PAX
97888 +
97889 +config PAX_SOFTMODE
97890 + bool 'Support soft mode'
97891 + help
97892 + Enabling this option will allow you to run PaX in soft mode, that
97893 + is, PaX features will not be enforced by default, only on executables
97894 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
97895 + support as they are the only way to mark executables for soft mode use.
97896 +
97897 + Soft mode can be activated by using the "pax_softmode=1" kernel command
97898 + line option on boot. Furthermore you can control various PaX features
97899 + at runtime via the entries in /proc/sys/kernel/pax.
97900 +
97901 +config PAX_EI_PAX
97902 + bool 'Use legacy ELF header marking'
97903 + default y if GRKERNSEC_CONFIG_AUTO
97904 + help
97905 + Enabling this option will allow you to control PaX features on
97906 + a per executable basis via the 'chpax' utility available at
97907 + http://pax.grsecurity.net/. The control flags will be read from
97908 + an otherwise reserved part of the ELF header. This marking has
97909 + numerous drawbacks (no support for soft-mode, toolchain does not
97910 + know about the non-standard use of the ELF header) therefore it
97911 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
97912 + support.
97913 +
97914 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
97915 + support as well, they will override the legacy EI_PAX marks.
97916 +
97917 + If you enable none of the marking options then all applications
97918 + will run with PaX enabled on them by default.
97919 +
97920 +config PAX_PT_PAX_FLAGS
97921 + bool 'Use ELF program header marking'
97922 + default y if GRKERNSEC_CONFIG_AUTO
97923 + help
97924 + Enabling this option will allow you to control PaX features on
97925 + a per executable basis via the 'paxctl' utility available at
97926 + http://pax.grsecurity.net/. The control flags will be read from
97927 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
97928 + has the benefits of supporting both soft mode and being fully
97929 + integrated into the toolchain (the binutils patch is available
97930 + from http://pax.grsecurity.net).
97931 +
97932 + Note that if you enable the legacy EI_PAX marking support as well,
97933 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
97934 +
97935 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97936 + must make sure that the marks are the same if a binary has both marks.
97937 +
97938 + If you enable none of the marking options then all applications
97939 + will run with PaX enabled on them by default.
97940 +
97941 +config PAX_XATTR_PAX_FLAGS
97942 + bool 'Use filesystem extended attributes marking'
97943 + default y if GRKERNSEC_CONFIG_AUTO
97944 + select CIFS_XATTR if CIFS
97945 + select EXT2_FS_XATTR if EXT2_FS
97946 + select EXT3_FS_XATTR if EXT3_FS
97947 + select EXT4_FS_XATTR if EXT4_FS
97948 + select JFFS2_FS_XATTR if JFFS2_FS
97949 + select REISERFS_FS_XATTR if REISERFS_FS
97950 + select SQUASHFS_XATTR if SQUASHFS
97951 + select TMPFS_XATTR if TMPFS
97952 + select UBIFS_FS_XATTR if UBIFS_FS
97953 + help
97954 + Enabling this option will allow you to control PaX features on
97955 + a per executable basis via the 'setfattr' utility. The control
97956 + flags will be read from the user.pax.flags extended attribute of
97957 + the file. This marking has the benefit of supporting binary-only
97958 + applications that self-check themselves (e.g., skype) and would
97959 + not tolerate chpax/paxctl changes. The main drawback is that
97960 + extended attributes are not supported by some filesystems (e.g.,
97961 + isofs, udf, vfat) so copying files through such filesystems will
97962 + lose the extended attributes and these PaX markings.
97963 +
97964 + Note that if you enable the legacy EI_PAX marking support as well,
97965 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
97966 +
97967 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
97968 + must make sure that the marks are the same if a binary has both marks.
97969 +
97970 + If you enable none of the marking options then all applications
97971 + will run with PaX enabled on them by default.
97972 +
97973 +choice
97974 + prompt 'MAC system integration'
97975 + default PAX_HAVE_ACL_FLAGS
97976 + help
97977 + Mandatory Access Control systems have the option of controlling
97978 + PaX flags on a per executable basis, choose the method supported
97979 + by your particular system.
97980 +
97981 + - "none": if your MAC system does not interact with PaX,
97982 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
97983 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
97984 +
97985 + NOTE: this option is for developers/integrators only.
97986 +
97987 + config PAX_NO_ACL_FLAGS
97988 + bool 'none'
97989 +
97990 + config PAX_HAVE_ACL_FLAGS
97991 + bool 'direct'
97992 +
97993 + config PAX_HOOK_ACL_FLAGS
97994 + bool 'hook'
97995 +endchoice
97996 +
97997 +endmenu
97998 +
97999 +menu "Non-executable pages"
98000 + depends on PAX
98001 +
98002 +config PAX_NOEXEC
98003 + bool "Enforce non-executable pages"
98004 + default y if GRKERNSEC_CONFIG_AUTO
98005 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
98006 + help
98007 + By design some architectures do not allow for protecting memory
98008 + pages against execution or even if they do, Linux does not make
98009 + use of this feature. In practice this means that if a page is
98010 + readable (such as the stack or heap) it is also executable.
98011 +
98012 + There is a well known exploit technique that makes use of this
98013 + fact and a common programming mistake where an attacker can
98014 + introduce code of his choice somewhere in the attacked program's
98015 + memory (typically the stack or the heap) and then execute it.
98016 +
98017 + If the attacked program was running with different (typically
98018 + higher) privileges than that of the attacker, then he can elevate
98019 + his own privilege level (e.g. get a root shell, write to files for
98020 + which he does not have write access to, etc).
98021 +
98022 + Enabling this option will let you choose from various features
98023 + that prevent the injection and execution of 'foreign' code in
98024 + a program.
98025 +
98026 + This will also break programs that rely on the old behaviour and
98027 + expect that dynamically allocated memory via the malloc() family
98028 + of functions is executable (which it is not). Notable examples
98029 + are the XFree86 4.x server, the java runtime and wine.
98030 +
98031 +config PAX_PAGEEXEC
98032 + bool "Paging based non-executable pages"
98033 + default y if GRKERNSEC_CONFIG_AUTO
98034 + 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)
98035 + select ARCH_TRACK_EXEC_LIMIT if X86_32
98036 + help
98037 + This implementation is based on the paging feature of the CPU.
98038 + On i386 without hardware non-executable bit support there is a
98039 + variable but usually low performance impact, however on Intel's
98040 + P4 core based CPUs it is very high so you should not enable this
98041 + for kernels meant to be used on such CPUs.
98042 +
98043 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
98044 + with hardware non-executable bit support there is no performance
98045 + impact, on ppc the impact is negligible.
98046 +
98047 + Note that several architectures require various emulations due to
98048 + badly designed userland ABIs, this will cause a performance impact
98049 + but will disappear as soon as userland is fixed. For example, ppc
98050 + userland MUST have been built with secure-plt by a recent toolchain.
98051 +
98052 +config PAX_SEGMEXEC
98053 + bool "Segmentation based non-executable pages"
98054 + default y if GRKERNSEC_CONFIG_AUTO
98055 + depends on PAX_NOEXEC && X86_32
98056 + help
98057 + This implementation is based on the segmentation feature of the
98058 + CPU and has a very small performance impact, however applications
98059 + will be limited to a 1.5 GB address space instead of the normal
98060 + 3 GB.
98061 +
98062 +config PAX_EMUTRAMP
98063 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
98064 + default y if PARISC
98065 + help
98066 + There are some programs and libraries that for one reason or
98067 + another attempt to execute special small code snippets from
98068 + non-executable memory pages. Most notable examples are the
98069 + signal handler return code generated by the kernel itself and
98070 + the GCC trampolines.
98071 +
98072 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
98073 + such programs will no longer work under your kernel.
98074 +
98075 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
98076 + utilities to enable trampoline emulation for the affected programs
98077 + yet still have the protection provided by the non-executable pages.
98078 +
98079 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
98080 + your system will not even boot.
98081 +
98082 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
98083 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
98084 + for the affected files.
98085 +
98086 + NOTE: enabling this feature *may* open up a loophole in the
98087 + protection provided by non-executable pages that an attacker
98088 + could abuse. Therefore the best solution is to not have any
98089 + files on your system that would require this option. This can
98090 + be achieved by not using libc5 (which relies on the kernel
98091 + signal handler return code) and not using or rewriting programs
98092 + that make use of the nested function implementation of GCC.
98093 + Skilled users can just fix GCC itself so that it implements
98094 + nested function calls in a way that does not interfere with PaX.
98095 +
98096 +config PAX_EMUSIGRT
98097 + bool "Automatically emulate sigreturn trampolines"
98098 + depends on PAX_EMUTRAMP && PARISC
98099 + default y
98100 + help
98101 + Enabling this option will have the kernel automatically detect
98102 + and emulate signal return trampolines executing on the stack
98103 + that would otherwise lead to task termination.
98104 +
98105 + This solution is intended as a temporary one for users with
98106 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
98107 + Modula-3 runtime, etc) or executables linked to such, basically
98108 + everything that does not specify its own SA_RESTORER function in
98109 + normal executable memory like glibc 2.1+ does.
98110 +
98111 + On parisc you MUST enable this option, otherwise your system will
98112 + not even boot.
98113 +
98114 + NOTE: this feature cannot be disabled on a per executable basis
98115 + and since it *does* open up a loophole in the protection provided
98116 + by non-executable pages, the best solution is to not have any
98117 + files on your system that would require this option.
98118 +
98119 +config PAX_MPROTECT
98120 + bool "Restrict mprotect()"
98121 + default y if GRKERNSEC_CONFIG_AUTO
98122 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
98123 + help
98124 + Enabling this option will prevent programs from
98125 + - changing the executable status of memory pages that were
98126 + not originally created as executable,
98127 + - making read-only executable pages writable again,
98128 + - creating executable pages from anonymous memory,
98129 + - making read-only-after-relocations (RELRO) data pages writable again.
98130 +
98131 + You should say Y here to complete the protection provided by
98132 + the enforcement of non-executable pages.
98133 +
98134 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98135 + this feature on a per file basis.
98136 +
98137 +config PAX_MPROTECT_COMPAT
98138 + bool "Use legacy/compat protection demoting (read help)"
98139 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98140 + depends on PAX_MPROTECT
98141 + help
98142 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
98143 + by sending the proper error code to the application. For some broken
98144 + userland, this can cause problems with Python or other applications. The
98145 + current implementation however allows for applications like clamav to
98146 + detect if JIT compilation/execution is allowed and to fall back gracefully
98147 + to an interpreter-based mode if it does not. While we encourage everyone
98148 + to use the current implementation as-is and push upstream to fix broken
98149 + userland (note that the RWX logging option can assist with this), in some
98150 + environments this may not be possible. Having to disable MPROTECT
98151 + completely on certain binaries reduces the security benefit of PaX,
98152 + so this option is provided for those environments to revert to the old
98153 + behavior.
98154 +
98155 +config PAX_ELFRELOCS
98156 + bool "Allow ELF text relocations (read help)"
98157 + depends on PAX_MPROTECT
98158 + default n
98159 + help
98160 + Non-executable pages and mprotect() restrictions are effective
98161 + in preventing the introduction of new executable code into an
98162 + attacked task's address space. There remain only two venues
98163 + for this kind of attack: if the attacker can execute already
98164 + existing code in the attacked task then he can either have it
98165 + create and mmap() a file containing his code or have it mmap()
98166 + an already existing ELF library that does not have position
98167 + independent code in it and use mprotect() on it to make it
98168 + writable and copy his code there. While protecting against
98169 + the former approach is beyond PaX, the latter can be prevented
98170 + by having only PIC ELF libraries on one's system (which do not
98171 + need to relocate their code). If you are sure this is your case,
98172 + as is the case with all modern Linux distributions, then leave
98173 + this option disabled. You should say 'n' here.
98174 +
98175 +config PAX_ETEXECRELOCS
98176 + bool "Allow ELF ET_EXEC text relocations"
98177 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
98178 + select PAX_ELFRELOCS
98179 + default y
98180 + help
98181 + On some architectures there are incorrectly created applications
98182 + that require text relocations and would not work without enabling
98183 + this option. If you are an alpha, ia64 or parisc user, you should
98184 + enable this option and disable it once you have made sure that
98185 + none of your applications need it.
98186 +
98187 +config PAX_EMUPLT
98188 + bool "Automatically emulate ELF PLT"
98189 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
98190 + default y
98191 + help
98192 + Enabling this option will have the kernel automatically detect
98193 + and emulate the Procedure Linkage Table entries in ELF files.
98194 + On some architectures such entries are in writable memory, and
98195 + become non-executable leading to task termination. Therefore
98196 + it is mandatory that you enable this option on alpha, parisc,
98197 + sparc and sparc64, otherwise your system would not even boot.
98198 +
98199 + NOTE: this feature *does* open up a loophole in the protection
98200 + provided by the non-executable pages, therefore the proper
98201 + solution is to modify the toolchain to produce a PLT that does
98202 + not need to be writable.
98203 +
98204 +config PAX_DLRESOLVE
98205 + bool 'Emulate old glibc resolver stub'
98206 + depends on PAX_EMUPLT && SPARC
98207 + default n
98208 + help
98209 + This option is needed if userland has an old glibc (before 2.4)
98210 + that puts a 'save' instruction into the runtime generated resolver
98211 + stub that needs special emulation.
98212 +
98213 +config PAX_KERNEXEC
98214 + bool "Enforce non-executable kernel pages"
98215 + 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))
98216 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
98217 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
98218 + select PAX_KERNEXEC_PLUGIN if X86_64
98219 + help
98220 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
98221 + that is, enabling this option will make it harder to inject
98222 + and execute 'foreign' code in kernel memory itself.
98223 +
98224 +choice
98225 + prompt "Return Address Instrumentation Method"
98226 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
98227 + depends on PAX_KERNEXEC_PLUGIN
98228 + help
98229 + Select the method used to instrument function pointer dereferences.
98230 + Note that binary modules cannot be instrumented by this approach.
98231 +
98232 + Note that the implementation requires a gcc with plugin support,
98233 + i.e., gcc 4.5 or newer. You may need to install the supporting
98234 + headers explicitly in addition to the normal gcc package.
98235 +
98236 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
98237 + bool "bts"
98238 + help
98239 + This method is compatible with binary only modules but has
98240 + a higher runtime overhead.
98241 +
98242 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
98243 + bool "or"
98244 + depends on !PARAVIRT
98245 + help
98246 + This method is incompatible with binary only modules but has
98247 + a lower runtime overhead.
98248 +endchoice
98249 +
98250 +config PAX_KERNEXEC_PLUGIN_METHOD
98251 + string
98252 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
98253 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
98254 + default ""
98255 +
98256 +config PAX_KERNEXEC_MODULE_TEXT
98257 + int "Minimum amount of memory reserved for module code"
98258 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
98259 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
98260 + depends on PAX_KERNEXEC && X86_32
98261 + help
98262 + Due to implementation details the kernel must reserve a fixed
98263 + amount of memory for runtime allocated code (such as modules)
98264 + at compile time that cannot be changed at runtime. Here you
98265 + can specify the minimum amount in MB that will be reserved.
98266 + Due to the same implementation details this size will always
98267 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
98268 + the actually available memory for runtime allocated code will
98269 + usually be more than this minimum.
98270 +
98271 + The default 4 MB should be enough for most users but if you have
98272 + an excessive number of modules (e.g., most distribution configs
98273 + compile many drivers as modules) or use huge modules such as
98274 + nvidia's kernel driver, you will need to adjust this amount.
98275 + A good rule of thumb is to look at your currently loaded kernel
98276 + modules and add up their sizes.
98277 +
98278 +endmenu
98279 +
98280 +menu "Address Space Layout Randomization"
98281 + depends on PAX
98282 +
98283 +config PAX_ASLR
98284 + bool "Address Space Layout Randomization"
98285 + default y if GRKERNSEC_CONFIG_AUTO
98286 + help
98287 + Many if not most exploit techniques rely on the knowledge of
98288 + certain addresses in the attacked program. The following options
98289 + will allow the kernel to apply a certain amount of randomization
98290 + to specific parts of the program thereby forcing an attacker to
98291 + guess them in most cases. Any failed guess will most likely crash
98292 + the attacked program which allows the kernel to detect such attempts
98293 + and react on them. PaX itself provides no reaction mechanisms,
98294 + instead it is strongly encouraged that you make use of Nergal's
98295 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
98296 + (http://www.grsecurity.net/) built-in crash detection features or
98297 + develop one yourself.
98298 +
98299 + By saying Y here you can choose to randomize the following areas:
98300 + - top of the task's kernel stack
98301 + - top of the task's userland stack
98302 + - base address for mmap() requests that do not specify one
98303 + (this includes all libraries)
98304 + - base address of the main executable
98305 +
98306 + It is strongly recommended to say Y here as address space layout
98307 + randomization has negligible impact on performance yet it provides
98308 + a very effective protection.
98309 +
98310 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
98311 + this feature on a per file basis.
98312 +
98313 +config PAX_RANDKSTACK
98314 + bool "Randomize kernel stack base"
98315 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
98316 + depends on X86_TSC && X86
98317 + help
98318 + By saying Y here the kernel will randomize every task's kernel
98319 + stack on every system call. This will not only force an attacker
98320 + to guess it but also prevent him from making use of possible
98321 + leaked information about it.
98322 +
98323 + Since the kernel stack is a rather scarce resource, randomization
98324 + may cause unexpected stack overflows, therefore you should very
98325 + carefully test your system. Note that once enabled in the kernel
98326 + configuration, this feature cannot be disabled on a per file basis.
98327 +
98328 +config PAX_RANDUSTACK
98329 + bool "Randomize user stack base"
98330 + default y if GRKERNSEC_CONFIG_AUTO
98331 + depends on PAX_ASLR
98332 + help
98333 + By saying Y here the kernel will randomize every task's userland
98334 + stack. The randomization is done in two steps where the second
98335 + one may apply a big amount of shift to the top of the stack and
98336 + cause problems for programs that want to use lots of memory (more
98337 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
98338 + For this reason the second step can be controlled by 'chpax' or
98339 + 'paxctl' on a per file basis.
98340 +
98341 +config PAX_RANDMMAP
98342 + bool "Randomize mmap() base"
98343 + default y if GRKERNSEC_CONFIG_AUTO
98344 + depends on PAX_ASLR
98345 + help
98346 + By saying Y here the kernel will use a randomized base address for
98347 + mmap() requests that do not specify one themselves. As a result
98348 + all dynamically loaded libraries will appear at random addresses
98349 + and therefore be harder to exploit by a technique where an attacker
98350 + attempts to execute library code for his purposes (e.g. spawn a
98351 + shell from an exploited program that is running at an elevated
98352 + privilege level).
98353 +
98354 + Furthermore, if a program is relinked as a dynamic ELF file, its
98355 + base address will be randomized as well, completing the full
98356 + randomization of the address space layout. Attacking such programs
98357 + becomes a guess game. You can find an example of doing this at
98358 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
98359 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
98360 +
98361 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
98362 + feature on a per file basis.
98363 +
98364 +endmenu
98365 +
98366 +menu "Miscellaneous hardening features"
98367 +
98368 +config PAX_MEMORY_SANITIZE
98369 + bool "Sanitize all freed memory"
98370 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98371 + depends on !HIBERNATION
98372 + help
98373 + By saying Y here the kernel will erase memory pages and slab objects
98374 + as soon as they are freed. This in turn reduces the lifetime of data
98375 + stored in them, making it less likely that sensitive information such
98376 + as passwords, cryptographic secrets, etc stay in memory for too long.
98377 +
98378 + This is especially useful for programs whose runtime is short, long
98379 + lived processes and the kernel itself benefit from this as long as
98380 + they ensure timely freeing of memory that may hold sensitive
98381 + information.
98382 +
98383 + A nice side effect of the sanitization of slab objects is the
98384 + reduction of possible info leaks caused by padding bytes within the
98385 + leaky structures. Use-after-free bugs for structures containing
98386 + pointers can also be detected as dereferencing the sanitized pointer
98387 + will generate an access violation.
98388 +
98389 + The tradeoff is performance impact, on a single CPU system kernel
98390 + compilation sees a 3% slowdown, other systems and workloads may vary
98391 + and you are advised to test this feature on your expected workload
98392 + before deploying it.
98393 +
98394 + To reduce the performance penalty by sanitizing pages only, albeit
98395 + limiting the effectiveness of this feature at the same time, slab
98396 + sanitization can be disabled with the kernel commandline parameter
98397 + "pax_sanitize_slab=0".
98398 +
98399 + Note that this feature does not protect data stored in live pages,
98400 + e.g., process memory swapped to disk may stay there for a long time.
98401 +
98402 +config PAX_MEMORY_STACKLEAK
98403 + bool "Sanitize kernel stack"
98404 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98405 + depends on X86
98406 + help
98407 + By saying Y here the kernel will erase the kernel stack before it
98408 + returns from a system call. This in turn reduces the information
98409 + that a kernel stack leak bug can reveal.
98410 +
98411 + Note that such a bug can still leak information that was put on
98412 + the stack by the current system call (the one eventually triggering
98413 + the bug) but traces of earlier system calls on the kernel stack
98414 + cannot leak anymore.
98415 +
98416 + The tradeoff is performance impact: on a single CPU system kernel
98417 + compilation sees a 1% slowdown, other systems and workloads may vary
98418 + and you are advised to test this feature on your expected workload
98419 + before deploying it.
98420 +
98421 + Note that the full feature requires a gcc with plugin support,
98422 + i.e., gcc 4.5 or newer. You may need to install the supporting
98423 + headers explicitly in addition to the normal gcc package. Using
98424 + older gcc versions means that functions with large enough stack
98425 + frames may leave uninitialized memory behind that may be exposed
98426 + to a later syscall leaking the stack.
98427 +
98428 +config PAX_MEMORY_STRUCTLEAK
98429 + bool "Forcibly initialize local variables copied to userland"
98430 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
98431 + help
98432 + By saying Y here the kernel will zero initialize some local
98433 + variables that are going to be copied to userland. This in
98434 + turn prevents unintended information leakage from the kernel
98435 + stack should later code forget to explicitly set all parts of
98436 + the copied variable.
98437 +
98438 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
98439 + at a much smaller coverage.
98440 +
98441 + Note that the implementation requires a gcc with plugin support,
98442 + i.e., gcc 4.5 or newer. You may need to install the supporting
98443 + headers explicitly in addition to the normal gcc package.
98444 +
98445 +config PAX_MEMORY_UDEREF
98446 + bool "Prevent invalid userland pointer dereference"
98447 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
98448 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
98449 + select PAX_PER_CPU_PGD if X86_64
98450 + help
98451 + By saying Y here the kernel will be prevented from dereferencing
98452 + userland pointers in contexts where the kernel expects only kernel
98453 + pointers. This is both a useful runtime debugging feature and a
98454 + security measure that prevents exploiting a class of kernel bugs.
98455 +
98456 + The tradeoff is that some virtualization solutions may experience
98457 + a huge slowdown and therefore you should not enable this feature
98458 + for kernels meant to run in such environments. Whether a given VM
98459 + solution is affected or not is best determined by simply trying it
98460 + out, the performance impact will be obvious right on boot as this
98461 + mechanism engages from very early on. A good rule of thumb is that
98462 + VMs running on CPUs without hardware virtualization support (i.e.,
98463 + the majority of IA-32 CPUs) will likely experience the slowdown.
98464 +
98465 + On X86_64 the kernel will make use of PCID support when available
98466 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
98467 + or performance impact. Pass pax_weakuderef on the kernel command
98468 + line to choose the latter.
98469 +
98470 +config PAX_REFCOUNT
98471 + bool "Prevent various kernel object reference counter overflows"
98472 + default y if GRKERNSEC_CONFIG_AUTO
98473 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
98474 + help
98475 + By saying Y here the kernel will detect and prevent overflowing
98476 + various (but not all) kinds of object reference counters. Such
98477 + overflows can normally occur due to bugs only and are often, if
98478 + not always, exploitable.
98479 +
98480 + The tradeoff is that data structures protected by an overflowed
98481 + refcount will never be freed and therefore will leak memory. Note
98482 + that this leak also happens even without this protection but in
98483 + that case the overflow can eventually trigger the freeing of the
98484 + data structure while it is still being used elsewhere, resulting
98485 + in the exploitable situation that this feature prevents.
98486 +
98487 + Since this has a negligible performance impact, you should enable
98488 + this feature.
98489 +
98490 +config PAX_CONSTIFY_PLUGIN
98491 + bool "Automatically constify eligible structures"
98492 + default y
98493 + depends on !UML && PAX_KERNEXEC
98494 + help
98495 + By saying Y here the compiler will automatically constify a class
98496 + of types that contain only function pointers. This reduces the
98497 + kernel's attack surface and also produces a better memory layout.
98498 +
98499 + Note that the implementation requires a gcc with plugin support,
98500 + i.e., gcc 4.5 or newer. You may need to install the supporting
98501 + headers explicitly in addition to the normal gcc package.
98502 +
98503 + Note that if some code really has to modify constified variables
98504 + then the source code will have to be patched to allow it. Examples
98505 + can be found in PaX itself (the no_const attribute) and for some
98506 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
98507 +
98508 +config PAX_USERCOPY
98509 + bool "Harden heap object copies between kernel and userland"
98510 + default y if GRKERNSEC_CONFIG_AUTO
98511 + depends on ARM || IA64 || PPC || SPARC || X86
98512 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
98513 + select PAX_USERCOPY_SLABS
98514 + help
98515 + By saying Y here the kernel will enforce the size of heap objects
98516 + when they are copied in either direction between the kernel and
98517 + userland, even if only a part of the heap object is copied.
98518 +
98519 + Specifically, this checking prevents information leaking from the
98520 + kernel heap during kernel to userland copies (if the kernel heap
98521 + object is otherwise fully initialized) and prevents kernel heap
98522 + overflows during userland to kernel copies.
98523 +
98524 + Note that the current implementation provides the strictest bounds
98525 + checks for the SLUB allocator.
98526 +
98527 + Enabling this option also enables per-slab cache protection against
98528 + data in a given cache being copied into/out of via userland
98529 + accessors. Though the whitelist of regions will be reduced over
98530 + time, it notably protects important data structures like task structs.
98531 +
98532 + If frame pointers are enabled on x86, this option will also restrict
98533 + copies into and out of the kernel stack to local variables within a
98534 + single frame.
98535 +
98536 + Since this has a negligible performance impact, you should enable
98537 + this feature.
98538 +
98539 +config PAX_USERCOPY_DEBUG
98540 + bool
98541 + depends on X86 && PAX_USERCOPY
98542 + default n
98543 +
98544 +config PAX_SIZE_OVERFLOW
98545 + bool "Prevent various integer overflows in function size parameters"
98546 + default y if GRKERNSEC_CONFIG_AUTO
98547 + depends on X86
98548 + help
98549 + By saying Y here the kernel recomputes expressions of function
98550 + arguments marked by a size_overflow attribute with double integer
98551 + precision (DImode/TImode for 32/64 bit integer types).
98552 +
98553 + The recomputed argument is checked against TYPE_MAX and an event
98554 + is logged on overflow and the triggering process is killed.
98555 +
98556 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
98557 +
98558 + Note that the implementation requires a gcc with plugin support,
98559 + i.e., gcc 4.5 or newer. You may need to install the supporting
98560 + headers explicitly in addition to the normal gcc package.
98561 +
98562 +config PAX_LATENT_ENTROPY
98563 + bool "Generate some entropy during boot and runtime"
98564 + default y if GRKERNSEC_CONFIG_AUTO
98565 + help
98566 + By saying Y here the kernel will instrument some kernel code to
98567 + extract some entropy from both original and artificially created
98568 + program state. This will help especially embedded systems where
98569 + there is little 'natural' source of entropy normally. The cost
98570 + is some slowdown of the boot process and fork and irq processing.
98571 +
98572 + When pax_extra_latent_entropy is passed on the kernel command line,
98573 + entropy will be extracted from up to the first 4GB of RAM while the
98574 + runtime memory allocator is being initialized. This costs even more
98575 + slowdown of the boot process.
98576 +
98577 + Note that the implementation requires a gcc with plugin support,
98578 + i.e., gcc 4.5 or newer. You may need to install the supporting
98579 + headers explicitly in addition to the normal gcc package.
98580 +
98581 + Note that entropy extracted this way is not cryptographically
98582 + secure!
98583 +
98584 +endmenu
98585 +
98586 +endmenu
98587 +
98588 +source grsecurity/Kconfig
98589 +
98590 +endmenu
98591 +
98592 +endmenu
98593 +
98594 source security/keys/Kconfig
98595
98596 config SECURITY_DMESG_RESTRICT
98597 @@ -103,7 +1056,7 @@ config INTEL_TXT
98598 config LSM_MMAP_MIN_ADDR
98599 int "Low address space for LSM to protect from user allocation"
98600 depends on SECURITY && SECURITY_SELINUX
98601 - default 32768 if ARM
98602 + default 32768 if ALPHA || ARM || PARISC || SPARC32
98603 default 65536
98604 help
98605 This is the portion of low virtual memory which should be protected
98606 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
98607 index 9b9013b..51ebf96 100644
98608 --- a/security/apparmor/Kconfig
98609 +++ b/security/apparmor/Kconfig
98610 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
98611 boot.
98612
98613 If you are unsure how to answer this question, answer 1.
98614 +
98615 +config SECURITY_APPARMOR_COMPAT_24
98616 + bool "Enable AppArmor 2.4 compatability"
98617 + depends on SECURITY_APPARMOR
98618 + default y
98619 + help
98620 + This option enables compatability with AppArmor 2.4. It is
98621 + recommended if compatability with older versions of AppArmor
98622 + is desired.
98623 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
98624 index 16c15ec..42b7c9f 100644
98625 --- a/security/apparmor/apparmorfs.c
98626 +++ b/security/apparmor/apparmorfs.c
98627 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
98628 .release = single_release,
98629 };
98630
98631 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98632 +/**
98633 + * __next_namespace - find the next namespace to list
98634 + * @root: root namespace to stop search at (NOT NULL)
98635 + * @ns: current ns position (NOT NULL)
98636 + *
98637 + * Find the next namespace from @ns under @root and handle all locking needed
98638 + * while switching current namespace.
98639 + *
98640 + * Returns: next namespace or NULL if at last namespace under @root
98641 + * NOTE: will not unlock root->lock
98642 + */
98643 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
98644 + struct aa_namespace *ns)
98645 +{
98646 + struct aa_namespace *parent;
98647 +
98648 + /* is next namespace a child */
98649 + if (!list_empty(&ns->sub_ns)) {
98650 + struct aa_namespace *next;
98651 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
98652 + read_lock(&next->lock);
98653 + return next;
98654 + }
98655 +
98656 + /* check if the next ns is a sibling, parent, gp, .. */
98657 + parent = ns->parent;
98658 + while (parent) {
98659 + read_unlock(&ns->lock);
98660 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
98661 + read_lock(&ns->lock);
98662 + return ns;
98663 + }
98664 + if (parent == root)
98665 + return NULL;
98666 + ns = parent;
98667 + parent = parent->parent;
98668 + }
98669 +
98670 + return NULL;
98671 +}
98672 +
98673 +/**
98674 + * __first_profile - find the first profile in a namespace
98675 + * @root: namespace that is root of profiles being displayed (NOT NULL)
98676 + * @ns: namespace to start in (NOT NULL)
98677 + *
98678 + * Returns: unrefcounted profile or NULL if no profile
98679 + */
98680 +static struct aa_profile *__first_profile(struct aa_namespace *root,
98681 + struct aa_namespace *ns)
98682 +{
98683 + for ( ; ns; ns = __next_namespace(root, ns)) {
98684 + if (!list_empty(&ns->base.profiles))
98685 + return list_first_entry(&ns->base.profiles,
98686 + struct aa_profile, base.list);
98687 + }
98688 + return NULL;
98689 +}
98690 +
98691 +/**
98692 + * __next_profile - step to the next profile in a profile tree
98693 + * @profile: current profile in tree (NOT NULL)
98694 + *
98695 + * Perform a depth first taversal on the profile tree in a namespace
98696 + *
98697 + * Returns: next profile or NULL if done
98698 + * Requires: profile->ns.lock to be held
98699 + */
98700 +static struct aa_profile *__next_profile(struct aa_profile *p)
98701 +{
98702 + struct aa_profile *parent;
98703 + struct aa_namespace *ns = p->ns;
98704 +
98705 + /* is next profile a child */
98706 + if (!list_empty(&p->base.profiles))
98707 + return list_first_entry(&p->base.profiles, typeof(*p),
98708 + base.list);
98709 +
98710 + /* is next profile a sibling, parent sibling, gp, subling, .. */
98711 + parent = p->parent;
98712 + while (parent) {
98713 + list_for_each_entry_continue(p, &parent->base.profiles,
98714 + base.list)
98715 + return p;
98716 + p = parent;
98717 + parent = parent->parent;
98718 + }
98719 +
98720 + /* is next another profile in the namespace */
98721 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
98722 + return p;
98723 +
98724 + return NULL;
98725 +}
98726 +
98727 +/**
98728 + * next_profile - step to the next profile in where ever it may be
98729 + * @root: root namespace (NOT NULL)
98730 + * @profile: current profile (NOT NULL)
98731 + *
98732 + * Returns: next profile or NULL if there isn't one
98733 + */
98734 +static struct aa_profile *next_profile(struct aa_namespace *root,
98735 + struct aa_profile *profile)
98736 +{
98737 + struct aa_profile *next = __next_profile(profile);
98738 + if (next)
98739 + return next;
98740 +
98741 + /* finished all profiles in namespace move to next namespace */
98742 + return __first_profile(root, __next_namespace(root, profile->ns));
98743 +}
98744 +
98745 +/**
98746 + * p_start - start a depth first traversal of profile tree
98747 + * @f: seq_file to fill
98748 + * @pos: current position
98749 + *
98750 + * Returns: first profile under current namespace or NULL if none found
98751 + *
98752 + * acquires first ns->lock
98753 + */
98754 +static void *p_start(struct seq_file *f, loff_t *pos)
98755 + __acquires(root->lock)
98756 +{
98757 + struct aa_profile *profile = NULL;
98758 + struct aa_namespace *root = aa_current_profile()->ns;
98759 + loff_t l = *pos;
98760 + f->private = aa_get_namespace(root);
98761 +
98762 +
98763 + /* find the first profile */
98764 + read_lock(&root->lock);
98765 + profile = __first_profile(root, root);
98766 +
98767 + /* skip to position */
98768 + for (; profile && l > 0; l--)
98769 + profile = next_profile(root, profile);
98770 +
98771 + return profile;
98772 +}
98773 +
98774 +/**
98775 + * p_next - read the next profile entry
98776 + * @f: seq_file to fill
98777 + * @p: profile previously returned
98778 + * @pos: current position
98779 + *
98780 + * Returns: next profile after @p or NULL if none
98781 + *
98782 + * may acquire/release locks in namespace tree as necessary
98783 + */
98784 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
98785 +{
98786 + struct aa_profile *profile = p;
98787 + struct aa_namespace *root = f->private;
98788 + (*pos)++;
98789 +
98790 + return next_profile(root, profile);
98791 +}
98792 +
98793 +/**
98794 + * p_stop - stop depth first traversal
98795 + * @f: seq_file we are filling
98796 + * @p: the last profile writen
98797 + *
98798 + * Release all locking done by p_start/p_next on namespace tree
98799 + */
98800 +static void p_stop(struct seq_file *f, void *p)
98801 + __releases(root->lock)
98802 +{
98803 + struct aa_profile *profile = p;
98804 + struct aa_namespace *root = f->private, *ns;
98805 +
98806 + if (profile) {
98807 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
98808 + read_unlock(&ns->lock);
98809 + }
98810 + read_unlock(&root->lock);
98811 + aa_put_namespace(root);
98812 +}
98813 +
98814 +/**
98815 + * seq_show_profile - show a profile entry
98816 + * @f: seq_file to file
98817 + * @p: current position (profile) (NOT NULL)
98818 + *
98819 + * Returns: error on failure
98820 + */
98821 +static int seq_show_profile(struct seq_file *f, void *p)
98822 +{
98823 + struct aa_profile *profile = (struct aa_profile *)p;
98824 + struct aa_namespace *root = f->private;
98825 +
98826 + if (profile->ns != root)
98827 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
98828 + seq_printf(f, "%s (%s)\n", profile->base.hname,
98829 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
98830 +
98831 + return 0;
98832 +}
98833 +
98834 +static const struct seq_operations aa_fs_profiles_op = {
98835 + .start = p_start,
98836 + .next = p_next,
98837 + .stop = p_stop,
98838 + .show = seq_show_profile,
98839 +};
98840 +
98841 +static int profiles_open(struct inode *inode, struct file *file)
98842 +{
98843 + return seq_open(file, &aa_fs_profiles_op);
98844 +}
98845 +
98846 +static int profiles_release(struct inode *inode, struct file *file)
98847 +{
98848 + return seq_release(inode, file);
98849 +}
98850 +
98851 +const struct file_operations aa_fs_profiles_fops = {
98852 + .open = profiles_open,
98853 + .read = seq_read,
98854 + .llseek = seq_lseek,
98855 + .release = profiles_release,
98856 +};
98857 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
98858 +
98859 /** Base file system setup **/
98860
98861 static struct aa_fs_entry aa_fs_entry_file[] = {
98862 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
98863 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
98864 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
98865 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
98866 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
98867 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
98868 +#endif
98869 AA_FS_DIR("features", aa_fs_entry_features),
98870 { }
98871 };
98872 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
98873 index 2e2a0dd..a0cbc44 100644
98874 --- a/security/apparmor/lsm.c
98875 +++ b/security/apparmor/lsm.c
98876 @@ -613,7 +613,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
98877 return error;
98878 }
98879
98880 -static struct security_operations apparmor_ops = {
98881 +static struct security_operations apparmor_ops __read_only = {
98882 .name = "apparmor",
98883
98884 .ptrace_access_check = apparmor_ptrace_access_check,
98885 diff --git a/security/commoncap.c b/security/commoncap.c
98886 index c44b6fe..932df30 100644
98887 --- a/security/commoncap.c
98888 +++ b/security/commoncap.c
98889 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
98890 return 0;
98891 }
98892
98893 +/* returns:
98894 + 1 for suid privilege
98895 + 2 for sgid privilege
98896 + 3 for fscap privilege
98897 +*/
98898 +int is_privileged_binary(const struct dentry *dentry)
98899 +{
98900 + struct cpu_vfs_cap_data capdata;
98901 + struct inode *inode = dentry->d_inode;
98902 +
98903 + if (!inode || S_ISDIR(inode->i_mode))
98904 + return 0;
98905 +
98906 + if (inode->i_mode & S_ISUID)
98907 + return 1;
98908 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
98909 + return 2;
98910 +
98911 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
98912 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
98913 + return 3;
98914 + }
98915 +
98916 + return 0;
98917 +}
98918 +
98919 /*
98920 * Attempt to get the on-exec apply capability sets for an executable file from
98921 * its xattrs and, if present, apply them to the proposed credentials being
98922 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
98923 const struct cred *cred = current_cred();
98924 kuid_t root_uid = make_kuid(cred->user_ns, 0);
98925
98926 + if (gr_acl_enable_at_secure())
98927 + return 1;
98928 +
98929 if (!uid_eq(cred->uid, root_uid)) {
98930 if (bprm->cap_effective)
98931 return 1;
98932 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
98933 index b3dd616..4bb17f3 100644
98934 --- a/security/integrity/ima/ima.h
98935 +++ b/security/integrity/ima/ima.h
98936 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
98937 extern spinlock_t ima_queue_lock;
98938
98939 struct ima_h_table {
98940 - atomic_long_t len; /* number of stored measurements in the list */
98941 - atomic_long_t violations;
98942 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
98943 + atomic_long_unchecked_t violations;
98944 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
98945 };
98946 extern struct ima_h_table ima_htable;
98947 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
98948 index 1c03e8f1..398a941 100644
98949 --- a/security/integrity/ima/ima_api.c
98950 +++ b/security/integrity/ima/ima_api.c
98951 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
98952 int result;
98953
98954 /* can overflow, only indicator */
98955 - atomic_long_inc(&ima_htable.violations);
98956 + atomic_long_inc_unchecked(&ima_htable.violations);
98957
98958 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
98959 if (!entry) {
98960 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
98961 index 38477c9..87a60c7 100644
98962 --- a/security/integrity/ima/ima_fs.c
98963 +++ b/security/integrity/ima/ima_fs.c
98964 @@ -28,12 +28,12 @@
98965 static int valid_policy = 1;
98966 #define TMPBUFLEN 12
98967 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
98968 - loff_t *ppos, atomic_long_t *val)
98969 + loff_t *ppos, atomic_long_unchecked_t *val)
98970 {
98971 char tmpbuf[TMPBUFLEN];
98972 ssize_t len;
98973
98974 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
98975 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
98976 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
98977 }
98978
98979 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
98980 index ff63fe0..809cd96 100644
98981 --- a/security/integrity/ima/ima_queue.c
98982 +++ b/security/integrity/ima/ima_queue.c
98983 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
98984 INIT_LIST_HEAD(&qe->later);
98985 list_add_tail_rcu(&qe->later, &ima_measurements);
98986
98987 - atomic_long_inc(&ima_htable.len);
98988 + atomic_long_inc_unchecked(&ima_htable.len);
98989 key = ima_hash_key(entry->digest);
98990 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
98991 return 0;
98992 diff --git a/security/keys/compat.c b/security/keys/compat.c
98993 index d65fa7f..cbfe366 100644
98994 --- a/security/keys/compat.c
98995 +++ b/security/keys/compat.c
98996 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
98997 if (ret == 0)
98998 goto no_payload_free;
98999
99000 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99001 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99002 err:
99003 if (iov != iovstack)
99004 kfree(iov);
99005 diff --git a/security/keys/internal.h b/security/keys/internal.h
99006 index d4f1468..cc52f92 100644
99007 --- a/security/keys/internal.h
99008 +++ b/security/keys/internal.h
99009 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
99010 extern long keyctl_invalidate_key(key_serial_t);
99011
99012 extern long keyctl_instantiate_key_common(key_serial_t,
99013 - const struct iovec *,
99014 + const struct iovec __user *,
99015 unsigned, size_t, key_serial_t);
99016
99017 /*
99018 diff --git a/security/keys/key.c b/security/keys/key.c
99019 index 8fb7c7b..ba3610d 100644
99020 --- a/security/keys/key.c
99021 +++ b/security/keys/key.c
99022 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
99023
99024 atomic_set(&key->usage, 1);
99025 init_rwsem(&key->sem);
99026 - lockdep_set_class(&key->sem, &type->lock_class);
99027 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
99028 key->type = type;
99029 key->user = user;
99030 key->quotalen = quotalen;
99031 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
99032 struct key_type *p;
99033 int ret;
99034
99035 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
99036 + pax_open_kernel();
99037 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
99038 + pax_close_kernel();
99039
99040 ret = -EEXIST;
99041 down_write(&key_types_sem);
99042 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
99043 }
99044
99045 /* store the type */
99046 - list_add(&ktype->link, &key_types_list);
99047 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
99048
99049 pr_notice("Key type %s registered\n", ktype->name);
99050 ret = 0;
99051 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
99052 void unregister_key_type(struct key_type *ktype)
99053 {
99054 down_write(&key_types_sem);
99055 - list_del_init(&ktype->link);
99056 + pax_list_del_init((struct list_head *)&ktype->link);
99057 downgrade_write(&key_types_sem);
99058 key_gc_keytype(ktype);
99059 pr_notice("Key type %s unregistered\n", ktype->name);
99060 @@ -1084,10 +1086,10 @@ void __init key_init(void)
99061 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
99062
99063 /* add the special key types */
99064 - list_add_tail(&key_type_keyring.link, &key_types_list);
99065 - list_add_tail(&key_type_dead.link, &key_types_list);
99066 - list_add_tail(&key_type_user.link, &key_types_list);
99067 - list_add_tail(&key_type_logon.link, &key_types_list);
99068 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
99069 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
99070 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
99071 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
99072
99073 /* record the root user tracking */
99074 rb_link_node(&root_key_user.node,
99075 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
99076 index 33cfd27..842fc5a 100644
99077 --- a/security/keys/keyctl.c
99078 +++ b/security/keys/keyctl.c
99079 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
99080 /*
99081 * Copy the iovec data from userspace
99082 */
99083 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99084 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
99085 unsigned ioc)
99086 {
99087 for (; ioc > 0; ioc--) {
99088 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
99089 * If successful, 0 will be returned.
99090 */
99091 long keyctl_instantiate_key_common(key_serial_t id,
99092 - const struct iovec *payload_iov,
99093 + const struct iovec __user *payload_iov,
99094 unsigned ioc,
99095 size_t plen,
99096 key_serial_t ringid)
99097 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
99098 [0].iov_len = plen
99099 };
99100
99101 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
99102 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
99103 }
99104
99105 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
99106 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
99107 if (ret == 0)
99108 goto no_payload_free;
99109
99110 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
99111 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
99112 err:
99113 if (iov != iovstack)
99114 kfree(iov);
99115 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
99116 index 6ece7f2..ecdb55c 100644
99117 --- a/security/keys/keyring.c
99118 +++ b/security/keys/keyring.c
99119 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
99120 ret = -EFAULT;
99121
99122 for (loop = 0; loop < klist->nkeys; loop++) {
99123 + key_serial_t serial;
99124 key = rcu_deref_link_locked(klist, loop,
99125 keyring);
99126 + serial = key->serial;
99127
99128 tmp = sizeof(key_serial_t);
99129 if (tmp > buflen)
99130 tmp = buflen;
99131
99132 - if (copy_to_user(buffer,
99133 - &key->serial,
99134 - tmp) != 0)
99135 + if (copy_to_user(buffer, &serial, tmp))
99136 goto error;
99137
99138 buflen -= tmp;
99139 diff --git a/security/min_addr.c b/security/min_addr.c
99140 index f728728..6457a0c 100644
99141 --- a/security/min_addr.c
99142 +++ b/security/min_addr.c
99143 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
99144 */
99145 static void update_mmap_min_addr(void)
99146 {
99147 +#ifndef SPARC
99148 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
99149 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
99150 mmap_min_addr = dac_mmap_min_addr;
99151 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
99152 #else
99153 mmap_min_addr = dac_mmap_min_addr;
99154 #endif
99155 +#endif
99156 }
99157
99158 /*
99159 diff --git a/security/security.c b/security/security.c
99160 index 94b35ae..f4e7751 100644
99161 --- a/security/security.c
99162 +++ b/security/security.c
99163 @@ -33,8 +33,8 @@
99164 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
99165 CONFIG_DEFAULT_SECURITY;
99166
99167 -static struct security_operations *security_ops;
99168 -static struct security_operations default_security_ops = {
99169 +struct security_operations *security_ops __read_only;
99170 +struct security_operations default_security_ops __read_only = {
99171 .name = "default",
99172 };
99173
99174 @@ -73,11 +73,6 @@ int __init security_init(void)
99175 return 0;
99176 }
99177
99178 -void reset_security_ops(void)
99179 -{
99180 - security_ops = &default_security_ops;
99181 -}
99182 -
99183 /* Save user chosen LSM */
99184 static int __init choose_lsm(char *str)
99185 {
99186 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
99187 index dad36a6..7e5ffbf 100644
99188 --- a/security/selinux/avc.c
99189 +++ b/security/selinux/avc.c
99190 @@ -59,7 +59,7 @@ struct avc_node {
99191 struct avc_cache {
99192 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
99193 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
99194 - atomic_t lru_hint; /* LRU hint for reclaim scan */
99195 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
99196 atomic_t active_nodes;
99197 u32 latest_notif; /* latest revocation notification */
99198 };
99199 @@ -167,7 +167,7 @@ void __init avc_init(void)
99200 spin_lock_init(&avc_cache.slots_lock[i]);
99201 }
99202 atomic_set(&avc_cache.active_nodes, 0);
99203 - atomic_set(&avc_cache.lru_hint, 0);
99204 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
99205
99206 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
99207 0, SLAB_PANIC, NULL);
99208 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
99209 spinlock_t *lock;
99210
99211 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
99212 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99213 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
99214 head = &avc_cache.slots[hvalue];
99215 lock = &avc_cache.slots_lock[hvalue];
99216
99217 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
99218 index c956390..1899f06 100644
99219 --- a/security/selinux/hooks.c
99220 +++ b/security/selinux/hooks.c
99221 @@ -97,8 +97,6 @@
99222
99223 #define NUM_SEL_MNT_OPTS 5
99224
99225 -extern struct security_operations *security_ops;
99226 -
99227 /* SECMARK reference count */
99228 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
99229
99230 @@ -5609,7 +5607,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
99231
99232 #endif
99233
99234 -static struct security_operations selinux_ops = {
99235 +static struct security_operations selinux_ops __read_only = {
99236 .name = "selinux",
99237
99238 .ptrace_access_check = selinux_ptrace_access_check,
99239 @@ -5961,6 +5959,9 @@ static void selinux_nf_ip_exit(void)
99240 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
99241 static int selinux_disabled;
99242
99243 +extern struct security_operations *security_ops;
99244 +extern struct security_operations default_security_ops;
99245 +
99246 int selinux_disable(void)
99247 {
99248 if (ss_initialized) {
99249 @@ -5978,7 +5979,9 @@ int selinux_disable(void)
99250 selinux_disabled = 1;
99251 selinux_enabled = 0;
99252
99253 - reset_security_ops();
99254 + pax_open_kernel();
99255 + security_ops = &default_security_ops;
99256 + pax_close_kernel();
99257
99258 /* Try to destroy the avc node cache */
99259 avc_disable();
99260 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
99261 index 65f67cb..3f141ef 100644
99262 --- a/security/selinux/include/xfrm.h
99263 +++ b/security/selinux/include/xfrm.h
99264 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
99265
99266 static inline void selinux_xfrm_notify_policyload(void)
99267 {
99268 - atomic_inc(&flow_cache_genid);
99269 + atomic_inc_unchecked(&flow_cache_genid);
99270 rt_genid_bump(&init_net);
99271 }
99272 #else
99273 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
99274 index eefbd10..9f10ddb 100644
99275 --- a/security/smack/smack_lsm.c
99276 +++ b/security/smack/smack_lsm.c
99277 @@ -3711,7 +3711,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
99278 return 0;
99279 }
99280
99281 -struct security_operations smack_ops = {
99282 +struct security_operations smack_ops __read_only = {
99283 .name = "smack",
99284
99285 .ptrace_access_check = smack_ptrace_access_check,
99286 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
99287 index 390c646..f2f8db3 100644
99288 --- a/security/tomoyo/mount.c
99289 +++ b/security/tomoyo/mount.c
99290 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
99291 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
99292 need_dev = -1; /* dev_name is a directory */
99293 } else {
99294 + if (!capable(CAP_SYS_ADMIN)) {
99295 + error = -EPERM;
99296 + goto out;
99297 + }
99298 fstype = get_fs_type(type);
99299 if (!fstype) {
99300 error = -ENODEV;
99301 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
99302 index f0b756e..b129202 100644
99303 --- a/security/tomoyo/tomoyo.c
99304 +++ b/security/tomoyo/tomoyo.c
99305 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
99306 * tomoyo_security_ops is a "struct security_operations" which is used for
99307 * registering TOMOYO.
99308 */
99309 -static struct security_operations tomoyo_security_ops = {
99310 +static struct security_operations tomoyo_security_ops __read_only = {
99311 .name = "tomoyo",
99312 .cred_alloc_blank = tomoyo_cred_alloc_blank,
99313 .cred_prepare = tomoyo_cred_prepare,
99314 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
99315 index 20ef514..4182bed 100644
99316 --- a/security/yama/Kconfig
99317 +++ b/security/yama/Kconfig
99318 @@ -1,6 +1,6 @@
99319 config SECURITY_YAMA
99320 bool "Yama support"
99321 - depends on SECURITY
99322 + depends on SECURITY && !GRKERNSEC
99323 select SECURITYFS
99324 select SECURITY_PATH
99325 default n
99326 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
99327 index 13c88fbc..f8c115e 100644
99328 --- a/security/yama/yama_lsm.c
99329 +++ b/security/yama/yama_lsm.c
99330 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
99331 }
99332
99333 #ifndef CONFIG_SECURITY_YAMA_STACKED
99334 -static struct security_operations yama_ops = {
99335 +static struct security_operations yama_ops __read_only = {
99336 .name = "yama",
99337
99338 .ptrace_access_check = yama_ptrace_access_check,
99339 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
99340 #endif
99341
99342 #ifdef CONFIG_SYSCTL
99343 +static int zero __read_only;
99344 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
99345 +
99346 static int yama_dointvec_minmax(struct ctl_table *table, int write,
99347 void __user *buffer, size_t *lenp, loff_t *ppos)
99348 {
99349 - int rc;
99350 + ctl_table_no_const yama_table;
99351
99352 if (write && !capable(CAP_SYS_PTRACE))
99353 return -EPERM;
99354
99355 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
99356 - if (rc)
99357 - return rc;
99358 -
99359 + yama_table = *table;
99360 /* Lock the max value if it ever gets set. */
99361 - if (write && *(int *)table->data == *(int *)table->extra2)
99362 - table->extra1 = table->extra2;
99363 -
99364 - return rc;
99365 + if (ptrace_scope == max_scope)
99366 + yama_table.extra1 = &max_scope;
99367 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
99368 }
99369
99370 -static int zero;
99371 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
99372 -
99373 struct ctl_path yama_sysctl_path[] = {
99374 { .procname = "kernel", },
99375 { .procname = "yama", },
99376 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
99377 index 4cedc69..e59d8a3 100644
99378 --- a/sound/aoa/codecs/onyx.c
99379 +++ b/sound/aoa/codecs/onyx.c
99380 @@ -54,7 +54,7 @@ struct onyx {
99381 spdif_locked:1,
99382 analog_locked:1,
99383 original_mute:2;
99384 - int open_count;
99385 + local_t open_count;
99386 struct codec_info *codec_info;
99387
99388 /* mutex serializes concurrent access to the device
99389 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
99390 struct onyx *onyx = cii->codec_data;
99391
99392 mutex_lock(&onyx->mutex);
99393 - onyx->open_count++;
99394 + local_inc(&onyx->open_count);
99395 mutex_unlock(&onyx->mutex);
99396
99397 return 0;
99398 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
99399 struct onyx *onyx = cii->codec_data;
99400
99401 mutex_lock(&onyx->mutex);
99402 - onyx->open_count--;
99403 - if (!onyx->open_count)
99404 + if (local_dec_and_test(&onyx->open_count))
99405 onyx->spdif_locked = onyx->analog_locked = 0;
99406 mutex_unlock(&onyx->mutex);
99407
99408 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
99409 index ffd2025..df062c9 100644
99410 --- a/sound/aoa/codecs/onyx.h
99411 +++ b/sound/aoa/codecs/onyx.h
99412 @@ -11,6 +11,7 @@
99413 #include <linux/i2c.h>
99414 #include <asm/pmac_low_i2c.h>
99415 #include <asm/prom.h>
99416 +#include <asm/local.h>
99417
99418 /* PCM3052 register definitions */
99419
99420 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
99421 index 4c1cc51..16040040 100644
99422 --- a/sound/core/oss/pcm_oss.c
99423 +++ b/sound/core/oss/pcm_oss.c
99424 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
99425 if (in_kernel) {
99426 mm_segment_t fs;
99427 fs = snd_enter_user();
99428 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99429 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99430 snd_leave_user(fs);
99431 } else {
99432 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
99433 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
99434 }
99435 if (ret != -EPIPE && ret != -ESTRPIPE)
99436 break;
99437 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
99438 if (in_kernel) {
99439 mm_segment_t fs;
99440 fs = snd_enter_user();
99441 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99442 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99443 snd_leave_user(fs);
99444 } else {
99445 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
99446 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
99447 }
99448 if (ret == -EPIPE) {
99449 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
99450 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
99451 struct snd_pcm_plugin_channel *channels;
99452 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
99453 if (!in_kernel) {
99454 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
99455 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
99456 return -EFAULT;
99457 buf = runtime->oss.buffer;
99458 }
99459 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
99460 }
99461 } else {
99462 tmp = snd_pcm_oss_write2(substream,
99463 - (const char __force *)buf,
99464 + (const char __force_kernel *)buf,
99465 runtime->oss.period_bytes, 0);
99466 if (tmp <= 0)
99467 goto err;
99468 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
99469 struct snd_pcm_runtime *runtime = substream->runtime;
99470 snd_pcm_sframes_t frames, frames1;
99471 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
99472 - char __user *final_dst = (char __force __user *)buf;
99473 + char __user *final_dst = (char __force_user *)buf;
99474 if (runtime->oss.plugin_first) {
99475 struct snd_pcm_plugin_channel *channels;
99476 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
99477 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
99478 xfer += tmp;
99479 runtime->oss.buffer_used -= tmp;
99480 } else {
99481 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
99482 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
99483 runtime->oss.period_bytes, 0);
99484 if (tmp <= 0)
99485 goto err;
99486 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
99487 size1);
99488 size1 /= runtime->channels; /* frames */
99489 fs = snd_enter_user();
99490 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
99491 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
99492 snd_leave_user(fs);
99493 }
99494 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
99495 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
99496 index af49721..e85058e 100644
99497 --- a/sound/core/pcm_compat.c
99498 +++ b/sound/core/pcm_compat.c
99499 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
99500 int err;
99501
99502 fs = snd_enter_user();
99503 - err = snd_pcm_delay(substream, &delay);
99504 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
99505 snd_leave_user(fs);
99506 if (err < 0)
99507 return err;
99508 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
99509 index a68d4c6..72af3cf 100644
99510 --- a/sound/core/pcm_native.c
99511 +++ b/sound/core/pcm_native.c
99512 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
99513 switch (substream->stream) {
99514 case SNDRV_PCM_STREAM_PLAYBACK:
99515 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
99516 - (void __user *)arg);
99517 + (void __force_user *)arg);
99518 break;
99519 case SNDRV_PCM_STREAM_CAPTURE:
99520 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
99521 - (void __user *)arg);
99522 + (void __force_user *)arg);
99523 break;
99524 default:
99525 result = -EINVAL;
99526 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
99527 index 040c60e..989a19a 100644
99528 --- a/sound/core/seq/seq_device.c
99529 +++ b/sound/core/seq/seq_device.c
99530 @@ -64,7 +64,7 @@ struct ops_list {
99531 int argsize; /* argument size */
99532
99533 /* operators */
99534 - struct snd_seq_dev_ops ops;
99535 + struct snd_seq_dev_ops *ops;
99536
99537 /* registered devices */
99538 struct list_head dev_list; /* list of devices */
99539 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
99540
99541 mutex_lock(&ops->reg_mutex);
99542 /* copy driver operators */
99543 - ops->ops = *entry;
99544 + ops->ops = entry;
99545 ops->driver |= DRIVER_LOADED;
99546 ops->argsize = argsize;
99547
99548 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
99549 dev->name, ops->id, ops->argsize, dev->argsize);
99550 return -EINVAL;
99551 }
99552 - if (ops->ops.init_device(dev) >= 0) {
99553 + if (ops->ops->init_device(dev) >= 0) {
99554 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
99555 ops->num_init_devices++;
99556 } else {
99557 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
99558 dev->name, ops->id, ops->argsize, dev->argsize);
99559 return -EINVAL;
99560 }
99561 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
99562 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
99563 dev->status = SNDRV_SEQ_DEVICE_FREE;
99564 dev->driver_data = NULL;
99565 ops->num_init_devices--;
99566 diff --git a/sound/core/sound.c b/sound/core/sound.c
99567 index f002bd9..c462985 100644
99568 --- a/sound/core/sound.c
99569 +++ b/sound/core/sound.c
99570 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
99571 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
99572 default: return;
99573 }
99574 - request_module(str);
99575 + request_module("%s", str);
99576 }
99577
99578 #endif /* modular kernel */
99579 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
99580 index 4e0dd22..7a1f32c 100644
99581 --- a/sound/drivers/mts64.c
99582 +++ b/sound/drivers/mts64.c
99583 @@ -29,6 +29,7 @@
99584 #include <sound/initval.h>
99585 #include <sound/rawmidi.h>
99586 #include <sound/control.h>
99587 +#include <asm/local.h>
99588
99589 #define CARD_NAME "Miditerminal 4140"
99590 #define DRIVER_NAME "MTS64"
99591 @@ -67,7 +68,7 @@ struct mts64 {
99592 struct pardevice *pardev;
99593 int pardev_claimed;
99594
99595 - int open_count;
99596 + local_t open_count;
99597 int current_midi_output_port;
99598 int current_midi_input_port;
99599 u8 mode[MTS64_NUM_INPUT_PORTS];
99600 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99601 {
99602 struct mts64 *mts = substream->rmidi->private_data;
99603
99604 - if (mts->open_count == 0) {
99605 + if (local_read(&mts->open_count) == 0) {
99606 /* We don't need a spinlock here, because this is just called
99607 if the device has not been opened before.
99608 So there aren't any IRQs from the device */
99609 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
99610
99611 msleep(50);
99612 }
99613 - ++(mts->open_count);
99614 + local_inc(&mts->open_count);
99615
99616 return 0;
99617 }
99618 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99619 struct mts64 *mts = substream->rmidi->private_data;
99620 unsigned long flags;
99621
99622 - --(mts->open_count);
99623 - if (mts->open_count == 0) {
99624 + if (local_dec_return(&mts->open_count) == 0) {
99625 /* We need the spinlock_irqsave here because we can still
99626 have IRQs at this point */
99627 spin_lock_irqsave(&mts->lock, flags);
99628 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
99629
99630 msleep(500);
99631
99632 - } else if (mts->open_count < 0)
99633 - mts->open_count = 0;
99634 + } else if (local_read(&mts->open_count) < 0)
99635 + local_set(&mts->open_count, 0);
99636
99637 return 0;
99638 }
99639 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
99640 index b953fb4..1999c01 100644
99641 --- a/sound/drivers/opl4/opl4_lib.c
99642 +++ b/sound/drivers/opl4/opl4_lib.c
99643 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
99644 MODULE_DESCRIPTION("OPL4 driver");
99645 MODULE_LICENSE("GPL");
99646
99647 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
99648 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
99649 {
99650 int timeout = 10;
99651 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
99652 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
99653 index 991018d..8984740 100644
99654 --- a/sound/drivers/portman2x4.c
99655 +++ b/sound/drivers/portman2x4.c
99656 @@ -48,6 +48,7 @@
99657 #include <sound/initval.h>
99658 #include <sound/rawmidi.h>
99659 #include <sound/control.h>
99660 +#include <asm/local.h>
99661
99662 #define CARD_NAME "Portman 2x4"
99663 #define DRIVER_NAME "portman"
99664 @@ -85,7 +86,7 @@ struct portman {
99665 struct pardevice *pardev;
99666 int pardev_claimed;
99667
99668 - int open_count;
99669 + local_t open_count;
99670 int mode[PORTMAN_NUM_INPUT_PORTS];
99671 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
99672 };
99673 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
99674 index ea995af..f1bfa37 100644
99675 --- a/sound/firewire/amdtp.c
99676 +++ b/sound/firewire/amdtp.c
99677 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
99678 ptr = s->pcm_buffer_pointer + data_blocks;
99679 if (ptr >= pcm->runtime->buffer_size)
99680 ptr -= pcm->runtime->buffer_size;
99681 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
99682 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
99683
99684 s->pcm_period_pointer += data_blocks;
99685 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
99686 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
99687 */
99688 void amdtp_out_stream_update(struct amdtp_out_stream *s)
99689 {
99690 - ACCESS_ONCE(s->source_node_id_field) =
99691 + ACCESS_ONCE_RW(s->source_node_id_field) =
99692 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
99693 }
99694 EXPORT_SYMBOL(amdtp_out_stream_update);
99695 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
99696 index f6103d6..4843fbf 100644
99697 --- a/sound/firewire/amdtp.h
99698 +++ b/sound/firewire/amdtp.h
99699 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
99700 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
99701 struct snd_pcm_substream *pcm)
99702 {
99703 - ACCESS_ONCE(s->pcm) = pcm;
99704 + ACCESS_ONCE_RW(s->pcm) = pcm;
99705 }
99706
99707 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
99708 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
99709 index 58a5afe..af5bd64 100644
99710 --- a/sound/firewire/isight.c
99711 +++ b/sound/firewire/isight.c
99712 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
99713 ptr += count;
99714 if (ptr >= runtime->buffer_size)
99715 ptr -= runtime->buffer_size;
99716 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
99717 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
99718
99719 isight->period_counter += count;
99720 if (isight->period_counter >= runtime->period_size) {
99721 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
99722 if (err < 0)
99723 return err;
99724
99725 - ACCESS_ONCE(isight->pcm_active) = true;
99726 + ACCESS_ONCE_RW(isight->pcm_active) = true;
99727
99728 return 0;
99729 }
99730 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
99731 {
99732 struct isight *isight = substream->private_data;
99733
99734 - ACCESS_ONCE(isight->pcm_active) = false;
99735 + ACCESS_ONCE_RW(isight->pcm_active) = false;
99736
99737 mutex_lock(&isight->mutex);
99738 isight_stop_streaming(isight);
99739 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
99740
99741 switch (cmd) {
99742 case SNDRV_PCM_TRIGGER_START:
99743 - ACCESS_ONCE(isight->pcm_running) = true;
99744 + ACCESS_ONCE_RW(isight->pcm_running) = true;
99745 break;
99746 case SNDRV_PCM_TRIGGER_STOP:
99747 - ACCESS_ONCE(isight->pcm_running) = false;
99748 + ACCESS_ONCE_RW(isight->pcm_running) = false;
99749 break;
99750 default:
99751 return -EINVAL;
99752 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
99753 index 505fc81..62e569e 100644
99754 --- a/sound/firewire/scs1x.c
99755 +++ b/sound/firewire/scs1x.c
99756 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
99757 {
99758 struct scs *scs = stream->rmidi->private_data;
99759
99760 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
99761 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
99762 if (up) {
99763 scs->output_idle = false;
99764 tasklet_schedule(&scs->tasklet);
99765 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
99766 {
99767 struct scs *scs = stream->rmidi->private_data;
99768
99769 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
99770 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
99771 }
99772
99773 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
99774 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
99775
99776 snd_card_disconnect(scs->card);
99777
99778 - ACCESS_ONCE(scs->output) = NULL;
99779 - ACCESS_ONCE(scs->input) = NULL;
99780 + ACCESS_ONCE_RW(scs->output) = NULL;
99781 + ACCESS_ONCE_RW(scs->input) = NULL;
99782
99783 wait_event(scs->idle_wait, scs->output_idle);
99784
99785 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
99786 index 048439a..3be9f6f 100644
99787 --- a/sound/oss/sb_audio.c
99788 +++ b/sound/oss/sb_audio.c
99789 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
99790 buf16 = (signed short *)(localbuf + localoffs);
99791 while (c)
99792 {
99793 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99794 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
99795 if (copy_from_user(lbuf8,
99796 userbuf+useroffs + p,
99797 locallen))
99798 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
99799 index 7d8803a..559f8d0 100644
99800 --- a/sound/oss/swarm_cs4297a.c
99801 +++ b/sound/oss/swarm_cs4297a.c
99802 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
99803 {
99804 struct cs4297a_state *s;
99805 u32 pwr, id;
99806 - mm_segment_t fs;
99807 int rval;
99808 #ifndef CONFIG_BCM_CS4297A_CSWARM
99809 u64 cfg;
99810 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
99811 if (!rval) {
99812 char *sb1250_duart_present;
99813
99814 +#if 0
99815 + mm_segment_t fs;
99816 fs = get_fs();
99817 set_fs(KERNEL_DS);
99818 -#if 0
99819 val = SOUND_MASK_LINE;
99820 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
99821 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
99822 val = initvol[i].vol;
99823 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
99824 }
99825 + set_fs(fs);
99826 // cs4297a_write_ac97(s, 0x18, 0x0808);
99827 #else
99828 // cs4297a_write_ac97(s, 0x5e, 0x180);
99829 cs4297a_write_ac97(s, 0x02, 0x0808);
99830 cs4297a_write_ac97(s, 0x18, 0x0808);
99831 #endif
99832 - set_fs(fs);
99833
99834 list_add(&s->list, &cs4297a_devs);
99835
99836 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
99837 index 8a005f0..4fe3059 100644
99838 --- a/sound/pci/hda/hda_codec.c
99839 +++ b/sound/pci/hda/hda_codec.c
99840 @@ -918,14 +918,10 @@ find_codec_preset(struct hda_codec *codec)
99841 mutex_unlock(&preset_mutex);
99842
99843 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
99844 - char name[32];
99845 if (!mod_requested)
99846 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
99847 - codec->vendor_id);
99848 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
99849 else
99850 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
99851 - (codec->vendor_id >> 16) & 0xffff);
99852 - request_module(name);
99853 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
99854 mod_requested++;
99855 goto again;
99856 }
99857 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
99858 index 4631a23..001ae57 100644
99859 --- a/sound/pci/ymfpci/ymfpci.h
99860 +++ b/sound/pci/ymfpci/ymfpci.h
99861 @@ -358,7 +358,7 @@ struct snd_ymfpci {
99862 spinlock_t reg_lock;
99863 spinlock_t voice_lock;
99864 wait_queue_head_t interrupt_sleep;
99865 - atomic_t interrupt_sleep_count;
99866 + atomic_unchecked_t interrupt_sleep_count;
99867 struct snd_info_entry *proc_entry;
99868 const struct firmware *dsp_microcode;
99869 const struct firmware *controller_microcode;
99870 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
99871 index d591c15..8cb8f94 100644
99872 --- a/sound/pci/ymfpci/ymfpci_main.c
99873 +++ b/sound/pci/ymfpci/ymfpci_main.c
99874 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
99875 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
99876 break;
99877 }
99878 - if (atomic_read(&chip->interrupt_sleep_count)) {
99879 - atomic_set(&chip->interrupt_sleep_count, 0);
99880 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99881 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99882 wake_up(&chip->interrupt_sleep);
99883 }
99884 __end:
99885 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
99886 continue;
99887 init_waitqueue_entry(&wait, current);
99888 add_wait_queue(&chip->interrupt_sleep, &wait);
99889 - atomic_inc(&chip->interrupt_sleep_count);
99890 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
99891 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
99892 remove_wait_queue(&chip->interrupt_sleep, &wait);
99893 }
99894 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
99895 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
99896 spin_unlock(&chip->reg_lock);
99897
99898 - if (atomic_read(&chip->interrupt_sleep_count)) {
99899 - atomic_set(&chip->interrupt_sleep_count, 0);
99900 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
99901 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99902 wake_up(&chip->interrupt_sleep);
99903 }
99904 }
99905 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
99906 spin_lock_init(&chip->reg_lock);
99907 spin_lock_init(&chip->voice_lock);
99908 init_waitqueue_head(&chip->interrupt_sleep);
99909 - atomic_set(&chip->interrupt_sleep_count, 0);
99910 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
99911 chip->card = card;
99912 chip->pci = pci;
99913 chip->irq = -1;
99914 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
99915 index 2f2d837..3e3f1f6 100644
99916 --- a/sound/soc/fsl/fsl_ssi.c
99917 +++ b/sound/soc/fsl/fsl_ssi.c
99918 @@ -656,7 +656,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
99919 {
99920 struct fsl_ssi_private *ssi_private;
99921 int ret = 0;
99922 - struct device_attribute *dev_attr = NULL;
99923 + device_attribute_no_const *dev_attr = NULL;
99924 struct device_node *np = pdev->dev.of_node;
99925 const char *p, *sprop;
99926 const uint32_t *iprop;
99927 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
99928 new file mode 100644
99929 index 0000000..50f2f2f
99930 --- /dev/null
99931 +++ b/tools/gcc/.gitignore
99932 @@ -0,0 +1 @@
99933 +size_overflow_hash.h
99934 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
99935 new file mode 100644
99936 index 0000000..144dbee
99937 --- /dev/null
99938 +++ b/tools/gcc/Makefile
99939 @@ -0,0 +1,45 @@
99940 +#CC := gcc
99941 +#PLUGIN_SOURCE_FILES := pax_plugin.c
99942 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
99943 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
99944 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
99945 +
99946 +ifeq ($(PLUGINCC),$(HOSTCC))
99947 +HOSTLIBS := hostlibs
99948 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
99949 +else
99950 +HOSTLIBS := hostcxxlibs
99951 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
99952 +endif
99953 +
99954 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
99955 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
99956 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
99957 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
99958 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
99959 +$(HOSTLIBS)-y += colorize_plugin.so
99960 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
99961 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
99962 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
99963 +
99964 +always := $($(HOSTLIBS)-y)
99965 +
99966 +constify_plugin-objs := constify_plugin.o
99967 +stackleak_plugin-objs := stackleak_plugin.o
99968 +kallocstat_plugin-objs := kallocstat_plugin.o
99969 +kernexec_plugin-objs := kernexec_plugin.o
99970 +checker_plugin-objs := checker_plugin.o
99971 +colorize_plugin-objs := colorize_plugin.o
99972 +size_overflow_plugin-objs := size_overflow_plugin.o
99973 +latent_entropy_plugin-objs := latent_entropy_plugin.o
99974 +structleak_plugin-objs := structleak_plugin.o
99975 +
99976 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
99977 +
99978 +quiet_cmd_build_size_overflow_hash = GENHASH $@
99979 + cmd_build_size_overflow_hash = \
99980 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
99981 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
99982 + $(call if_changed,build_size_overflow_hash)
99983 +
99984 +targets += size_overflow_hash.h
99985 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
99986 new file mode 100644
99987 index 0000000..22f03c0
99988 --- /dev/null
99989 +++ b/tools/gcc/checker_plugin.c
99990 @@ -0,0 +1,172 @@
99991 +/*
99992 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
99993 + * Licensed under the GPL v2
99994 + *
99995 + * Note: the choice of the license means that the compilation process is
99996 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99997 + * but for the kernel it doesn't matter since it doesn't link against
99998 + * any of the gcc libraries
99999 + *
100000 + * gcc plugin to implement various sparse (source code checker) features
100001 + *
100002 + * TODO:
100003 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
100004 + *
100005 + * BUGS:
100006 + * - none known
100007 + */
100008 +#include "gcc-plugin.h"
100009 +#include "config.h"
100010 +#include "system.h"
100011 +#include "coretypes.h"
100012 +#include "tree.h"
100013 +#include "tree-pass.h"
100014 +#include "flags.h"
100015 +#include "intl.h"
100016 +#include "toplev.h"
100017 +#include "plugin.h"
100018 +//#include "expr.h" where are you...
100019 +#include "diagnostic.h"
100020 +#include "plugin-version.h"
100021 +#include "tm.h"
100022 +#include "function.h"
100023 +#include "basic-block.h"
100024 +#include "gimple.h"
100025 +#include "rtl.h"
100026 +#include "emit-rtl.h"
100027 +#include "tree-flow.h"
100028 +#include "target.h"
100029 +
100030 +extern void c_register_addr_space (const char *str, addr_space_t as);
100031 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
100032 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
100033 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
100034 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
100035 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
100036 +
100037 +extern void print_gimple_stmt(FILE *, gimple, int, int);
100038 +extern rtx emit_move_insn(rtx x, rtx y);
100039 +
100040 +int plugin_is_GPL_compatible;
100041 +
100042 +static struct plugin_info checker_plugin_info = {
100043 + .version = "201111150100",
100044 + .help = NULL,
100045 +};
100046 +
100047 +#define ADDR_SPACE_KERNEL 0
100048 +#define ADDR_SPACE_FORCE_KERNEL 1
100049 +#define ADDR_SPACE_USER 2
100050 +#define ADDR_SPACE_FORCE_USER 3
100051 +#define ADDR_SPACE_IOMEM 0
100052 +#define ADDR_SPACE_FORCE_IOMEM 0
100053 +#define ADDR_SPACE_PERCPU 0
100054 +#define ADDR_SPACE_FORCE_PERCPU 0
100055 +#define ADDR_SPACE_RCU 0
100056 +#define ADDR_SPACE_FORCE_RCU 0
100057 +
100058 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
100059 +{
100060 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
100061 +}
100062 +
100063 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
100064 +{
100065 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
100066 +}
100067 +
100068 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
100069 +{
100070 + return default_addr_space_valid_pointer_mode(mode, as);
100071 +}
100072 +
100073 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
100074 +{
100075 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
100076 +}
100077 +
100078 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
100079 +{
100080 + return default_addr_space_legitimize_address(x, oldx, mode, as);
100081 +}
100082 +
100083 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
100084 +{
100085 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
100086 + return true;
100087 +
100088 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
100089 + return true;
100090 +
100091 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
100092 + return true;
100093 +
100094 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
100095 + return true;
100096 +
100097 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
100098 + return true;
100099 +
100100 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
100101 + return true;
100102 +
100103 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
100104 + return true;
100105 +
100106 + return subset == superset;
100107 +}
100108 +
100109 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
100110 +{
100111 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
100112 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
100113 +
100114 + return op;
100115 +}
100116 +
100117 +static void register_checker_address_spaces(void *event_data, void *data)
100118 +{
100119 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
100120 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
100121 + c_register_addr_space("__user", ADDR_SPACE_USER);
100122 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
100123 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
100124 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
100125 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
100126 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
100127 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
100128 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
100129 +
100130 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
100131 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
100132 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
100133 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
100134 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
100135 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
100136 + targetm.addr_space.convert = checker_addr_space_convert;
100137 +}
100138 +
100139 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100140 +{
100141 + const char * const plugin_name = plugin_info->base_name;
100142 + const int argc = plugin_info->argc;
100143 + const struct plugin_argument * const argv = plugin_info->argv;
100144 + int i;
100145 +
100146 + if (!plugin_default_version_check(version, &gcc_version)) {
100147 + error(G_("incompatible gcc/plugin versions"));
100148 + return 1;
100149 + }
100150 +
100151 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
100152 +
100153 + for (i = 0; i < argc; ++i)
100154 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100155 +
100156 + if (TARGET_64BIT == 0)
100157 + return 0;
100158 +
100159 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
100160 +
100161 + return 0;
100162 +}
100163 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
100164 new file mode 100644
100165 index 0000000..414fe5e
100166 --- /dev/null
100167 +++ b/tools/gcc/colorize_plugin.c
100168 @@ -0,0 +1,151 @@
100169 +/*
100170 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
100171 + * Licensed under the GPL v2
100172 + *
100173 + * Note: the choice of the license means that the compilation process is
100174 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100175 + * but for the kernel it doesn't matter since it doesn't link against
100176 + * any of the gcc libraries
100177 + *
100178 + * gcc plugin to colorize diagnostic output
100179 + *
100180 + */
100181 +
100182 +#include "gcc-plugin.h"
100183 +#include "config.h"
100184 +#include "system.h"
100185 +#include "coretypes.h"
100186 +#include "tree.h"
100187 +#include "tree-pass.h"
100188 +#include "flags.h"
100189 +#include "intl.h"
100190 +#include "toplev.h"
100191 +#include "plugin.h"
100192 +#include "diagnostic.h"
100193 +#include "plugin-version.h"
100194 +#include "tm.h"
100195 +
100196 +int plugin_is_GPL_compatible;
100197 +
100198 +static struct plugin_info colorize_plugin_info = {
100199 + .version = "201302112000",
100200 + .help = NULL,
100201 +};
100202 +
100203 +#define GREEN "\033[32m\033[2m"
100204 +#define LIGHTGREEN "\033[32m\033[1m"
100205 +#define YELLOW "\033[33m\033[2m"
100206 +#define LIGHTYELLOW "\033[33m\033[1m"
100207 +#define RED "\033[31m\033[2m"
100208 +#define LIGHTRED "\033[31m\033[1m"
100209 +#define BLUE "\033[34m\033[2m"
100210 +#define LIGHTBLUE "\033[34m\033[1m"
100211 +#define BRIGHT "\033[m\033[1m"
100212 +#define NORMAL "\033[m"
100213 +
100214 +static diagnostic_starter_fn old_starter;
100215 +static diagnostic_finalizer_fn old_finalizer;
100216 +
100217 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100218 +{
100219 + const char *color;
100220 + char *newprefix;
100221 +
100222 + switch (diagnostic->kind) {
100223 + case DK_NOTE:
100224 + color = LIGHTBLUE;
100225 + break;
100226 +
100227 + case DK_PEDWARN:
100228 + case DK_WARNING:
100229 + color = LIGHTYELLOW;
100230 + break;
100231 +
100232 + case DK_ERROR:
100233 + case DK_FATAL:
100234 + case DK_ICE:
100235 + case DK_PERMERROR:
100236 + case DK_SORRY:
100237 + color = LIGHTRED;
100238 + break;
100239 +
100240 + default:
100241 + color = NORMAL;
100242 + }
100243 +
100244 + old_starter(context, diagnostic);
100245 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
100246 + return;
100247 + pp_destroy_prefix(context->printer);
100248 + pp_set_prefix(context->printer, newprefix);
100249 +}
100250 +
100251 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
100252 +{
100253 + old_finalizer(context, diagnostic);
100254 +}
100255 +
100256 +static void colorize_arm(void)
100257 +{
100258 + old_starter = diagnostic_starter(global_dc);
100259 + old_finalizer = diagnostic_finalizer(global_dc);
100260 +
100261 + diagnostic_starter(global_dc) = start_colorize;
100262 + diagnostic_finalizer(global_dc) = finalize_colorize;
100263 +}
100264 +
100265 +static unsigned int execute_colorize_rearm(void)
100266 +{
100267 + if (diagnostic_starter(global_dc) == start_colorize)
100268 + return 0;
100269 +
100270 + colorize_arm();
100271 + return 0;
100272 +}
100273 +
100274 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
100275 + .pass = {
100276 + .type = SIMPLE_IPA_PASS,
100277 + .name = "colorize_rearm",
100278 +#if BUILDING_GCC_VERSION >= 4008
100279 + .optinfo_flags = OPTGROUP_NONE,
100280 +#endif
100281 + .gate = NULL,
100282 + .execute = execute_colorize_rearm,
100283 + .sub = NULL,
100284 + .next = NULL,
100285 + .static_pass_number = 0,
100286 + .tv_id = TV_NONE,
100287 + .properties_required = 0,
100288 + .properties_provided = 0,
100289 + .properties_destroyed = 0,
100290 + .todo_flags_start = 0,
100291 + .todo_flags_finish = 0
100292 + }
100293 +};
100294 +
100295 +static void colorize_start_unit(void *gcc_data, void *user_data)
100296 +{
100297 + colorize_arm();
100298 +}
100299 +
100300 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100301 +{
100302 + const char * const plugin_name = plugin_info->base_name;
100303 + struct register_pass_info colorize_rearm_pass_info = {
100304 + .pass = &pass_ipa_colorize_rearm.pass,
100305 + .reference_pass_name = "*free_lang_data",
100306 + .ref_pass_instance_number = 1,
100307 + .pos_op = PASS_POS_INSERT_AFTER
100308 + };
100309 +
100310 + if (!plugin_default_version_check(version, &gcc_version)) {
100311 + error(G_("incompatible gcc/plugin versions"));
100312 + return 1;
100313 + }
100314 +
100315 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
100316 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
100317 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
100318 + return 0;
100319 +}
100320 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
100321 new file mode 100644
100322 index 0000000..c17312d
100323 --- /dev/null
100324 +++ b/tools/gcc/constify_plugin.c
100325 @@ -0,0 +1,560 @@
100326 +/*
100327 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
100328 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
100329 + * Licensed under the GPL v2, or (at your option) v3
100330 + *
100331 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
100332 + *
100333 + * Homepage:
100334 + * http://www.grsecurity.net/~ephox/const_plugin/
100335 + *
100336 + * Usage:
100337 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
100338 + * $ gcc -fplugin=constify_plugin.so test.c -O2
100339 + */
100340 +
100341 +#include "gcc-plugin.h"
100342 +#include "config.h"
100343 +#include "system.h"
100344 +#include "coretypes.h"
100345 +#include "tree.h"
100346 +#include "tree-pass.h"
100347 +#include "flags.h"
100348 +#include "intl.h"
100349 +#include "toplev.h"
100350 +#include "plugin.h"
100351 +#include "diagnostic.h"
100352 +#include "plugin-version.h"
100353 +#include "tm.h"
100354 +#include "function.h"
100355 +#include "basic-block.h"
100356 +#include "gimple.h"
100357 +#include "rtl.h"
100358 +#include "emit-rtl.h"
100359 +#include "tree-flow.h"
100360 +#include "target.h"
100361 +#include "langhooks.h"
100362 +
100363 +// should come from c-tree.h if only it were installed for gcc 4.5...
100364 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
100365 +
100366 +// unused type flag in all versions 4.5-4.8
100367 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
100368 +
100369 +int plugin_is_GPL_compatible;
100370 +
100371 +static struct plugin_info const_plugin_info = {
100372 + .version = "201305231310",
100373 + .help = "no-constify\tturn off constification\n",
100374 +};
100375 +
100376 +typedef struct {
100377 + bool has_fptr_field;
100378 + bool has_writable_field;
100379 + bool has_do_const_field;
100380 + bool has_no_const_field;
100381 +} constify_info;
100382 +
100383 +static const_tree get_field_type(const_tree field)
100384 +{
100385 + return strip_array_types(TREE_TYPE(field));
100386 +}
100387 +
100388 +static bool is_fptr(const_tree field)
100389 +{
100390 + const_tree ptr = get_field_type(field);
100391 +
100392 + if (TREE_CODE(ptr) != POINTER_TYPE)
100393 + return false;
100394 +
100395 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
100396 +}
100397 +
100398 +/*
100399 + * determine whether the given structure type meets the requirements for automatic constification,
100400 + * including the constification attributes on nested structure types
100401 + */
100402 +static void constifiable(const_tree node, constify_info *cinfo)
100403 +{
100404 + const_tree field;
100405 +
100406 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100407 +
100408 + // e.g., pointer to structure fields while still constructing the structure type
100409 + if (TYPE_FIELDS(node) == NULL_TREE)
100410 + return;
100411 +
100412 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
100413 + const_tree type = get_field_type(field);
100414 + enum tree_code code = TREE_CODE(type);
100415 +
100416 + if (node == type)
100417 + continue;
100418 +
100419 + if (is_fptr(field))
100420 + cinfo->has_fptr_field = true;
100421 + else if (!TREE_READONLY(field))
100422 + cinfo->has_writable_field = true;
100423 +
100424 + if (code == RECORD_TYPE || code == UNION_TYPE) {
100425 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100426 + cinfo->has_do_const_field = true;
100427 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
100428 + cinfo->has_no_const_field = true;
100429 + else
100430 + constifiable(type, cinfo);
100431 + }
100432 + }
100433 +}
100434 +
100435 +static bool constified(const_tree node)
100436 +{
100437 + constify_info cinfo = {
100438 + .has_fptr_field = false,
100439 + .has_writable_field = false,
100440 + .has_do_const_field = false,
100441 + .has_no_const_field = false
100442 + };
100443 +
100444 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
100445 +
100446 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
100447 + gcc_assert(!TYPE_READONLY(node));
100448 + return false;
100449 + }
100450 +
100451 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
100452 + gcc_assert(TYPE_READONLY(node));
100453 + return true;
100454 + }
100455 +
100456 + constifiable(node, &cinfo);
100457 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
100458 + return false;
100459 +
100460 + return TYPE_READONLY(node);
100461 +}
100462 +
100463 +static void deconstify_tree(tree node);
100464 +
100465 +static void deconstify_type(tree type)
100466 +{
100467 + tree field;
100468 +
100469 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
100470 +
100471 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
100472 + const_tree fieldtype = get_field_type(field);
100473 +
100474 + // special case handling of simple ptr-to-same-array-type members
100475 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
100476 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
100477 +
100478 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
100479 + continue;
100480 + if (TREE_TYPE(TREE_TYPE(field)) == type)
100481 + continue;
100482 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
100483 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
100484 + TREE_TYPE(TREE_TYPE(field)) = type;
100485 + }
100486 + continue;
100487 + }
100488 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
100489 + continue;
100490 + if (!constified(fieldtype))
100491 + continue;
100492 +
100493 + deconstify_tree(field);
100494 + TREE_READONLY(field) = 0;
100495 + }
100496 + TYPE_READONLY(type) = 0;
100497 + C_TYPE_FIELDS_READONLY(type) = 0;
100498 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100499 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
100500 +}
100501 +
100502 +static void deconstify_tree(tree node)
100503 +{
100504 + tree old_type, new_type, field;
100505 +
100506 + old_type = TREE_TYPE(node);
100507 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
100508 + node = TREE_TYPE(node) = copy_node(old_type);
100509 + old_type = TREE_TYPE(old_type);
100510 + }
100511 +
100512 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
100513 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
100514 +
100515 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
100516 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
100517 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
100518 + DECL_FIELD_CONTEXT(field) = new_type;
100519 +
100520 + deconstify_type(new_type);
100521 +
100522 + TREE_TYPE(node) = new_type;
100523 +}
100524 +
100525 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100526 +{
100527 + tree type;
100528 + constify_info cinfo = {
100529 + .has_fptr_field = false,
100530 + .has_writable_field = false,
100531 + .has_do_const_field = false,
100532 + .has_no_const_field = false
100533 + };
100534 +
100535 + *no_add_attrs = true;
100536 + if (TREE_CODE(*node) == FUNCTION_DECL) {
100537 + error("%qE attribute does not apply to functions", name);
100538 + return NULL_TREE;
100539 + }
100540 +
100541 + if (TREE_CODE(*node) == PARM_DECL) {
100542 + error("%qE attribute does not apply to function parameters", name);
100543 + return NULL_TREE;
100544 + }
100545 +
100546 + if (TREE_CODE(*node) == VAR_DECL) {
100547 + error("%qE attribute does not apply to variables", name);
100548 + return NULL_TREE;
100549 + }
100550 +
100551 + if (TYPE_P(*node)) {
100552 + *no_add_attrs = false;
100553 + type = *node;
100554 + } else {
100555 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
100556 + type = TREE_TYPE(*node);
100557 + }
100558 +
100559 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
100560 + error("%qE attribute applies to struct and union types only", name);
100561 + return NULL_TREE;
100562 + }
100563 +
100564 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
100565 + error("%qE attribute is already applied to the type", name);
100566 + return NULL_TREE;
100567 + }
100568 +
100569 + if (TYPE_P(*node)) {
100570 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100571 + error("%qE attribute is incompatible with 'do_const'", name);
100572 + return NULL_TREE;
100573 + }
100574 +
100575 + constifiable(type, &cinfo);
100576 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100577 + deconstify_tree(*node);
100578 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
100579 + return NULL_TREE;
100580 + }
100581 +
100582 + error("%qE attribute used on type that is not constified", name);
100583 + return NULL_TREE;
100584 +}
100585 +
100586 +static void constify_type(tree type)
100587 +{
100588 + TYPE_READONLY(type) = 1;
100589 + C_TYPE_FIELDS_READONLY(type) = 1;
100590 + TYPE_CONSTIFY_VISITED(type) = 1;
100591 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
100592 +}
100593 +
100594 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
100595 +{
100596 + *no_add_attrs = true;
100597 + if (!TYPE_P(*node)) {
100598 + error("%qE attribute applies to types only", name);
100599 + return NULL_TREE;
100600 + }
100601 +
100602 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
100603 + error("%qE attribute applies to struct and union types only", name);
100604 + return NULL_TREE;
100605 + }
100606 +
100607 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
100608 + error("%qE attribute is already applied to the type", name);
100609 + return NULL_TREE;
100610 + }
100611 +
100612 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
100613 + error("%qE attribute is incompatible with 'no_const'", name);
100614 + return NULL_TREE;
100615 + }
100616 +
100617 + *no_add_attrs = false;
100618 + return NULL_TREE;
100619 +}
100620 +
100621 +static struct attribute_spec no_const_attr = {
100622 + .name = "no_const",
100623 + .min_length = 0,
100624 + .max_length = 0,
100625 + .decl_required = false,
100626 + .type_required = false,
100627 + .function_type_required = false,
100628 + .handler = handle_no_const_attribute,
100629 +#if BUILDING_GCC_VERSION >= 4007
100630 + .affects_type_identity = true
100631 +#endif
100632 +};
100633 +
100634 +static struct attribute_spec do_const_attr = {
100635 + .name = "do_const",
100636 + .min_length = 0,
100637 + .max_length = 0,
100638 + .decl_required = false,
100639 + .type_required = false,
100640 + .function_type_required = false,
100641 + .handler = handle_do_const_attribute,
100642 +#if BUILDING_GCC_VERSION >= 4007
100643 + .affects_type_identity = true
100644 +#endif
100645 +};
100646 +
100647 +static void register_attributes(void *event_data, void *data)
100648 +{
100649 + register_attribute(&no_const_attr);
100650 + register_attribute(&do_const_attr);
100651 +}
100652 +
100653 +static void finish_type(void *event_data, void *data)
100654 +{
100655 + tree type = (tree)event_data;
100656 + constify_info cinfo = {
100657 + .has_fptr_field = false,
100658 + .has_writable_field = false,
100659 + .has_do_const_field = false,
100660 + .has_no_const_field = false
100661 + };
100662 +
100663 + if (type == NULL_TREE || type == error_mark_node)
100664 + return;
100665 +
100666 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
100667 + return;
100668 +
100669 + constifiable(type, &cinfo);
100670 +
100671 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
100672 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
100673 + return;
100674 + if (cinfo.has_writable_field)
100675 + return;
100676 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
100677 + return;
100678 + }
100679 +
100680 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
100681 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
100682 + deconstify_type(type);
100683 + TYPE_CONSTIFY_VISITED(type) = 1;
100684 + } else
100685 + error("'no_const' attribute used on type that is not constified");
100686 + return;
100687 + }
100688 +
100689 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
100690 + constify_type(type);
100691 + return;
100692 + }
100693 +
100694 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
100695 + constify_type(type);
100696 + return;
100697 + }
100698 +
100699 + deconstify_type(type);
100700 + TYPE_CONSTIFY_VISITED(type) = 1;
100701 +}
100702 +
100703 +static void check_global_variables(void)
100704 +{
100705 + struct varpool_node *node;
100706 +
100707 +#if BUILDING_GCC_VERSION <= 4007
100708 + for (node = varpool_nodes; node; node = node->next) {
100709 + tree var = node->decl;
100710 +#else
100711 + FOR_EACH_VARIABLE(node) {
100712 + tree var = node->symbol.decl;
100713 +#endif
100714 + tree type = TREE_TYPE(var);
100715 +
100716 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100717 + continue;
100718 +
100719 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100720 + continue;
100721 +
100722 + if (!TYPE_CONSTIFY_VISITED(type))
100723 + continue;
100724 +
100725 + if (DECL_EXTERNAL(var))
100726 + continue;
100727 +
100728 + if (DECL_INITIAL(var))
100729 + continue;
100730 +
100731 + // this works around a gcc bug/feature where uninitialized globals
100732 + // are moved into the .bss section regardless of any constification
100733 + DECL_INITIAL(var) = build_constructor(type, NULL);
100734 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
100735 + }
100736 +}
100737 +
100738 +static unsigned int check_local_variables(void)
100739 +{
100740 + unsigned int ret = 0;
100741 + tree var;
100742 +
100743 +#if BUILDING_GCC_VERSION == 4005
100744 + tree vars;
100745 +#else
100746 + unsigned int i;
100747 +#endif
100748 +
100749 +#if BUILDING_GCC_VERSION == 4005
100750 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
100751 + var = TREE_VALUE(vars);
100752 +#else
100753 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
100754 +#endif
100755 + tree type = TREE_TYPE(var);
100756 +
100757 + gcc_assert(DECL_P(var));
100758 + if (is_global_var(var))
100759 + continue;
100760 +
100761 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
100762 + continue;
100763 +
100764 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
100765 + continue;
100766 +
100767 + if (!TYPE_CONSTIFY_VISITED(type))
100768 + continue;
100769 +
100770 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
100771 + ret = 1;
100772 + }
100773 + return ret;
100774 +}
100775 +
100776 +static unsigned int check_variables(void)
100777 +{
100778 + check_global_variables();
100779 + return check_local_variables();
100780 +}
100781 +
100782 + unsigned int ret = 0;
100783 +static struct gimple_opt_pass pass_local_variable = {
100784 + {
100785 + .type = GIMPLE_PASS,
100786 + .name = "check_variables",
100787 +#if BUILDING_GCC_VERSION >= 4008
100788 + .optinfo_flags = OPTGROUP_NONE,
100789 +#endif
100790 + .gate = NULL,
100791 + .execute = check_variables,
100792 + .sub = NULL,
100793 + .next = NULL,
100794 + .static_pass_number = 0,
100795 + .tv_id = TV_NONE,
100796 + .properties_required = 0,
100797 + .properties_provided = 0,
100798 + .properties_destroyed = 0,
100799 + .todo_flags_start = 0,
100800 + .todo_flags_finish = 0
100801 + }
100802 +};
100803 +
100804 +static struct {
100805 + const char *name;
100806 + const char *asm_op;
100807 +} sections[] = {
100808 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
100809 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
100810 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
100811 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
100812 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
100813 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
100814 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
100815 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
100816 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
100817 +};
100818 +
100819 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
100820 +
100821 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
100822 +{
100823 + size_t i;
100824 +
100825 + for (i = 0; i < ARRAY_SIZE(sections); i++)
100826 + if (!strcmp(sections[i].name, name))
100827 + return 0;
100828 + return old_section_type_flags(decl, name, reloc);
100829 +}
100830 +
100831 +static void constify_start_unit(void *gcc_data, void *user_data)
100832 +{
100833 +// size_t i;
100834 +
100835 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
100836 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
100837 +// sections[i].section = get_section(sections[i].name, 0, NULL);
100838 +
100839 + old_section_type_flags = targetm.section_type_flags;
100840 + targetm.section_type_flags = constify_section_type_flags;
100841 +}
100842 +
100843 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
100844 +{
100845 + const char * const plugin_name = plugin_info->base_name;
100846 + const int argc = plugin_info->argc;
100847 + const struct plugin_argument * const argv = plugin_info->argv;
100848 + int i;
100849 + bool constify = true;
100850 +
100851 + struct register_pass_info local_variable_pass_info = {
100852 + .pass = &pass_local_variable.pass,
100853 + .reference_pass_name = "ssa",
100854 + .ref_pass_instance_number = 1,
100855 + .pos_op = PASS_POS_INSERT_BEFORE
100856 + };
100857 +
100858 + if (!plugin_default_version_check(version, &gcc_version)) {
100859 + error(G_("incompatible gcc/plugin versions"));
100860 + return 1;
100861 + }
100862 +
100863 + for (i = 0; i < argc; ++i) {
100864 + if (!(strcmp(argv[i].key, "no-constify"))) {
100865 + constify = false;
100866 + continue;
100867 + }
100868 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
100869 + }
100870 +
100871 + if (strcmp(lang_hooks.name, "GNU C")) {
100872 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
100873 + constify = false;
100874 + }
100875 +
100876 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
100877 + if (constify) {
100878 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
100879 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
100880 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
100881 + }
100882 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
100883 +
100884 + return 0;
100885 +}
100886 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
100887 new file mode 100644
100888 index 0000000..e518932
100889 --- /dev/null
100890 +++ b/tools/gcc/generate_size_overflow_hash.sh
100891 @@ -0,0 +1,94 @@
100892 +#!/bin/bash
100893 +
100894 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
100895 +
100896 +header1="size_overflow_hash.h"
100897 +database="size_overflow_hash.data"
100898 +n=65536
100899 +
100900 +usage() {
100901 +cat <<EOF
100902 +usage: $0 options
100903 +OPTIONS:
100904 + -h|--help help
100905 + -o header file
100906 + -d database file
100907 + -n hash array size
100908 +EOF
100909 + return 0
100910 +}
100911 +
100912 +while true
100913 +do
100914 + case "$1" in
100915 + -h|--help) usage && exit 0;;
100916 + -n) n=$2; shift 2;;
100917 + -o) header1="$2"; shift 2;;
100918 + -d) database="$2"; shift 2;;
100919 + --) shift 1; break ;;
100920 + *) break ;;
100921 + esac
100922 +done
100923 +
100924 +create_defines() {
100925 + for i in `seq 0 31`
100926 + do
100927 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
100928 + done
100929 + echo >> "$header1"
100930 +}
100931 +
100932 +create_structs() {
100933 + rm -f "$header1"
100934 +
100935 + create_defines
100936 +
100937 + cat "$database" | while read data
100938 + do
100939 + data_array=($data)
100940 + struct_hash_name="${data_array[0]}"
100941 + funcn="${data_array[1]}"
100942 + params="${data_array[2]}"
100943 + next="${data_array[4]}"
100944 +
100945 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
100946 +
100947 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
100948 + echo -en "\t.param\t= " >> "$header1"
100949 + line=
100950 + for param_num in ${params//-/ };
100951 + do
100952 + line="${line}PARAM"$param_num"|"
100953 + done
100954 +
100955 + echo -e "${line%?},\n};\n" >> "$header1"
100956 + done
100957 +}
100958 +
100959 +create_headers() {
100960 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
100961 +}
100962 +
100963 +create_array_elements() {
100964 + index=0
100965 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
100966 + do
100967 + data_array=($data)
100968 + i="${data_array[3]}"
100969 + hash="${data_array[0]}"
100970 + while [[ $index -lt $i ]]
100971 + do
100972 + echo -e "\t["$index"]\t= NULL," >> "$header1"
100973 + index=$(($index + 1))
100974 + done
100975 + index=$(($index + 1))
100976 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
100977 + done
100978 + echo '};' >> $header1
100979 +}
100980 +
100981 +create_structs
100982 +create_headers
100983 +create_array_elements
100984 +
100985 +exit 0
100986 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
100987 new file mode 100644
100988 index 0000000..568b360
100989 --- /dev/null
100990 +++ b/tools/gcc/kallocstat_plugin.c
100991 @@ -0,0 +1,170 @@
100992 +/*
100993 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
100994 + * Licensed under the GPL v2
100995 + *
100996 + * Note: the choice of the license means that the compilation process is
100997 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
100998 + * but for the kernel it doesn't matter since it doesn't link against
100999 + * any of the gcc libraries
101000 + *
101001 + * gcc plugin to find the distribution of k*alloc sizes
101002 + *
101003 + * TODO:
101004 + *
101005 + * BUGS:
101006 + * - none known
101007 + */
101008 +#include "gcc-plugin.h"
101009 +#include "config.h"
101010 +#include "system.h"
101011 +#include "coretypes.h"
101012 +#include "tree.h"
101013 +#include "tree-pass.h"
101014 +#include "flags.h"
101015 +#include "intl.h"
101016 +#include "toplev.h"
101017 +#include "plugin.h"
101018 +//#include "expr.h" where are you...
101019 +#include "diagnostic.h"
101020 +#include "plugin-version.h"
101021 +#include "tm.h"
101022 +#include "function.h"
101023 +#include "basic-block.h"
101024 +#include "gimple.h"
101025 +#include "rtl.h"
101026 +#include "emit-rtl.h"
101027 +
101028 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101029 +
101030 +int plugin_is_GPL_compatible;
101031 +
101032 +static const char * const kalloc_functions[] = {
101033 + "__kmalloc",
101034 + "kmalloc",
101035 + "kmalloc_large",
101036 + "kmalloc_node",
101037 + "kmalloc_order",
101038 + "kmalloc_order_trace",
101039 + "kmalloc_slab",
101040 + "kzalloc",
101041 + "kzalloc_node",
101042 +};
101043 +
101044 +static struct plugin_info kallocstat_plugin_info = {
101045 + .version = "201302112000",
101046 +};
101047 +
101048 +static unsigned int execute_kallocstat(void);
101049 +
101050 +static struct gimple_opt_pass kallocstat_pass = {
101051 + .pass = {
101052 + .type = GIMPLE_PASS,
101053 + .name = "kallocstat",
101054 +#if BUILDING_GCC_VERSION >= 4008
101055 + .optinfo_flags = OPTGROUP_NONE,
101056 +#endif
101057 + .gate = NULL,
101058 + .execute = execute_kallocstat,
101059 + .sub = NULL,
101060 + .next = NULL,
101061 + .static_pass_number = 0,
101062 + .tv_id = TV_NONE,
101063 + .properties_required = 0,
101064 + .properties_provided = 0,
101065 + .properties_destroyed = 0,
101066 + .todo_flags_start = 0,
101067 + .todo_flags_finish = 0
101068 + }
101069 +};
101070 +
101071 +static bool is_kalloc(const char *fnname)
101072 +{
101073 + size_t i;
101074 +
101075 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
101076 + if (!strcmp(fnname, kalloc_functions[i]))
101077 + return true;
101078 + return false;
101079 +}
101080 +
101081 +static unsigned int execute_kallocstat(void)
101082 +{
101083 + basic_block bb;
101084 +
101085 + // 1. loop through BBs and GIMPLE statements
101086 + FOR_EACH_BB(bb) {
101087 + gimple_stmt_iterator gsi;
101088 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101089 + // gimple match:
101090 + tree fndecl, size;
101091 + gimple call_stmt;
101092 + const char *fnname;
101093 +
101094 + // is it a call
101095 + call_stmt = gsi_stmt(gsi);
101096 + if (!is_gimple_call(call_stmt))
101097 + continue;
101098 + fndecl = gimple_call_fndecl(call_stmt);
101099 + if (fndecl == NULL_TREE)
101100 + continue;
101101 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
101102 + continue;
101103 +
101104 + // is it a call to k*alloc
101105 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
101106 + if (!is_kalloc(fnname))
101107 + continue;
101108 +
101109 + // is the size arg the result of a simple const assignment
101110 + size = gimple_call_arg(call_stmt, 0);
101111 + while (true) {
101112 + gimple def_stmt;
101113 + expanded_location xloc;
101114 + size_t size_val;
101115 +
101116 + if (TREE_CODE(size) != SSA_NAME)
101117 + break;
101118 + def_stmt = SSA_NAME_DEF_STMT(size);
101119 + if (!def_stmt || !is_gimple_assign(def_stmt))
101120 + break;
101121 + if (gimple_num_ops(def_stmt) != 2)
101122 + break;
101123 + size = gimple_assign_rhs1(def_stmt);
101124 + if (!TREE_CONSTANT(size))
101125 + continue;
101126 + xloc = expand_location(gimple_location(def_stmt));
101127 + if (!xloc.file)
101128 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
101129 + size_val = TREE_INT_CST_LOW(size);
101130 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
101131 + break;
101132 + }
101133 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101134 +//debug_tree(gimple_call_fn(call_stmt));
101135 +//print_node(stderr, "pax", fndecl, 4);
101136 + }
101137 + }
101138 +
101139 + return 0;
101140 +}
101141 +
101142 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101143 +{
101144 + const char * const plugin_name = plugin_info->base_name;
101145 + struct register_pass_info kallocstat_pass_info = {
101146 + .pass = &kallocstat_pass.pass,
101147 + .reference_pass_name = "ssa",
101148 + .ref_pass_instance_number = 1,
101149 + .pos_op = PASS_POS_INSERT_AFTER
101150 + };
101151 +
101152 + if (!plugin_default_version_check(version, &gcc_version)) {
101153 + error(G_("incompatible gcc/plugin versions"));
101154 + return 1;
101155 + }
101156 +
101157 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
101158 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
101159 +
101160 + return 0;
101161 +}
101162 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
101163 new file mode 100644
101164 index 0000000..698da67
101165 --- /dev/null
101166 +++ b/tools/gcc/kernexec_plugin.c
101167 @@ -0,0 +1,471 @@
101168 +/*
101169 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
101170 + * Licensed under the GPL v2
101171 + *
101172 + * Note: the choice of the license means that the compilation process is
101173 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101174 + * but for the kernel it doesn't matter since it doesn't link against
101175 + * any of the gcc libraries
101176 + *
101177 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
101178 + *
101179 + * TODO:
101180 + *
101181 + * BUGS:
101182 + * - none known
101183 + */
101184 +#include "gcc-plugin.h"
101185 +#include "config.h"
101186 +#include "system.h"
101187 +#include "coretypes.h"
101188 +#include "tree.h"
101189 +#include "tree-pass.h"
101190 +#include "flags.h"
101191 +#include "intl.h"
101192 +#include "toplev.h"
101193 +#include "plugin.h"
101194 +//#include "expr.h" where are you...
101195 +#include "diagnostic.h"
101196 +#include "plugin-version.h"
101197 +#include "tm.h"
101198 +#include "function.h"
101199 +#include "basic-block.h"
101200 +#include "gimple.h"
101201 +#include "rtl.h"
101202 +#include "emit-rtl.h"
101203 +#include "tree-flow.h"
101204 +
101205 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101206 +extern rtx emit_move_insn(rtx x, rtx y);
101207 +
101208 +#if BUILDING_GCC_VERSION <= 4006
101209 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
101210 +#endif
101211 +
101212 +#if BUILDING_GCC_VERSION >= 4008
101213 +#define TODO_dump_func 0
101214 +#endif
101215 +
101216 +int plugin_is_GPL_compatible;
101217 +
101218 +static struct plugin_info kernexec_plugin_info = {
101219 + .version = "201308230150",
101220 + .help = "method=[bts|or]\tinstrumentation method\n"
101221 +};
101222 +
101223 +static unsigned int execute_kernexec_reload(void);
101224 +static unsigned int execute_kernexec_fptr(void);
101225 +static unsigned int execute_kernexec_retaddr(void);
101226 +static bool kernexec_cmodel_check(void);
101227 +
101228 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
101229 +static void (*kernexec_instrument_retaddr)(rtx);
101230 +
101231 +static struct gimple_opt_pass kernexec_reload_pass = {
101232 + .pass = {
101233 + .type = GIMPLE_PASS,
101234 + .name = "kernexec_reload",
101235 +#if BUILDING_GCC_VERSION >= 4008
101236 + .optinfo_flags = OPTGROUP_NONE,
101237 +#endif
101238 + .gate = kernexec_cmodel_check,
101239 + .execute = execute_kernexec_reload,
101240 + .sub = NULL,
101241 + .next = NULL,
101242 + .static_pass_number = 0,
101243 + .tv_id = TV_NONE,
101244 + .properties_required = 0,
101245 + .properties_provided = 0,
101246 + .properties_destroyed = 0,
101247 + .todo_flags_start = 0,
101248 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101249 + }
101250 +};
101251 +
101252 +static struct gimple_opt_pass kernexec_fptr_pass = {
101253 + .pass = {
101254 + .type = GIMPLE_PASS,
101255 + .name = "kernexec_fptr",
101256 +#if BUILDING_GCC_VERSION >= 4008
101257 + .optinfo_flags = OPTGROUP_NONE,
101258 +#endif
101259 + .gate = kernexec_cmodel_check,
101260 + .execute = execute_kernexec_fptr,
101261 + .sub = NULL,
101262 + .next = NULL,
101263 + .static_pass_number = 0,
101264 + .tv_id = TV_NONE,
101265 + .properties_required = 0,
101266 + .properties_provided = 0,
101267 + .properties_destroyed = 0,
101268 + .todo_flags_start = 0,
101269 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
101270 + }
101271 +};
101272 +
101273 +static struct rtl_opt_pass kernexec_retaddr_pass = {
101274 + .pass = {
101275 + .type = RTL_PASS,
101276 + .name = "kernexec_retaddr",
101277 +#if BUILDING_GCC_VERSION >= 4008
101278 + .optinfo_flags = OPTGROUP_NONE,
101279 +#endif
101280 + .gate = kernexec_cmodel_check,
101281 + .execute = execute_kernexec_retaddr,
101282 + .sub = NULL,
101283 + .next = NULL,
101284 + .static_pass_number = 0,
101285 + .tv_id = TV_NONE,
101286 + .properties_required = 0,
101287 + .properties_provided = 0,
101288 + .properties_destroyed = 0,
101289 + .todo_flags_start = 0,
101290 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
101291 + }
101292 +};
101293 +
101294 +static bool kernexec_cmodel_check(void)
101295 +{
101296 + tree section;
101297 +
101298 + if (ix86_cmodel != CM_KERNEL)
101299 + return false;
101300 +
101301 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
101302 + if (!section || !TREE_VALUE(section))
101303 + return true;
101304 +
101305 + section = TREE_VALUE(TREE_VALUE(section));
101306 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
101307 + return true;
101308 +
101309 + return false;
101310 +}
101311 +
101312 +/*
101313 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
101314 + */
101315 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
101316 +{
101317 + gimple asm_movabs_stmt;
101318 +
101319 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
101320 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
101321 + gimple_asm_set_volatile(asm_movabs_stmt, true);
101322 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
101323 + update_stmt(asm_movabs_stmt);
101324 +}
101325 +
101326 +/*
101327 + * find all asm() stmts that clobber r10 and add a reload of r10
101328 + */
101329 +static unsigned int execute_kernexec_reload(void)
101330 +{
101331 + basic_block bb;
101332 +
101333 + // 1. loop through BBs and GIMPLE statements
101334 + FOR_EACH_BB(bb) {
101335 + gimple_stmt_iterator gsi;
101336 +
101337 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101338 + // gimple match: __asm__ ("" : : : "r10");
101339 + gimple asm_stmt;
101340 + size_t nclobbers;
101341 +
101342 + // is it an asm ...
101343 + asm_stmt = gsi_stmt(gsi);
101344 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
101345 + continue;
101346 +
101347 + // ... clobbering r10
101348 + nclobbers = gimple_asm_nclobbers(asm_stmt);
101349 + while (nclobbers--) {
101350 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
101351 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
101352 + continue;
101353 + kernexec_reload_fptr_mask(&gsi);
101354 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
101355 + break;
101356 + }
101357 + }
101358 + }
101359 +
101360 + return 0;
101361 +}
101362 +
101363 +/*
101364 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
101365 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
101366 + */
101367 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
101368 +{
101369 + gimple assign_intptr, assign_new_fptr, call_stmt;
101370 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
101371 +
101372 + call_stmt = gsi_stmt(*gsi);
101373 + old_fptr = gimple_call_fn(call_stmt);
101374 +
101375 + // create temporary unsigned long variable used for bitops and cast fptr to it
101376 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
101377 +#if BUILDING_GCC_VERSION <= 4007
101378 + add_referenced_var(intptr);
101379 +#endif
101380 + intptr = make_ssa_name(intptr, NULL);
101381 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
101382 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101383 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101384 + update_stmt(assign_intptr);
101385 +
101386 + // apply logical or to temporary unsigned long and bitmask
101387 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
101388 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
101389 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
101390 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
101391 + assign_intptr = gimple_build_assign(intptr, orptr);
101392 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
101393 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
101394 + update_stmt(assign_intptr);
101395 +
101396 + // cast temporary unsigned long back to a temporary fptr variable
101397 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
101398 +#if BUILDING_GCC_VERSION <= 4007
101399 + add_referenced_var(new_fptr);
101400 +#endif
101401 + new_fptr = make_ssa_name(new_fptr, NULL);
101402 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
101403 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
101404 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
101405 + update_stmt(assign_new_fptr);
101406 +
101407 + // replace call stmt fn with the new fptr
101408 + gimple_call_set_fn(call_stmt, new_fptr);
101409 + update_stmt(call_stmt);
101410 +}
101411 +
101412 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
101413 +{
101414 + gimple asm_or_stmt, call_stmt;
101415 + tree old_fptr, new_fptr, input, output;
101416 +#if BUILDING_GCC_VERSION <= 4007
101417 + VEC(tree, gc) *inputs = NULL;
101418 + VEC(tree, gc) *outputs = NULL;
101419 +#else
101420 + vec<tree, va_gc> *inputs = NULL;
101421 + vec<tree, va_gc> *outputs = NULL;
101422 +#endif
101423 +
101424 + call_stmt = gsi_stmt(*gsi);
101425 + old_fptr = gimple_call_fn(call_stmt);
101426 +
101427 + // create temporary fptr variable
101428 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
101429 +#if BUILDING_GCC_VERSION <= 4007
101430 + add_referenced_var(new_fptr);
101431 +#endif
101432 + new_fptr = make_ssa_name(new_fptr, NULL);
101433 +
101434 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
101435 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
101436 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
101437 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
101438 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
101439 +#if BUILDING_GCC_VERSION <= 4007
101440 + VEC_safe_push(tree, gc, inputs, input);
101441 + VEC_safe_push(tree, gc, outputs, output);
101442 +#else
101443 + vec_safe_push(inputs, input);
101444 + vec_safe_push(outputs, output);
101445 +#endif
101446 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
101447 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
101448 + gimple_asm_set_volatile(asm_or_stmt, true);
101449 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
101450 + update_stmt(asm_or_stmt);
101451 +
101452 + // replace call stmt fn with the new fptr
101453 + gimple_call_set_fn(call_stmt, new_fptr);
101454 + update_stmt(call_stmt);
101455 +}
101456 +
101457 +/*
101458 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
101459 + */
101460 +static unsigned int execute_kernexec_fptr(void)
101461 +{
101462 + basic_block bb;
101463 +
101464 + // 1. loop through BBs and GIMPLE statements
101465 + FOR_EACH_BB(bb) {
101466 + gimple_stmt_iterator gsi;
101467 +
101468 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
101469 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
101470 + tree fn;
101471 + gimple call_stmt;
101472 +
101473 + // is it a call ...
101474 + call_stmt = gsi_stmt(gsi);
101475 + if (!is_gimple_call(call_stmt))
101476 + continue;
101477 + fn = gimple_call_fn(call_stmt);
101478 + if (TREE_CODE(fn) == ADDR_EXPR)
101479 + continue;
101480 + if (TREE_CODE(fn) != SSA_NAME)
101481 + gcc_unreachable();
101482 +
101483 + // ... through a function pointer
101484 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
101485 + fn = SSA_NAME_VAR(fn);
101486 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
101487 + debug_tree(fn);
101488 + gcc_unreachable();
101489 + }
101490 + }
101491 + fn = TREE_TYPE(fn);
101492 + if (TREE_CODE(fn) != POINTER_TYPE)
101493 + continue;
101494 + fn = TREE_TYPE(fn);
101495 + if (TREE_CODE(fn) != FUNCTION_TYPE)
101496 + continue;
101497 +
101498 + kernexec_instrument_fptr(&gsi);
101499 +
101500 +//debug_tree(gimple_call_fn(call_stmt));
101501 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
101502 + }
101503 + }
101504 +
101505 + return 0;
101506 +}
101507 +
101508 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
101509 +static void kernexec_instrument_retaddr_bts(rtx insn)
101510 +{
101511 + rtx btsq;
101512 + rtvec argvec, constraintvec, labelvec;
101513 + int line;
101514 +
101515 + // create asm volatile("btsq $63,(%%rsp)":::)
101516 + argvec = rtvec_alloc(0);
101517 + constraintvec = rtvec_alloc(0);
101518 + labelvec = rtvec_alloc(0);
101519 + line = expand_location(RTL_LOCATION(insn)).line;
101520 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101521 + MEM_VOLATILE_P(btsq) = 1;
101522 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
101523 + emit_insn_before(btsq, insn);
101524 +}
101525 +
101526 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
101527 +static void kernexec_instrument_retaddr_or(rtx insn)
101528 +{
101529 + rtx orq;
101530 + rtvec argvec, constraintvec, labelvec;
101531 + int line;
101532 +
101533 + // create asm volatile("orq %%r10,(%%rsp)":::)
101534 + argvec = rtvec_alloc(0);
101535 + constraintvec = rtvec_alloc(0);
101536 + labelvec = rtvec_alloc(0);
101537 + line = expand_location(RTL_LOCATION(insn)).line;
101538 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
101539 + MEM_VOLATILE_P(orq) = 1;
101540 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
101541 + emit_insn_before(orq, insn);
101542 +}
101543 +
101544 +/*
101545 + * find all asm level function returns and forcibly set the highest bit of the return address
101546 + */
101547 +static unsigned int execute_kernexec_retaddr(void)
101548 +{
101549 + rtx insn;
101550 +
101551 + // 1. find function returns
101552 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
101553 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
101554 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
101555 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
101556 + rtx body;
101557 +
101558 + // is it a retn
101559 + if (!JUMP_P(insn))
101560 + continue;
101561 + body = PATTERN(insn);
101562 + if (GET_CODE(body) == PARALLEL)
101563 + body = XVECEXP(body, 0, 0);
101564 + if (!ANY_RETURN_P(body))
101565 + continue;
101566 + kernexec_instrument_retaddr(insn);
101567 + }
101568 +
101569 +// print_simple_rtl(stderr, get_insns());
101570 +// print_rtl(stderr, get_insns());
101571 +
101572 + return 0;
101573 +}
101574 +
101575 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101576 +{
101577 + const char * const plugin_name = plugin_info->base_name;
101578 + const int argc = plugin_info->argc;
101579 + const struct plugin_argument * const argv = plugin_info->argv;
101580 + int i;
101581 + struct register_pass_info kernexec_reload_pass_info = {
101582 + .pass = &kernexec_reload_pass.pass,
101583 + .reference_pass_name = "ssa",
101584 + .ref_pass_instance_number = 1,
101585 + .pos_op = PASS_POS_INSERT_AFTER
101586 + };
101587 + struct register_pass_info kernexec_fptr_pass_info = {
101588 + .pass = &kernexec_fptr_pass.pass,
101589 + .reference_pass_name = "ssa",
101590 + .ref_pass_instance_number = 1,
101591 + .pos_op = PASS_POS_INSERT_AFTER
101592 + };
101593 + struct register_pass_info kernexec_retaddr_pass_info = {
101594 + .pass = &kernexec_retaddr_pass.pass,
101595 + .reference_pass_name = "pro_and_epilogue",
101596 + .ref_pass_instance_number = 1,
101597 + .pos_op = PASS_POS_INSERT_AFTER
101598 + };
101599 +
101600 + if (!plugin_default_version_check(version, &gcc_version)) {
101601 + error(G_("incompatible gcc/plugin versions"));
101602 + return 1;
101603 + }
101604 +
101605 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
101606 +
101607 + if (TARGET_64BIT == 0)
101608 + return 0;
101609 +
101610 + for (i = 0; i < argc; ++i) {
101611 + if (!strcmp(argv[i].key, "method")) {
101612 + if (!argv[i].value) {
101613 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101614 + continue;
101615 + }
101616 + if (!strcmp(argv[i].value, "bts")) {
101617 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
101618 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
101619 + } else if (!strcmp(argv[i].value, "or")) {
101620 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
101621 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
101622 + fix_register("r10", 1, 1);
101623 + } else
101624 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
101625 + continue;
101626 + }
101627 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101628 + }
101629 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
101630 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
101631 +
101632 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
101633 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
101634 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
101635 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
101636 +
101637 + return 0;
101638 +}
101639 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
101640 new file mode 100644
101641 index 0000000..cd6c242
101642 --- /dev/null
101643 +++ b/tools/gcc/latent_entropy_plugin.c
101644 @@ -0,0 +1,321 @@
101645 +/*
101646 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
101647 + * Licensed under the GPL v2
101648 + *
101649 + * Note: the choice of the license means that the compilation process is
101650 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101651 + * but for the kernel it doesn't matter since it doesn't link against
101652 + * any of the gcc libraries
101653 + *
101654 + * gcc plugin to help generate a little bit of entropy from program state,
101655 + * used during boot in the kernel
101656 + *
101657 + * TODO:
101658 + * - add ipa pass to identify not explicitly marked candidate functions
101659 + * - mix in more program state (function arguments/return values, loop variables, etc)
101660 + * - more instrumentation control via attribute parameters
101661 + *
101662 + * BUGS:
101663 + * - LTO needs -flto-partition=none for now
101664 + */
101665 +#include "gcc-plugin.h"
101666 +#include "config.h"
101667 +#include "system.h"
101668 +#include "coretypes.h"
101669 +#include "tree.h"
101670 +#include "tree-pass.h"
101671 +#include "flags.h"
101672 +#include "intl.h"
101673 +#include "toplev.h"
101674 +#include "plugin.h"
101675 +//#include "expr.h" where are you...
101676 +#include "diagnostic.h"
101677 +#include "plugin-version.h"
101678 +#include "tm.h"
101679 +#include "function.h"
101680 +#include "basic-block.h"
101681 +#include "gimple.h"
101682 +#include "rtl.h"
101683 +#include "emit-rtl.h"
101684 +#include "tree-flow.h"
101685 +#include "langhooks.h"
101686 +
101687 +#if BUILDING_GCC_VERSION >= 4008
101688 +#define TODO_dump_func 0
101689 +#endif
101690 +
101691 +int plugin_is_GPL_compatible;
101692 +
101693 +static tree latent_entropy_decl;
101694 +
101695 +static struct plugin_info latent_entropy_plugin_info = {
101696 + .version = "201308230230",
101697 + .help = NULL
101698 +};
101699 +
101700 +static unsigned int execute_latent_entropy(void);
101701 +static bool gate_latent_entropy(void);
101702 +
101703 +static struct gimple_opt_pass latent_entropy_pass = {
101704 + .pass = {
101705 + .type = GIMPLE_PASS,
101706 + .name = "latent_entropy",
101707 +#if BUILDING_GCC_VERSION >= 4008
101708 + .optinfo_flags = OPTGROUP_NONE,
101709 +#endif
101710 + .gate = gate_latent_entropy,
101711 + .execute = execute_latent_entropy,
101712 + .sub = NULL,
101713 + .next = NULL,
101714 + .static_pass_number = 0,
101715 + .tv_id = TV_NONE,
101716 + .properties_required = PROP_gimple_leh | PROP_cfg,
101717 + .properties_provided = 0,
101718 + .properties_destroyed = 0,
101719 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
101720 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
101721 + }
101722 +};
101723 +
101724 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101725 +{
101726 + if (TREE_CODE(*node) != FUNCTION_DECL) {
101727 + *no_add_attrs = true;
101728 + error("%qE attribute only applies to functions", name);
101729 + }
101730 + return NULL_TREE;
101731 +}
101732 +
101733 +static struct attribute_spec latent_entropy_attr = {
101734 + .name = "latent_entropy",
101735 + .min_length = 0,
101736 + .max_length = 0,
101737 + .decl_required = true,
101738 + .type_required = false,
101739 + .function_type_required = false,
101740 + .handler = handle_latent_entropy_attribute,
101741 +#if BUILDING_GCC_VERSION >= 4007
101742 + .affects_type_identity = false
101743 +#endif
101744 +};
101745 +
101746 +static void register_attributes(void *event_data, void *data)
101747 +{
101748 + register_attribute(&latent_entropy_attr);
101749 +}
101750 +
101751 +static bool gate_latent_entropy(void)
101752 +{
101753 + tree latent_entropy_attr;
101754 +
101755 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
101756 + return latent_entropy_attr != NULL_TREE;
101757 +}
101758 +
101759 +static unsigned HOST_WIDE_INT seed;
101760 +static unsigned HOST_WIDE_INT get_random_const(void)
101761 +{
101762 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
101763 + return seed;
101764 +}
101765 +
101766 +static enum tree_code get_op(tree *rhs)
101767 +{
101768 + static enum tree_code op;
101769 + unsigned HOST_WIDE_INT random_const;
101770 +
101771 + random_const = get_random_const();
101772 +
101773 + switch (op) {
101774 + case BIT_XOR_EXPR:
101775 + op = PLUS_EXPR;
101776 + break;
101777 +
101778 + case PLUS_EXPR:
101779 + if (rhs) {
101780 + op = LROTATE_EXPR;
101781 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
101782 + break;
101783 + }
101784 +
101785 + case LROTATE_EXPR:
101786 + default:
101787 + op = BIT_XOR_EXPR;
101788 + break;
101789 + }
101790 + if (rhs)
101791 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
101792 + return op;
101793 +}
101794 +
101795 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
101796 +{
101797 + gimple_stmt_iterator gsi;
101798 + gimple assign;
101799 + tree addxorrol, rhs;
101800 + enum tree_code op;
101801 +
101802 + op = get_op(&rhs);
101803 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
101804 + assign = gimple_build_assign(local_entropy, addxorrol);
101805 + gsi = gsi_after_labels(bb);
101806 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101807 + update_stmt(assign);
101808 +//debug_bb(bb);
101809 +}
101810 +
101811 +static void perturb_latent_entropy(basic_block bb, tree rhs)
101812 +{
101813 + gimple_stmt_iterator gsi;
101814 + gimple assign;
101815 + tree addxorrol, temp;
101816 +
101817 + // 1. create temporary copy of latent_entropy
101818 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
101819 +#if BUILDING_GCC_VERSION <= 4007
101820 + add_referenced_var(temp);
101821 +#endif
101822 +
101823 + // 2. read...
101824 + temp = make_ssa_name(temp, NULL);
101825 + assign = gimple_build_assign(temp, latent_entropy_decl);
101826 + SSA_NAME_DEF_STMT(temp) = assign;
101827 +#if BUILDING_GCC_VERSION <= 4007
101828 + add_referenced_var(latent_entropy_decl);
101829 +#endif
101830 + gsi = gsi_after_labels(bb);
101831 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101832 + update_stmt(assign);
101833 +
101834 + // 3. ...modify...
101835 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
101836 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
101837 + assign = gimple_build_assign(temp, addxorrol);
101838 + SSA_NAME_DEF_STMT(temp) = assign;
101839 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101840 + update_stmt(assign);
101841 +
101842 + // 4. ...write latent_entropy
101843 + assign = gimple_build_assign(latent_entropy_decl, temp);
101844 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101845 + update_stmt(assign);
101846 +}
101847 +
101848 +static unsigned int execute_latent_entropy(void)
101849 +{
101850 + basic_block bb;
101851 + gimple assign;
101852 + gimple_stmt_iterator gsi;
101853 + tree local_entropy;
101854 +
101855 + if (!latent_entropy_decl) {
101856 + struct varpool_node *node;
101857 +
101858 +#if BUILDING_GCC_VERSION <= 4007
101859 + for (node = varpool_nodes; node; node = node->next) {
101860 + tree var = node->decl;
101861 +#else
101862 + FOR_EACH_VARIABLE(node) {
101863 + tree var = node->symbol.decl;
101864 +#endif
101865 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
101866 + continue;
101867 + latent_entropy_decl = var;
101868 +// debug_tree(var);
101869 + break;
101870 + }
101871 + if (!latent_entropy_decl) {
101872 +// debug_tree(current_function_decl);
101873 + return 0;
101874 + }
101875 + }
101876 +
101877 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
101878 +
101879 + // 1. create local entropy variable
101880 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
101881 +#if BUILDING_GCC_VERSION <= 4007
101882 + add_referenced_var(local_entropy);
101883 + mark_sym_for_renaming(local_entropy);
101884 +#endif
101885 +
101886 + // 2. initialize local entropy variable
101887 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101888 + if (dom_info_available_p(CDI_DOMINATORS))
101889 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
101890 + gsi = gsi_start_bb(bb);
101891 +
101892 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
101893 +// gimple_set_location(assign, loc);
101894 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
101895 + update_stmt(assign);
101896 +//debug_bb(bb);
101897 + bb = bb->next_bb;
101898 +
101899 + // 3. instrument each BB with an operation on the local entropy variable
101900 + while (bb != EXIT_BLOCK_PTR) {
101901 + perturb_local_entropy(bb, local_entropy);
101902 +//debug_bb(bb);
101903 + bb = bb->next_bb;
101904 + };
101905 +
101906 + // 4. mix local entropy into the global entropy variable
101907 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
101908 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
101909 + return 0;
101910 +}
101911 +
101912 +static void start_unit_callback(void *gcc_data, void *user_data)
101913 +{
101914 + tree latent_entropy_type;
101915 +
101916 +#if BUILDING_GCC_VERSION >= 4007
101917 + seed = get_random_seed(false);
101918 +#else
101919 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
101920 + seed *= seed;
101921 +#endif
101922 +
101923 + if (in_lto_p)
101924 + return;
101925 +
101926 + // extern volatile u64 latent_entropy
101927 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
101928 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
101929 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
101930 +
101931 + TREE_STATIC(latent_entropy_decl) = 1;
101932 + TREE_PUBLIC(latent_entropy_decl) = 1;
101933 + TREE_USED(latent_entropy_decl) = 1;
101934 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
101935 + DECL_EXTERNAL(latent_entropy_decl) = 1;
101936 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
101937 + DECL_INITIAL(latent_entropy_decl) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
101938 + lang_hooks.decls.pushdecl(latent_entropy_decl);
101939 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
101940 +// varpool_finalize_decl(latent_entropy_decl);
101941 +// varpool_mark_needed_node(latent_entropy_decl);
101942 +}
101943 +
101944 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101945 +{
101946 + const char * const plugin_name = plugin_info->base_name;
101947 + struct register_pass_info latent_entropy_pass_info = {
101948 + .pass = &latent_entropy_pass.pass,
101949 + .reference_pass_name = "optimized",
101950 + .ref_pass_instance_number = 1,
101951 + .pos_op = PASS_POS_INSERT_BEFORE
101952 + };
101953 +
101954 + if (!plugin_default_version_check(version, &gcc_version)) {
101955 + error(G_("incompatible gcc/plugin versions"));
101956 + return 1;
101957 + }
101958 +
101959 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
101960 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
101961 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
101962 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
101963 +
101964 + return 0;
101965 +}
101966 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
101967 new file mode 100644
101968 index 0000000..b04803b
101969 --- /dev/null
101970 +++ b/tools/gcc/size_overflow_hash.data
101971 @@ -0,0 +1,6350 @@
101972 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
101973 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
101974 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
101975 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
101976 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
101977 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
101978 +padzero_55 padzero 1 55 &sel_read_policyvers_55
101979 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
101980 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
101981 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
101982 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
101983 +load_msg_95 load_msg 2 95 NULL
101984 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
101985 +init_q_132 init_q 4 132 NULL
101986 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
101987 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
101988 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
101989 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
101990 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
101991 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
101992 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
101993 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
101994 +br_port_info_size_268 br_port_info_size 0 268 NULL
101995 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
101996 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
101997 +SYSC_connect_304 SYSC_connect 3 304 NULL
101998 +syslog_print_307 syslog_print 2 307 NULL
101999 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
102000 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
102001 +next_node_allowed_318 next_node_allowed 1 318 NULL
102002 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
102003 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
102004 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
102005 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
102006 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
102007 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
102008 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
102009 +pidlist_resize_496 pidlist_resize 2 496 NULL
102010 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
102011 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
102012 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
102013 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
102014 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
102015 +dle_count_543 dle_count 0 543 NULL
102016 +devres_alloc_551 devres_alloc 2 551 NULL
102017 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
102018 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
102019 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
102020 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
102021 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
102022 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
102023 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
102024 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
102025 +isp1760_register_628 isp1760_register 1-2 628 NULL
102026 +clone_split_bio_633 clone_split_bio 6 633 NULL
102027 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
102028 +remap_to_cache_640 remap_to_cache 3 640 NULL
102029 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
102030 +unlink_queued_645 unlink_queued 3-4 645 NULL
102031 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
102032 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
102033 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
102034 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
102035 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
102036 +disk_max_parts_719 disk_max_parts 0 719 NULL
102037 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
102038 +dvb_video_write_754 dvb_video_write 3 754 NULL
102039 +if_writecmd_815 if_writecmd 2 815 NULL
102040 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
102041 +read_fifo_826 read_fifo 3 826 NULL
102042 +um_idi_read_850 um_idi_read 3 850 NULL
102043 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
102044 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
102045 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
102046 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
102047 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
102048 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
102049 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
102050 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
102051 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
102052 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
102053 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
102054 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
102055 +_do_truncate_1019 _do_truncate 2 1019 NULL
102056 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
102057 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
102058 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
102059 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
102060 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
102061 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
102062 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
102063 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
102064 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
102065 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
102066 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
102067 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
102068 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
102069 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
102070 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
102071 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
102072 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
102073 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
102074 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
102075 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
102076 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
102077 +nested_get_page_1252 nested_get_page 2 1252 NULL
102078 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
102079 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
102080 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
102081 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
102082 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
102083 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
102084 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
102085 +ffs_1322 ffs 0 1322 NULL
102086 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
102087 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
102088 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
102089 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
102090 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
102091 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
102092 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
102093 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
102094 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
102095 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
102096 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
102097 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
102098 +zone_page_state_1393 zone_page_state 0 1393 NULL
102099 +file_read_actor_1401 file_read_actor 4 1401 NULL
102100 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
102101 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
102102 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
102103 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
102104 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
102105 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
102106 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
102107 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
102108 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
102109 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
102110 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
102111 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
102112 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
102113 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
102114 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
102115 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
102116 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
102117 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
102118 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
102119 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
102120 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
102121 +rmap_add_1677 rmap_add 3 1677 NULL
102122 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
102123 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
102124 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
102125 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
102126 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
102127 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
102128 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
102129 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
102130 +cosa_write_1774 cosa_write 3 1774 NULL
102131 +update_macheader_1775 update_macheader 7 1775 NULL
102132 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
102133 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
102134 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
102135 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
102136 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
102137 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
102138 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
102139 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
102140 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
102141 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
102142 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
102143 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
102144 +read_swap_header_1957 read_swap_header 0 1957 NULL
102145 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
102146 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
102147 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
102148 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
102149 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
102150 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
102151 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
102152 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
102153 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
102154 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
102155 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
102156 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
102157 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
102158 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
102159 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
102160 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
102161 +audit_expand_2098 audit_expand 2 2098 NULL
102162 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
102163 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
102164 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
102165 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
102166 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
102167 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
102168 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
102169 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
102170 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
102171 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
102172 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
102173 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
102174 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
102175 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
102176 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
102177 +vhci_write_2224 vhci_write 3 2224 NULL
102178 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
102179 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
102180 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
102181 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
102182 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
102183 +do_update_counters_2259 do_update_counters 4 2259 NULL
102184 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
102185 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
102186 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
102187 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
102188 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
102189 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
102190 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
102191 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
102192 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
102193 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
102194 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
102195 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
102196 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
102197 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
102198 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
102199 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
102200 +raid1_size_2419 raid1_size 0-2 2419 NULL
102201 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
102202 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
102203 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
102204 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
102205 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
102206 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
102207 +update_pmkid_2481 update_pmkid 4 2481 NULL
102208 +wiphy_new_2482 wiphy_new 2 2482 NULL
102209 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
102210 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
102211 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
102212 +dm_write_2513 dm_write 3 2513 NULL
102213 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
102214 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
102215 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
102216 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
102217 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
102218 +slot_bytes_2609 slot_bytes 0 2609 NULL
102219 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
102220 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
102221 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
102222 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
102223 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
102224 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
102225 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
102226 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
102227 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
102228 +__next_cpu_2782 __next_cpu 1 2782 NULL
102229 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
102230 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
102231 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
102232 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
102233 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
102234 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
102235 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
102236 +mq_map_2871 mq_map 2 2871 NULL
102237 +nla_padlen_2883 nla_padlen 1 2883 NULL
102238 +cmm_write_2896 cmm_write 3 2896 NULL
102239 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
102240 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
102241 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
102242 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
102243 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
102244 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
102245 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
102246 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
102247 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
102248 +depth_write_3021 depth_write 3 3021 NULL
102249 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
102250 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
102251 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
102252 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
102253 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
102254 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
102255 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
102256 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
102257 +free_coherent_3082 free_coherent 4-2 3082 NULL
102258 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
102259 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
102260 +rb_alloc_3102 rb_alloc 1 3102 NULL
102261 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
102262 +print_time_3132 print_time 0 3132 NULL
102263 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
102264 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
102265 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
102266 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
102267 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
102268 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
102269 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
102270 +alloc_context_3194 alloc_context 1 3194 NULL
102271 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
102272 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
102273 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
102274 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
102275 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
102276 +key_key_read_3241 key_key_read 3 3241 NULL
102277 +number_3243 number 0 3243 NULL
102278 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
102279 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
102280 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
102281 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
102282 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
102283 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
102284 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
102285 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
102286 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
102287 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
102288 +scnprintf_3360 scnprintf 0-2 3360 NULL
102289 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
102290 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
102291 +send_stream_3397 send_stream 4 3397 NULL
102292 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
102293 +msix_map_region_3411 msix_map_region 3 3411 NULL
102294 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
102295 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
102296 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
102297 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
102298 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
102299 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
102300 +map_single_3449 map_single 0-2 3449 NULL
102301 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
102302 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
102303 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
102304 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
102305 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
102306 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
102307 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
102308 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
102309 +SyS_readv_3539 SyS_readv 3 3539 NULL
102310 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
102311 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
102312 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
102313 +evtchn_read_3569 evtchn_read 3 3569 NULL
102314 +vc_resize_3585 vc_resize 2-3 3585 NULL
102315 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
102316 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
102317 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
102318 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
102319 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
102320 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
102321 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
102322 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
102323 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
102324 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
102325 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
102326 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
102327 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
102328 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
102329 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
102330 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
102331 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
102332 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
102333 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
102334 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
102335 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
102336 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
102337 +get_fd_set_3866 get_fd_set 1 3866 NULL
102338 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
102339 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
102340 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
102341 +nvram_write_3894 nvram_write 3 3894 NULL
102342 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
102343 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
102344 +vcs_write_3910 vcs_write 3 3910 NULL
102345 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
102346 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
102347 +do_add_counters_3992 do_add_counters 3 3992 NULL
102348 +userspace_status_4004 userspace_status 4 4004 NULL
102349 +mei_write_4005 mei_write 3 4005 NULL nohasharray
102350 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
102351 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
102352 +mm_populate_4016 mm_populate 1 4016 NULL
102353 +blk_end_request_4024 blk_end_request 3 4024 NULL
102354 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
102355 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
102356 +read_file_queues_4078 read_file_queues 3 4078 NULL
102357 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
102358 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
102359 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
102360 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
102361 +tm6000_read_4151 tm6000_read 3 4151 NULL
102362 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
102363 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
102364 +get_alua_req_4166 get_alua_req 3 4166 NULL
102365 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
102366 +read_file_bool_4180 read_file_bool 3 4180 NULL
102367 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
102368 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
102369 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
102370 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
102371 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
102372 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
102373 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
102374 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
102375 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
102376 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
102377 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
102378 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
102379 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
102380 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
102381 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
102382 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
102383 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
102384 +memparse_4444 memparse 0 4444 NULL
102385 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
102386 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
102387 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
102388 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
102389 +set_link_security_4502 set_link_security 4 4502 NULL
102390 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
102391 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
102392 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
102393 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
102394 +tty_register_device_4544 tty_register_device 2 4544 NULL
102395 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
102396 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
102397 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
102398 +bch_alloc_4593 bch_alloc 1 4593 NULL
102399 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
102400 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
102401 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
102402 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
102403 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
102404 +kone_receive_4690 kone_receive 4 4690 NULL
102405 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
102406 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
102407 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
102408 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
102409 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
102410 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
102411 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
102412 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
102413 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
102414 +create_subvol_4791 create_subvol 4 4791 NULL
102415 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
102416 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
102417 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
102418 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
102419 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
102420 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
102421 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
102422 +sys_ipc_4889 sys_ipc 3 4889 NULL
102423 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
102424 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
102425 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
102426 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
102427 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
102428 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
102429 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
102430 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
102431 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
102432 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
102433 +do_mincore_5018 do_mincore 0-1 5018 NULL
102434 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
102435 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
102436 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
102437 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
102438 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
102439 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
102440 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
102441 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
102442 +sound_write_5102 sound_write 3 5102 NULL
102443 +clear_dirty_5105 clear_dirty 3 5105 NULL
102444 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
102445 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
102446 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
102447 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
102448 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
102449 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
102450 +skb_network_header_5203 skb_network_header 0 5203 NULL
102451 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
102452 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
102453 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
102454 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
102455 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
102456 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
102457 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
102458 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
102459 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
102460 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
102461 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
102462 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
102463 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
102464 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
102465 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
102466 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
102467 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
102468 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
102469 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
102470 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
102471 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
102472 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
102473 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
102474 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
102475 +tty_write_5494 tty_write 3 5494 NULL
102476 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
102477 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
102478 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
102479 +spidev_message_5518 spidev_message 3 5518 NULL
102480 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
102481 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
102482 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
102483 +le_readq_5557 le_readq 0 5557 NULL
102484 +inw_5558 inw 0 5558 NULL
102485 +fir16_create_5574 fir16_create 3 5574 NULL
102486 +bioset_create_5580 bioset_create 1 5580 NULL
102487 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
102488 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
102489 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
102490 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
102491 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
102492 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
102493 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
102494 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
102495 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
102496 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
102497 +get_arg_5694 get_arg 3 5694 NULL
102498 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
102499 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
102500 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
102501 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
102502 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
102503 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
102504 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
102505 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
102506 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
102507 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
102508 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
102509 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
102510 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
102511 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
102512 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
102513 +setup_req_5848 setup_req 3 5848 NULL
102514 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
102515 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
102516 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
102517 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
102518 +port_show_regs_5904 port_show_regs 3 5904 NULL
102519 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
102520 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
102521 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
102522 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
102523 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
102524 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
102525 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
102526 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
102527 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
102528 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
102529 +native_pte_val_5978 native_pte_val 0 5978 NULL
102530 +SyS_semop_5980 SyS_semop 3 5980 NULL
102531 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
102532 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
102533 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
102534 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
102535 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
102536 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
102537 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
102538 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
102539 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
102540 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
102541 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
102542 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
102543 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
102544 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
102545 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
102546 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
102547 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
102548 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
102549 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
102550 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
102551 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
102552 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
102553 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
102554 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
102555 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
102556 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
102557 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
102558 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
102559 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
102560 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
102561 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
102562 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
102563 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
102564 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
102565 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
102566 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
102567 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
102568 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
102569 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
102570 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
102571 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
102572 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
102573 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
102574 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
102575 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
102576 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
102577 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
102578 +mei_read_6507 mei_read 3 6507 NULL
102579 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
102580 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
102581 +wdm_read_6549 wdm_read 3 6549 NULL
102582 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
102583 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
102584 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
102585 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
102586 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
102587 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
102588 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
102589 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
102590 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
102591 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
102592 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
102593 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
102594 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
102595 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
102596 +mpeg_read_6708 mpeg_read 3 6708 NULL
102597 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
102598 +video_proc_write_6724 video_proc_write 3 6724 NULL
102599 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
102600 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
102601 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
102602 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
102603 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
102604 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
102605 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
102606 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
102607 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
102608 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
102609 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
102610 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
102611 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
102612 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
102613 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
102614 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
102615 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
102616 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
102617 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
102618 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
102619 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
102620 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
102621 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
102622 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
102623 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
102624 +request_key_async_6990 request_key_async 4 6990 NULL
102625 +tpl_write_6998 tpl_write 3 6998 NULL
102626 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
102627 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
102628 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
102629 +wimax_msg_7030 wimax_msg 4 7030 NULL
102630 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
102631 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
102632 +event_enable_read_7074 event_enable_read 3 7074 NULL
102633 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
102634 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
102635 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
102636 +check_header_7108 check_header 0 7108 NULL
102637 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
102638 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
102639 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
102640 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
102641 +get_param_h_7247 get_param_h 0 7247 NULL
102642 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
102643 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
102644 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
102645 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
102646 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
102647 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
102648 +mgmt_control_7349 mgmt_control 3 7349 NULL
102649 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
102650 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
102651 +hweight_long_7388 hweight_long 0-1 7388 NULL
102652 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
102653 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
102654 +readb_7401 readb 0 7401 NULL
102655 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
102656 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
102657 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
102658 +numa_emulation_7466 numa_emulation 2 7466 NULL
102659 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
102660 +garp_request_join_7471 garp_request_join 4 7471 NULL
102661 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
102662 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
102663 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
102664 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
102665 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
102666 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
102667 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
102668 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
102669 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
102670 +groups_alloc_7614 groups_alloc 1 7614 NULL
102671 +sg_virt_7616 sg_virt 0 7616 NULL
102672 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
102673 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
102674 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
102675 +dev_write_7708 dev_write 3 7708 NULL
102676 +unmap_region_7709 unmap_region 1 7709 NULL
102677 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
102678 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
102679 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
102680 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
102681 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
102682 +ioread32be_7773 ioread32be 0 7773 NULL
102683 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
102684 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
102685 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
102686 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
102687 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
102688 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
102689 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
102690 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
102691 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
102692 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
102693 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
102694 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
102695 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
102696 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
102697 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
102698 +sys_mbind_7990 sys_mbind 5 7990 NULL
102699 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
102700 +vcs_read_8017 vcs_read 3 8017 NULL
102701 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
102702 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
102703 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
102704 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
102705 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
102706 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
102707 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
102708 +venus_lookup_8121 venus_lookup 4 8121 NULL
102709 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
102710 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
102711 +ore_truncate_8181 ore_truncate 3 8181 NULL
102712 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
102713 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
102714 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
102715 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
102716 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
102717 +play_iframe_8219 play_iframe 3 8219 NULL
102718 +create_log_8225 create_log 2 8225 NULL nohasharray
102719 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
102720 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
102721 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
102722 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
102723 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
102724 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
102725 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
102726 +init_cdev_8274 init_cdev 1 8274 NULL
102727 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
102728 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
102729 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
102730 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
102731 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
102732 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
102733 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
102734 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
102735 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
102736 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
102737 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
102738 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
102739 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
102740 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
102741 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
102742 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
102743 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
102744 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
102745 +dev_config_8506 dev_config 3 8506 NULL
102746 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
102747 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
102748 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
102749 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
102750 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
102751 +user_on_off_8552 user_on_off 2 8552 NULL
102752 +profile_remove_8556 profile_remove 3 8556 NULL
102753 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
102754 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
102755 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
102756 +tower_write_8580 tower_write 3 8580 NULL
102757 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
102758 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
102759 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
102760 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
102761 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
102762 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
102763 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
102764 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
102765 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
102766 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
102767 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
102768 +arcfb_write_8702 arcfb_write 3 8702 NULL
102769 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
102770 +init_header_8703 init_header 0 8703 &i_size_read_8703
102771 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
102772 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
102773 +f_dupfd_8730 f_dupfd 1 8730 NULL
102774 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
102775 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
102776 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
102777 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
102778 +sys_prctl_8766 sys_prctl 4 8766 NULL
102779 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
102780 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
102781 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
102782 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
102783 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
102784 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
102785 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
102786 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
102787 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
102788 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
102789 +clear_bitset_8840 clear_bitset 2 8840 NULL
102790 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
102791 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
102792 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
102793 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
102794 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
102795 +layout_commit_8926 layout_commit 3 8926 NULL
102796 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
102797 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
102798 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
102799 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
102800 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
102801 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
102802 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
102803 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
102804 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
102805 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
102806 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
102807 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
102808 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
102809 +nla_put_9042 nla_put 3 9042 NULL
102810 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
102811 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
102812 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
102813 +string_9080 string 0 9080 NULL
102814 +create_queues_9088 create_queues 2-3 9088 NULL
102815 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
102816 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
102817 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
102818 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
102819 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
102820 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
102821 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
102822 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
102823 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
102824 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
102825 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
102826 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
102827 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
102828 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
102829 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
102830 +get_pfn_9207 get_pfn 1 9207 NULL
102831 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
102832 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
102833 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
102834 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
102835 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
102836 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
102837 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
102838 +flakey_status_9274 flakey_status 5 9274 NULL
102839 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
102840 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
102841 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
102842 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
102843 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
102844 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
102845 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
102846 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
102847 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
102848 +read_9397 read 3 9397 NULL
102849 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
102850 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
102851 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
102852 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
102853 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
102854 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
102855 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
102856 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
102857 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
102858 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
102859 +lp_write_9511 lp_write 3 9511 NULL
102860 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
102861 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
102862 +read_file_dma_9530 read_file_dma 3 9530 NULL
102863 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
102864 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
102865 +fw_node_create_9559 fw_node_create 2 9559 NULL
102866 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
102867 +kobj_map_9566 kobj_map 2-3 9566 NULL
102868 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
102869 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
102870 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
102871 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
102872 +do_sync_9604 do_sync 1 9604 NULL
102873 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
102874 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
102875 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
102876 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
102877 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
102878 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
102879 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
102880 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
102881 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
102882 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
102883 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
102884 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
102885 +is_hole_9694 is_hole 2 9694 NULL nohasharray
102886 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
102887 +fnb_9703 fnb 2-3 9703 NULL
102888 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
102889 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
102890 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
102891 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
102892 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
102893 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
102894 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
102895 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
102896 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
102897 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
102898 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
102899 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
102900 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
102901 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
102902 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
102903 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
102904 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
102905 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
102906 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
102907 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
102908 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
102909 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
102910 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
102911 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
102912 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
102913 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
102914 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
102915 +read_file_misc_9948 read_file_misc 3 9948 NULL
102916 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
102917 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
102918 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
102919 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
102920 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
102921 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
102922 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
102923 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
102924 +handle_request_10024 handle_request 9 10024 NULL
102925 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
102926 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
102927 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
102928 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
102929 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
102930 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
102931 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
102932 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
102933 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
102934 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
102935 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
102936 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
102937 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
102938 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
102939 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
102940 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
102941 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
102942 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
102943 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
102944 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
102945 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
102946 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
102947 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
102948 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
102949 +read_emulate_10310 read_emulate 2-4 10310 NULL
102950 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
102951 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
102952 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
102953 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
102954 +get_dump_page_10338 get_dump_page 1 10338 NULL
102955 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
102956 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
102957 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
102958 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
102959 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
102960 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
102961 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
102962 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
102963 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
102964 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
102965 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
102966 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
102967 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
102968 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
102969 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
102970 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
102971 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
102972 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
102973 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
102974 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
102975 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
102976 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
102977 +otp_read_10594 otp_read 2-4-5 10594 NULL
102978 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
102979 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
102980 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
102981 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
102982 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
102983 +parport_write_10669 parport_write 0 10669 NULL
102984 +inl_10708 inl 0 10708 NULL nohasharray
102985 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
102986 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
102987 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
102988 +spi_sync_10731 spi_sync 0 10731 NULL
102989 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
102990 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
102991 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
102992 +sys_syslog_10746 sys_syslog 3 10746 NULL
102993 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
102994 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
102995 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
102996 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
102997 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
102998 +sys_bind_10799 sys_bind 3 10799 NULL
102999 +compat_put_int_10828 compat_put_int 1 10828 NULL
103000 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
103001 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
103002 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
103003 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
103004 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
103005 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
103006 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
103007 +get_scq_10897 get_scq 2 10897 NULL
103008 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
103009 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
103010 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
103011 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
103012 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
103013 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
103014 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
103015 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
103016 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
103017 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
103018 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
103019 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
103020 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
103021 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
103022 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
103023 +count_argc_11083 count_argc 0 11083 NULL
103024 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
103025 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
103026 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
103027 +page_offset_11120 page_offset 0 11120 NULL
103028 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
103029 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
103030 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
103031 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
103032 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
103033 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
103034 +__swab16p_11220 __swab16p 0 11220 NULL
103035 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
103036 +mmap_region_11247 mmap_region 0-2 11247 NULL
103037 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
103038 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
103039 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
103040 +cru_detect_11272 cru_detect 1 11272 NULL
103041 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
103042 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
103043 +construct_key_11329 construct_key 3 11329 NULL nohasharray
103044 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
103045 +next_segment_11330 next_segment 0-2-1 11330 NULL
103046 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
103047 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
103048 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
103049 +sel_write_create_11353 sel_write_create 3 11353 NULL
103050 +handle_unit_11355 handle_unit 0-1 11355 NULL
103051 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
103052 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
103053 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
103054 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
103055 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
103056 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
103057 +str_to_user_11411 str_to_user 2 11411 NULL
103058 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
103059 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
103060 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
103061 +trace_options_read_11419 trace_options_read 3 11419 NULL
103062 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
103063 +prepare_image_11424 prepare_image 0 11424 NULL
103064 +vring_size_11426 vring_size 0-1-2 11426 NULL
103065 +bttv_read_11432 bttv_read 3 11432 NULL
103066 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
103067 +swp_offset_11475 swp_offset 0 11475 NULL
103068 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
103069 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
103070 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
103071 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
103072 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
103073 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
103074 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
103075 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
103076 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
103077 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
103078 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
103079 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
103080 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
103081 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
103082 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
103083 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
103084 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
103085 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
103086 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
103087 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
103088 +split_11691 split 2 11691 NULL
103089 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
103090 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
103091 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
103092 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
103093 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
103094 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
103095 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
103096 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
103097 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
103098 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
103099 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
103100 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
103101 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
103102 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
103103 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
103104 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
103105 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
103106 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
103107 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
103108 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
103109 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
103110 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
103111 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
103112 +atmel_read16_11981 atmel_read16 0 11981 NULL
103113 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
103114 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
103115 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
103116 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
103117 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
103118 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
103119 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
103120 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
103121 +set_powered_12129 set_powered 4 12129 NULL
103122 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
103123 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
103124 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
103125 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
103126 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
103127 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
103128 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
103129 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
103130 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
103131 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
103132 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
103133 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
103134 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
103135 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
103136 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
103137 +scaled_div_12201 scaled_div 1-2 12201 NULL
103138 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
103139 +receive_copy_12216 receive_copy 3 12216 NULL
103140 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
103141 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
103142 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
103143 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
103144 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
103145 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
103146 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
103147 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
103148 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
103149 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
103150 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
103151 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
103152 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
103153 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
103154 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
103155 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
103156 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
103157 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
103158 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
103159 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
103160 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
103161 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
103162 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
103163 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
103164 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
103165 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
103166 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
103167 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
103168 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
103169 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
103170 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
103171 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
103172 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
103173 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
103174 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
103175 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
103176 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
103177 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
103178 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
103179 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
103180 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
103181 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
103182 +wb_create_12651 wb_create 1 12651 NULL
103183 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
103184 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
103185 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
103186 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
103187 +ivtv_write_12721 ivtv_write 3 12721 NULL
103188 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
103189 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
103190 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
103191 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
103192 +listxattr_12769 listxattr 3 12769 NULL
103193 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
103194 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
103195 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
103196 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
103197 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
103198 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
103199 +readq_12825 readq 0 12825 NULL
103200 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
103201 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
103202 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
103203 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
103204 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
103205 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
103206 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
103207 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
103208 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
103209 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
103210 +bm_status_write_12964 bm_status_write 3 12964 NULL
103211 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
103212 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
103213 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
103214 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
103215 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
103216 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
103217 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
103218 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
103219 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
103220 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
103221 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
103222 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
103223 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
103224 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
103225 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
103226 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
103227 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
103228 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
103229 +blk_update_request_13146 blk_update_request 3 13146 NULL
103230 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
103231 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
103232 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
103233 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
103234 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
103235 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
103236 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
103237 +comedi_read_13199 comedi_read 3 13199 NULL
103238 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
103239 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
103240 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
103241 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
103242 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
103243 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
103244 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
103245 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
103246 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
103247 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
103248 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
103249 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
103250 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
103251 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
103252 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
103253 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
103254 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
103255 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
103256 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
103257 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
103258 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
103259 +cache_ctr_13364 cache_ctr 2 13364 NULL
103260 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
103261 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
103262 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
103263 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
103264 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
103265 +sky2_receive_13407 sky2_receive 2 13407 NULL
103266 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
103267 +keyring_read_13438 keyring_read 3 13438 NULL
103268 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
103269 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
103270 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
103271 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
103272 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
103273 +core_status_13515 core_status 4 13515 NULL
103274 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
103275 +bm_init_13529 bm_init 2 13529 NULL
103276 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
103277 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
103278 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
103279 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
103280 +sys_madvise_13569 sys_madvise 1 13569 NULL
103281 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
103282 +cache_write_13589 cache_write 3 13589 NULL
103283 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
103284 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
103285 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
103286 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
103287 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
103288 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
103289 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
103290 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
103291 +packet_snd_13634 packet_snd 3 13634 NULL
103292 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
103293 +cache_downcall_13666 cache_downcall 3 13666 NULL
103294 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
103295 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
103296 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
103297 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
103298 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
103299 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
103300 +random_read_13815 random_read 3 13815 NULL
103301 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
103302 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
103303 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
103304 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
103305 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
103306 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
103307 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
103308 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
103309 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
103310 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
103311 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
103312 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
103313 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
103314 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
103315 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
103316 +com90xx_found_13974 com90xx_found 3 13974 NULL
103317 +qcam_read_13977 qcam_read 3 13977 NULL
103318 +dsp_read_13980 dsp_read 2 13980 NULL
103319 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
103320 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
103321 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
103322 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
103323 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
103324 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
103325 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
103326 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
103327 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
103328 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
103329 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
103330 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
103331 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
103332 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
103333 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
103334 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
103335 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
103336 +em_canid_change_14150 em_canid_change 3 14150 NULL
103337 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
103338 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
103339 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
103340 +alloc_async_14208 alloc_async 1 14208 NULL
103341 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
103342 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
103343 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
103344 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
103345 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
103346 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
103347 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
103348 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
103349 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
103350 +rr_status_14293 rr_status 5 14293 NULL
103351 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
103352 +oo_objects_14319 oo_objects 0 14319 NULL
103353 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
103354 +scsi2int_14358 scsi2int 0 14358 NULL
103355 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
103356 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
103357 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
103358 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
103359 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
103360 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
103361 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
103362 +block_size_14443 block_size 0 14443 NULL
103363 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
103364 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
103365 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
103366 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
103367 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
103368 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
103369 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
103370 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
103371 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
103372 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
103373 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
103374 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
103375 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
103376 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
103377 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
103378 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
103379 +dbJoin_14644 dbJoin 0 14644 NULL
103380 +profile_replace_14652 profile_replace 3 14652 NULL
103381 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
103382 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
103383 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
103384 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
103385 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
103386 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
103387 +get_bio_block_14714 get_bio_block 0 14714 NULL
103388 +vfd_write_14717 vfd_write 3 14717 NULL
103389 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
103390 +raid1_resize_14740 raid1_resize 2 14740 NULL
103391 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
103392 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
103393 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
103394 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
103395 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
103396 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
103397 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
103398 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
103399 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
103400 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
103401 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
103402 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
103403 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
103404 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
103405 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
103406 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
103407 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
103408 +unifi_read_14899 unifi_read 3 14899 NULL
103409 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
103410 +krealloc_14908 krealloc 2 14908 NULL
103411 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
103412 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
103413 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
103414 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
103415 +queue_cnt_14951 queue_cnt 0 14951 NULL
103416 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
103417 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
103418 +setkey_14987 setkey 3 14987 NULL nohasharray
103419 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
103420 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
103421 +vmap_15025 vmap 2 15025 NULL
103422 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
103423 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
103424 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
103425 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
103426 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
103427 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
103428 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
103429 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
103430 +start_port_15124 start_port 0 15124 NULL
103431 +memchr_15126 memchr 0 15126 NULL
103432 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
103433 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
103434 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
103435 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
103436 +reserve_resources_15194 reserve_resources 3 15194 NULL
103437 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
103438 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
103439 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
103440 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
103441 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
103442 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
103443 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
103444 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
103445 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
103446 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
103447 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
103448 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
103449 +ioread16_15342 ioread16 0 15342 NULL
103450 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
103451 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
103452 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
103453 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
103454 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
103455 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
103456 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
103457 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
103458 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
103459 +get_modalias_15406 get_modalias 2 15406 NULL
103460 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
103461 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
103462 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
103463 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
103464 +memweight_15450 memweight 2 15450 NULL
103465 +vmalloc_15464 vmalloc 1 15464 NULL
103466 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
103467 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
103468 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
103469 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
103470 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
103471 +persistent_status_15574 persistent_status 4 15574 NULL
103472 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
103473 +vme_user_write_15587 vme_user_write 3 15587 NULL
103474 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
103475 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
103476 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
103477 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
103478 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
103479 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
103480 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
103481 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
103482 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
103483 +fs_path_add_15648 fs_path_add 3 15648 NULL
103484 +xsd_read_15653 xsd_read 3 15653 NULL
103485 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
103486 +unix_bind_15668 unix_bind 3 15668 NULL
103487 +dm_read_15674 dm_read 3 15674 NULL
103488 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
103489 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
103490 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
103491 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
103492 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
103493 +do_test_15766 do_test 1 15766 NULL
103494 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
103495 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
103496 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
103497 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
103498 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
103499 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
103500 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
103501 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
103502 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
103503 +table_size_15851 table_size 0-1-2 15851 NULL
103504 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
103505 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
103506 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
103507 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
103508 +native_read_msr_15905 native_read_msr 0 15905 NULL
103509 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
103510 +power_read_15939 power_read 3 15939 NULL
103511 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
103512 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
103513 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
103514 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
103515 +frame_alloc_15981 frame_alloc 4 15981 NULL
103516 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
103517 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
103518 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
103519 +got_frame_16028 got_frame 2 16028 NULL
103520 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
103521 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
103522 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
103523 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
103524 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
103525 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
103526 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
103527 +fsm_init_16134 fsm_init 2 16134 NULL
103528 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
103529 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
103530 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
103531 +mapping_level_16188 mapping_level 2 16188 NULL
103532 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
103533 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
103534 +create_table_16213 create_table 2 16213 NULL
103535 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
103536 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
103537 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
103538 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
103539 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
103540 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
103541 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
103542 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
103543 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
103544 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
103545 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
103546 +account_16283 account 0-2-4 16283 NULL nohasharray
103547 +mirror_status_16283 mirror_status 5 16283 &account_16283
103548 +retry_instruction_16285 retry_instruction 2 16285 NULL
103549 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
103550 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
103551 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
103552 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
103553 +wb_map_16301 wb_map 2 16301 NULL
103554 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
103555 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
103556 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
103557 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
103558 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
103559 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
103560 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
103561 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
103562 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
103563 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
103564 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
103565 +raid10_resize_16537 raid10_resize 2 16537 NULL
103566 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
103567 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
103568 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
103569 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
103570 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
103571 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
103572 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
103573 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
103574 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
103575 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
103576 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
103577 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
103578 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
103579 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
103580 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
103581 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
103582 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
103583 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
103584 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
103585 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
103586 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
103587 +st_write_16874 st_write 3 16874 NULL
103588 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
103589 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
103590 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
103591 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
103592 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
103593 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
103594 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
103595 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
103596 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
103597 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
103598 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
103599 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
103600 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
103601 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
103602 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
103603 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
103604 +mac_address_string_17091 mac_address_string 0 17091 NULL
103605 +entry_length_17093 entry_length 0 17093 NULL
103606 +sys_preadv_17100 sys_preadv 3 17100 NULL
103607 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
103608 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
103609 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
103610 +sep_read_17161 sep_read 3 17161 NULL
103611 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
103612 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
103613 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
103614 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
103615 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
103616 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
103617 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
103618 +to_oblock_17254 to_oblock 0-1 17254 NULL
103619 +unpack_value_17259 unpack_value 1 17259 NULL
103620 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
103621 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
103622 +alloc_ep_17269 alloc_ep 1 17269 NULL
103623 +pg_read_17276 pg_read 3 17276 NULL
103624 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
103625 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
103626 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
103627 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
103628 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
103629 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
103630 +skb_pad_17302 skb_pad 2 17302 NULL
103631 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
103632 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
103633 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
103634 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
103635 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
103636 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
103637 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
103638 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
103639 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
103640 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
103641 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
103642 +compat_cmd_17465 compat_cmd 2 17465 NULL
103643 +probe_bios_17467 probe_bios 1 17467 NULL
103644 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
103645 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
103646 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
103647 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
103648 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
103649 +copy_from_user_17559 copy_from_user 3 17559 NULL
103650 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
103651 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
103652 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
103653 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
103654 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
103655 +osst_execute_17607 osst_execute 7-6 17607 NULL
103656 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
103657 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
103658 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
103659 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
103660 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
103661 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
103662 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
103663 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
103664 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
103665 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
103666 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
103667 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
103668 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
103669 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
103670 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
103671 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
103672 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
103673 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
103674 +perf_clock_17787 perf_clock 0 17787 NULL
103675 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
103676 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
103677 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
103678 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
103679 +count_leafs_17842 count_leafs 0 17842 NULL
103680 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
103681 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
103682 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
103683 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
103684 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
103685 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
103686 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
103687 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
103688 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
103689 +recover_head_17904 recover_head 3 17904 NULL
103690 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
103691 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
103692 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
103693 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
103694 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
103695 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
103696 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
103697 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
103698 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
103699 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
103700 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
103701 +fill_read_18019 fill_read 0 18019 NULL
103702 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
103703 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
103704 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
103705 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
103706 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
103707 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
103708 +packet_came_18072 packet_came 3 18072 NULL
103709 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
103710 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
103711 +get_vm_area_18080 get_vm_area 1 18080 NULL
103712 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
103713 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
103714 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
103715 +svc_getnl_18120 svc_getnl 0 18120 NULL
103716 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
103717 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
103718 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
103719 +_has_tag_18169 _has_tag 2 18169 NULL
103720 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
103721 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
103722 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
103723 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
103724 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
103725 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
103726 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
103727 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
103728 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
103729 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
103730 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
103731 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
103732 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
103733 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
103734 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
103735 +um_idi_write_18293 um_idi_write 3 18293 NULL
103736 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
103737 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
103738 +vga_r_18310 vga_r 0 18310 NULL
103739 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
103740 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
103741 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
103742 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
103743 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
103744 +ep_io_18367 ep_io 0 18367 NULL
103745 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
103746 +ci_role_write_18388 ci_role_write 3 18388 NULL
103747 +__video_register_device_18399 __video_register_device 3 18399 NULL
103748 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
103749 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
103750 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
103751 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
103752 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
103753 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
103754 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
103755 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
103756 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
103757 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
103758 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
103759 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
103760 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
103761 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
103762 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
103763 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
103764 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
103765 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
103766 +debug_output_18575 debug_output 3 18575 NULL
103767 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
103768 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
103769 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
103770 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
103771 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
103772 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
103773 +from_buffer_18625 from_buffer 3 18625 NULL
103774 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
103775 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
103776 +unmap_page_18665 unmap_page 2-3 18665 NULL
103777 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
103778 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
103779 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
103780 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
103781 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
103782 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
103783 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
103784 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
103785 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
103786 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
103787 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
103788 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
103789 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
103790 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
103791 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
103792 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
103793 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
103794 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
103795 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
103796 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
103797 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
103798 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
103799 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
103800 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
103801 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
103802 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
103803 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
103804 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
103805 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
103806 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
103807 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
103808 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
103809 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
103810 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
103811 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
103812 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
103813 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
103814 +huge_page_size_19008 huge_page_size 0 19008 NULL
103815 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
103816 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
103817 +revalidate_19043 revalidate 2 19043 NULL
103818 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
103819 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
103820 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
103821 +msix_map_region_19072 msix_map_region 2 19072 NULL
103822 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
103823 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
103824 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
103825 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
103826 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
103827 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
103828 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
103829 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
103830 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
103831 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
103832 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
103833 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
103834 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
103835 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
103836 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
103837 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
103838 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
103839 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
103840 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
103841 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
103842 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
103843 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
103844 +qc_capture_19298 qc_capture 3 19298 NULL
103845 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
103846 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
103847 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
103848 +debug_read_19322 debug_read 3 19322 NULL
103849 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
103850 +closure_sub_19359 closure_sub 2 19359 NULL
103851 +read_zero_19366 read_zero 3 19366 NULL
103852 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
103853 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
103854 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
103855 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
103856 +__phys_addr_19434 __phys_addr 0 19434 NULL
103857 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
103858 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
103859 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
103860 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
103861 +sky2_read16_19475 sky2_read16 0 19475 NULL
103862 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
103863 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
103864 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
103865 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
103866 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
103867 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
103868 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
103869 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
103870 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
103871 +nfsd_read_19568 nfsd_read 5 19568 NULL
103872 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
103873 +bm_status_read_19583 bm_status_read 3 19583 NULL
103874 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
103875 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
103876 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
103877 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
103878 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
103879 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
103880 +bio_detain_19690 bio_detain 2 19690 NULL
103881 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
103882 +read_reg_19723 read_reg 0 19723 NULL
103883 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
103884 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
103885 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
103886 +p9_client_read_19750 p9_client_read 5 19750 NULL
103887 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
103888 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
103889 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
103890 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
103891 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
103892 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
103893 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
103894 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
103895 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
103896 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
103897 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
103898 +__nla_put_19857 __nla_put 3 19857 NULL
103899 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
103900 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
103901 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
103902 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
103903 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
103904 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
103905 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
103906 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
103907 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
103908 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
103909 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
103910 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
103911 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
103912 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
103913 +team_options_register_20091 team_options_register 3 20091 NULL
103914 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
103915 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
103916 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
103917 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
103918 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
103919 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
103920 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
103921 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
103922 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
103923 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
103924 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
103925 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
103926 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
103927 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
103928 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
103929 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
103930 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
103931 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
103932 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
103933 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
103934 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
103935 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
103936 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
103937 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
103938 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
103939 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
103940 +read_buf_20469 read_buf 2 20469 NULL
103941 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
103942 +fast_user_write_20494 fast_user_write 5 20494 NULL
103943 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
103944 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
103945 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
103946 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
103947 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
103948 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
103949 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
103950 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
103951 +venus_create_20555 venus_create 4 20555 NULL
103952 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
103953 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
103954 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
103955 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
103956 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
103957 +lirc_write_20604 lirc_write 3 20604 NULL
103958 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
103959 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
103960 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
103961 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
103962 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
103963 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
103964 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
103965 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
103966 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
103967 +cpumask_size_20683 cpumask_size 0 20683 NULL
103968 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
103969 +gru_vtop_20689 gru_vtop 2 20689 NULL
103970 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
103971 +__maestro_read_20700 __maestro_read 0 20700 NULL
103972 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
103973 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
103974 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
103975 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
103976 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
103977 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
103978 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
103979 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
103980 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
103981 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
103982 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
103983 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
103984 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
103985 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
103986 +sys_sendto_20809 sys_sendto 6 20809 NULL
103987 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
103988 +strndup_user_20819 strndup_user 2 20819 NULL
103989 +calc_layout_20829 calc_layout 3 20829 NULL
103990 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
103991 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
103992 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
103993 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
103994 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
103995 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
103996 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
103997 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
103998 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
103999 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
104000 +htable_bits_20933 htable_bits 0 20933 NULL
104001 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
104002 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
104003 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
104004 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
104005 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
104006 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
104007 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
104008 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
104009 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
104010 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
104011 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
104012 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
104013 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
104014 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
104015 +multipath_status_21094 multipath_status 5 21094 NULL
104016 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
104017 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
104018 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
104019 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
104020 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
104021 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
104022 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
104023 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
104024 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
104025 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
104026 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
104027 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
104028 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
104029 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
104030 +input_ff_create_21240 input_ff_create 2 21240 NULL
104031 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
104032 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
104033 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
104034 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
104035 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
104036 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
104037 +add_res_range_21310 add_res_range 4 21310 NULL
104038 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
104039 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
104040 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
104041 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
104042 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
104043 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
104044 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
104045 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
104046 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
104047 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
104048 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
104049 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
104050 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
104051 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
104052 +concat_writev_21451 concat_writev 3 21451 NULL
104053 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
104054 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
104055 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
104056 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
104057 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
104058 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
104059 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
104060 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
104061 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
104062 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
104063 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
104064 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
104065 +validate_nnode_21638 validate_nnode 0 21638 NULL
104066 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
104067 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
104068 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
104069 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
104070 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
104071 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
104072 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
104073 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
104074 +vm_brk_21739 vm_brk 1 21739 NULL
104075 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
104076 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
104077 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
104078 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
104079 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
104080 +min_odd_21802 min_odd 0 21802 NULL
104081 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
104082 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
104083 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
104084 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
104085 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
104086 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
104087 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
104088 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
104089 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
104090 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
104091 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
104092 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
104093 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
104094 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
104095 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
104096 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
104097 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
104098 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
104099 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
104100 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
104101 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
104102 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
104103 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
104104 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
104105 +write_opcode_22082 write_opcode 2 22082 NULL
104106 +mem_rw_22085 mem_rw 3 22085 NULL
104107 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
104108 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
104109 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
104110 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
104111 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
104112 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
104113 +compat_insn_22142 compat_insn 2 22142 NULL
104114 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
104115 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
104116 +fls_22210 fls 0 22210 NULL
104117 +mem_write_22232 mem_write 3 22232 NULL
104118 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
104119 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
104120 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
104121 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
104122 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
104123 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
104124 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
104125 +extend_brk_22301 extend_brk 0 22301 NULL
104126 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
104127 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
104128 +get_segment_base_22324 get_segment_base 0 22324 NULL
104129 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
104130 +atomic_read_22342 atomic_read 0 22342 NULL
104131 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
104132 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
104133 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
104134 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
104135 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
104136 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
104137 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
104138 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
104139 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
104140 +zoran_write_22404 zoran_write 3 22404 NULL
104141 +queue_reply_22416 queue_reply 3 22416 NULL
104142 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
104143 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
104144 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
104145 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
104146 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
104147 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
104148 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
104149 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
104150 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
104151 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
104152 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
104153 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
104154 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
104155 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
104156 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
104157 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
104158 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
104159 +snapshot_read_22601 snapshot_read 3 22601 NULL
104160 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
104161 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
104162 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
104163 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
104164 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
104165 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
104166 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
104167 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
104168 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
104169 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
104170 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
104171 +map_22700 map 2 22700 NULL
104172 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
104173 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
104174 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
104175 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
104176 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
104177 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
104178 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
104179 +print_frame_22769 print_frame 0 22769 NULL
104180 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
104181 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
104182 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
104183 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
104184 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
104185 +create_attr_set_22861 create_attr_set 1 22861 NULL
104186 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
104187 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
104188 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
104189 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
104190 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
104191 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
104192 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
104193 +vme_get_size_22964 vme_get_size 0 22964 NULL
104194 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
104195 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
104196 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
104197 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
104198 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
104199 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
104200 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
104201 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
104202 +st_status_23032 st_status 5 23032 NULL
104203 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
104204 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
104205 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
104206 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
104207 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
104208 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
104209 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
104210 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
104211 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
104212 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
104213 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
104214 +fls_long_23096 fls_long 0 23096 NULL
104215 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
104216 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
104217 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
104218 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
104219 +__clear_user_23118 __clear_user 0 23118 NULL
104220 +dm_write_async_23120 dm_write_async 3 23120 NULL
104221 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
104222 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
104223 +read_file_ani_23161 read_file_ani 3 23161 NULL
104224 +ioremap_23172 ioremap 1-2 23172 NULL
104225 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
104226 +usblp_write_23178 usblp_write 3 23178 NULL
104227 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
104228 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
104229 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
104230 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
104231 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
104232 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
104233 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
104234 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
104235 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
104236 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
104237 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
104238 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
104239 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
104240 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
104241 +doc_probe_23285 doc_probe 1 23285 NULL
104242 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
104243 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
104244 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
104245 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
104246 +page_readlink_23346 page_readlink 3 23346 NULL
104247 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
104248 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
104249 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
104250 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
104251 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
104252 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
104253 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
104254 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
104255 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
104256 +event_filter_read_23494 event_filter_read 3 23494 NULL
104257 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
104258 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
104259 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
104260 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
104261 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
104262 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
104263 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
104264 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
104265 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
104266 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
104267 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
104268 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
104269 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
104270 +sInW_23663 sInW 0 23663 NULL
104271 +SyS_connect_23669 SyS_connect 3 23669 NULL
104272 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
104273 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
104274 +cx18_read_23699 cx18_read 3 23699 NULL
104275 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
104276 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
104277 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
104278 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
104279 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
104280 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
104281 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
104282 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
104283 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
104284 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
104285 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
104286 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
104287 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
104288 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
104289 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
104290 +p54_init_common_23850 p54_init_common 1 23850 NULL
104291 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
104292 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
104293 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
104294 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
104295 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
104296 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
104297 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
104298 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
104299 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
104300 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
104301 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
104302 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
104303 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
104304 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
104305 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
104306 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
104307 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
104308 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
104309 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
104310 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
104311 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
104312 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
104313 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
104314 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
104315 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
104316 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
104317 +mpu401_read_24126 mpu401_read 3 24126 NULL
104318 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
104319 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
104320 +set_discard_24162 set_discard 2 24162 NULL
104321 +adu_read_24177 adu_read 3 24177 NULL
104322 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
104323 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
104324 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
104325 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
104326 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
104327 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
104328 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
104329 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
104330 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
104331 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
104332 +thin_status_24278 thin_status 5 24278 NULL
104333 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
104334 +msg_size_24288 msg_size 0 24288 NULL
104335 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
104336 +map_page_24298 map_page 3-4 24298 NULL
104337 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
104338 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
104339 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
104340 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
104341 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
104342 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
104343 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
104344 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
104345 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
104346 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
104347 +igetword_24373 igetword 0 24373 NULL
104348 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
104349 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
104350 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
104351 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
104352 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
104353 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
104354 +smk_user_access_24440 smk_user_access 3 24440 NULL
104355 +page_address_24444 page_address 0 24444 NULL
104356 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
104357 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
104358 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
104359 +pd_video_read_24510 pd_video_read 3 24510 NULL
104360 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
104361 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
104362 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
104363 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
104364 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
104365 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
104366 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
104367 +count_preds_24600 count_preds 0 24600 NULL
104368 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
104369 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
104370 +context_alloc_24645 context_alloc 3 24645 NULL
104371 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
104372 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
104373 +read_fs_24717 read_fs 0 24717 NULL
104374 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
104375 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
104376 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
104377 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
104378 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
104379 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
104380 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
104381 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
104382 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
104383 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
104384 +cache_read_24790 cache_read 3 24790 NULL
104385 +unpack_str_24798 unpack_str 0 24798 NULL
104386 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
104387 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
104388 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
104389 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
104390 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
104391 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
104392 +setup_buffering_24872 setup_buffering 3 24872 NULL
104393 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
104394 +queues_read_24877 queues_read 3 24877 NULL nohasharray
104395 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
104396 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
104397 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
104398 +next_token_24929 next_token 0 24929 NULL
104399 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
104400 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
104401 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
104402 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
104403 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
104404 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
104405 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
104406 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
104407 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
104408 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
104409 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
104410 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
104411 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
104412 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
104413 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
104414 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
104415 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
104416 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
104417 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
104418 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
104419 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
104420 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
104421 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
104422 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
104423 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
104424 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
104425 +stripe_status_25259 stripe_status 5 25259 NULL
104426 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
104427 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
104428 +vfs_writev_25278 vfs_writev 3 25278 NULL
104429 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
104430 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
104431 +help_25316 help 5 25316 NULL nohasharray
104432 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
104433 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
104434 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
104435 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
104436 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
104437 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
104438 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
104439 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
104440 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
104441 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
104442 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
104443 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
104444 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
104445 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
104446 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
104447 +sb_permission_25523 sb_permission 0 25523 NULL
104448 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
104449 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
104450 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
104451 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
104452 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
104453 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
104454 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
104455 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
104456 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
104457 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
104458 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
104459 +__direct_map_25647 __direct_map 5-6 25647 NULL
104460 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
104461 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
104462 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
104463 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
104464 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
104465 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
104466 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
104467 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
104468 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
104469 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
104470 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
104471 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
104472 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
104473 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
104474 +sg_read_25799 sg_read 3 25799 NULL
104475 +system_enable_read_25815 system_enable_read 3 25815 NULL
104476 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
104477 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
104478 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
104479 +parport_read_25855 parport_read 0 25855 NULL
104480 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
104481 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
104482 +key_attr_size_25865 key_attr_size 0 25865 NULL
104483 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
104484 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
104485 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
104486 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
104487 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
104488 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
104489 +rcname_read_25919 rcname_read 3 25919 NULL
104490 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
104491 +key_flags_read_25931 key_flags_read 3 25931 NULL
104492 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
104493 +flush_25957 flush 2 25957 NULL
104494 +video_register_device_25971 video_register_device 3 25971 NULL
104495 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
104496 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
104497 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
104498 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
104499 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
104500 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
104501 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
104502 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
104503 +tun_do_read_26047 tun_do_read 5 26047 NULL
104504 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
104505 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
104506 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
104507 +skb_cow_26138 skb_cow 2 26138 NULL
104508 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
104509 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
104510 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
104511 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
104512 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
104513 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
104514 +disk_devt_26180 disk_devt 0 26180 NULL
104515 +get_registers_26187 get_registers 3 26187 NULL
104516 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
104517 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
104518 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
104519 +mce_write_26201 mce_write 3 26201 NULL
104520 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
104521 +bio_split_26235 bio_split 2 26235 NULL
104522 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
104523 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
104524 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
104525 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
104526 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
104527 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
104528 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
104529 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
104530 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
104531 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
104532 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
104533 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
104534 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
104535 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
104536 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
104537 +read_vmcore_26501 read_vmcore 3 26501 NULL
104538 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
104539 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
104540 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
104541 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
104542 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
104543 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
104544 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
104545 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
104546 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
104547 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
104548 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
104549 +pack_value_26625 pack_value 1 26625 NULL
104550 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
104551 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
104552 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
104553 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
104554 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
104555 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
104556 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
104557 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
104558 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
104559 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
104560 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
104561 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
104562 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
104563 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
104564 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
104565 +smk_write_load_26829 smk_write_load 3 26829 NULL
104566 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
104567 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
104568 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
104569 +scnprint_id_26842 scnprint_id 3 26842 NULL
104570 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
104571 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
104572 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
104573 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
104574 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
104575 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
104576 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
104577 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
104578 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
104579 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
104580 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
104581 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
104582 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
104583 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
104584 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
104585 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
104586 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
104587 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
104588 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
104589 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
104590 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
104591 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
104592 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
104593 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
104594 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
104595 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
104596 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
104597 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
104598 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
104599 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
104600 +pms_capture_27142 pms_capture 4 27142 NULL
104601 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
104602 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
104603 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
104604 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
104605 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
104606 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
104607 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
104608 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
104609 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
104610 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
104611 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
104612 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
104613 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
104614 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
104615 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
104616 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
104617 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
104618 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
104619 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
104620 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
104621 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
104622 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
104623 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
104624 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
104625 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
104626 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
104627 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
104628 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
104629 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
104630 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
104631 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
104632 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
104633 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
104634 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
104635 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
104636 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
104637 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
104638 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
104639 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
104640 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
104641 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
104642 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
104643 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
104644 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
104645 +qword_get_27670 qword_get 0 27670 NULL
104646 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
104647 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
104648 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
104649 +evm_write_key_27715 evm_write_key 3 27715 NULL
104650 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
104651 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
104652 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
104653 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
104654 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
104655 +kcalloc_27770 kcalloc 1-2 27770 NULL
104656 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
104657 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
104658 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
104659 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
104660 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
104661 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
104662 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
104663 +read_profile_27859 read_profile 3 27859 NULL
104664 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
104665 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
104666 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
104667 +gluebi_write_27905 gluebi_write 3 27905 NULL
104668 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
104669 +bm_find_next_27929 bm_find_next 2 27929 NULL
104670 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
104671 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
104672 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
104673 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
104674 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
104675 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
104676 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
104677 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
104678 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
104679 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
104680 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
104681 +pool_status_28055 pool_status 5 28055 NULL
104682 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
104683 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
104684 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
104685 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
104686 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
104687 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
104688 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
104689 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
104690 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
104691 +video_read_28148 video_read 3 28148 NULL
104692 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
104693 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
104694 +vread_28173 vread 0 28173 NULL
104695 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
104696 +d_path_28198 d_path 0 28198 NULL
104697 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
104698 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
104699 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
104700 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
104701 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
104702 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
104703 +usemap_size_28281 usemap_size 0 28281 NULL
104704 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
104705 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
104706 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
104707 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
104708 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
104709 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
104710 +snapshot_write_28351 snapshot_write 3 28351 NULL
104711 +sys_writev_28384 sys_writev 3 28384 NULL
104712 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
104713 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
104714 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
104715 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
104716 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
104717 +__split_large_page_28429 __split_large_page 2 28429 NULL
104718 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
104719 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
104720 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
104721 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
104722 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
104723 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
104724 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
104725 +max_response_pages_28492 max_response_pages 0 28492 NULL
104726 +clear_discard_28494 clear_discard 2 28494 NULL
104727 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
104728 +__next_node_28521 __next_node 1 28521 NULL
104729 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
104730 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
104731 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
104732 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
104733 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
104734 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
104735 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
104736 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
104737 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
104738 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
104739 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
104740 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
104741 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
104742 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
104743 +_set_range_28627 _set_range 3 28627 NULL
104744 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
104745 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
104746 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
104747 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
104748 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
104749 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
104750 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
104751 +spi_execute_28736 spi_execute 5 28736 NULL
104752 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
104753 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
104754 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
104755 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
104756 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
104757 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
104758 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
104759 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
104760 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
104761 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
104762 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
104763 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
104764 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
104765 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
104766 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
104767 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
104768 +to_cblock_28899 to_cblock 0-1 28899 NULL
104769 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
104770 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
104771 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
104772 +push_rx_28939 push_rx 3 28939 NULL
104773 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
104774 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
104775 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
104776 +bin_uuid_28999 bin_uuid 3 28999 NULL
104777 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
104778 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
104779 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
104780 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
104781 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
104782 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
104783 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
104784 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
104785 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
104786 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
104787 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
104788 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
104789 +snprintf_29125 snprintf 0 29125 NULL
104790 +iov_shorten_29130 iov_shorten 0 29130 NULL
104791 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
104792 +reshape_ring_29147 reshape_ring 2 29147 NULL
104793 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
104794 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
104795 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
104796 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
104797 +__mm_populate_29204 __mm_populate 1 29204 NULL
104798 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
104799 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
104800 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
104801 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
104802 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
104803 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
104804 +recover_peb_29238 recover_peb 6-7 29238 NULL
104805 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
104806 +block_div_29268 block_div 0-1-2 29268 NULL
104807 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
104808 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
104809 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
104810 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
104811 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
104812 +tun_put_user_29337 tun_put_user 5 29337 NULL
104813 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
104814 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
104815 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
104816 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
104817 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
104818 +mempool_create_29437 mempool_create 1 29437 NULL
104819 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
104820 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
104821 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
104822 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
104823 +do_register_entry_29478 do_register_entry 4 29478 NULL
104824 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
104825 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
104826 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
104827 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
104828 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
104829 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
104830 +set_brk_29551 set_brk 1 29551 NULL nohasharray
104831 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
104832 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
104833 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
104834 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
104835 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
104836 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
104837 +slots_per_page_29601 slots_per_page 0 29601 NULL
104838 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
104839 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
104840 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
104841 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
104842 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
104843 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
104844 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
104845 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
104846 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
104847 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
104848 +probes_write_29711 probes_write 3 29711 NULL
104849 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
104850 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
104851 +std_nic_write_29752 std_nic_write 3 29752 NULL
104852 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
104853 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
104854 +dbAlloc_29794 dbAlloc 0 29794 NULL
104855 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
104856 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
104857 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
104858 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
104859 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
104860 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
104861 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
104862 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
104863 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
104864 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
104865 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
104866 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
104867 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
104868 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
104869 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
104870 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
104871 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
104872 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
104873 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
104874 +drp_wmove_30043 drp_wmove 4 30043 NULL
104875 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
104876 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
104877 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
104878 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
104879 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
104880 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
104881 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
104882 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
104883 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
104884 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
104885 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
104886 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
104887 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
104888 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
104889 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
104890 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
104891 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
104892 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
104893 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
104894 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
104895 +compat_readv_30273 compat_readv 3 30273 NULL
104896 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
104897 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
104898 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
104899 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
104900 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
104901 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
104902 +resource_from_user_30341 resource_from_user 3 30341 NULL
104903 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
104904 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
104905 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
104906 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
104907 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
104908 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
104909 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
104910 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
104911 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
104912 +mq_create_30425 mq_create 1 30425 NULL
104913 +enable_write_30456 enable_write 3 30456 NULL
104914 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
104915 +urandom_read_30462 urandom_read 3 30462 NULL
104916 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
104917 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
104918 +write_head_30481 write_head 4 30481 NULL
104919 +adu_write_30487 adu_write 3 30487 NULL
104920 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
104921 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
104922 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
104923 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
104924 +set_le_30581 set_le 4 30581 NULL
104925 +from_cblock_30582 from_cblock 0-1 30582 NULL
104926 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
104927 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
104928 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
104929 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
104930 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
104931 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
104932 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
104933 +agp_remap_30665 agp_remap 2 30665 NULL
104934 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
104935 +il_free_pages_30692 il_free_pages 2 30692 NULL
104936 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
104937 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
104938 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
104939 +snapshot_status_30744 snapshot_status 5 30744 NULL
104940 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
104941 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
104942 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
104943 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
104944 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
104945 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
104946 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
104947 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
104948 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
104949 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
104950 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
104951 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
104952 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
104953 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
104954 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
104955 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
104956 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
104957 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
104958 +sys_mincore_31079 sys_mincore 1 31079 NULL
104959 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
104960 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
104961 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
104962 +depth_read_31112 depth_read 3 31112 NULL
104963 +ssb_read16_31139 ssb_read16 0 31139 NULL
104964 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
104965 +size_inside_page_31141 size_inside_page 0 31141 NULL
104966 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
104967 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
104968 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
104969 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
104970 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
104971 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
104972 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
104973 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
104974 +__read_reg_31216 __read_reg 0 31216 NULL
104975 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
104976 +cyy_readb_31240 cyy_readb 0 31240 NULL
104977 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
104978 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
104979 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
104980 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
104981 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
104982 +command_file_write_31318 command_file_write 3 31318 NULL
104983 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
104984 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
104985 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
104986 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
104987 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
104988 +inb_31388 inb 0 31388 NULL
104989 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
104990 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
104991 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
104992 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
104993 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
104994 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
104995 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
104996 +do_fcntl_31468 do_fcntl 3 31468 NULL
104997 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
104998 +alg_setkey_31485 alg_setkey 3 31485 NULL
104999 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
105000 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
105001 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
105002 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
105003 +hidraw_write_31536 hidraw_write 3 31536 NULL
105004 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
105005 +usbvision_read_31555 usbvision_read 3 31555 NULL
105006 +normalize_31566 normalize 0-1-2 31566 NULL
105007 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
105008 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
105009 +osst_write_31581 osst_write 3 31581 NULL
105010 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
105011 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
105012 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
105013 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
105014 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
105015 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
105016 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
105017 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
105018 +__lgread_31668 __lgread 4 31668 NULL
105019 +symbol_string_31670 symbol_string 0 31670 NULL
105020 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
105021 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
105022 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
105023 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
105024 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
105025 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
105026 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
105027 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
105028 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
105029 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
105030 +muldiv64_31743 muldiv64 2-3 31743 NULL
105031 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
105032 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
105033 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
105034 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
105035 +get_count_order_31800 get_count_order 0 31800 NULL
105036 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
105037 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
105038 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
105039 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
105040 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
105041 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
105042 +xattr_permission_31907 xattr_permission 0 31907 NULL
105043 +new_dir_31919 new_dir 3 31919 NULL
105044 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
105045 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
105046 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
105047 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
105048 +vb2_write_31948 vb2_write 3 31948 NULL
105049 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
105050 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
105051 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
105052 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
105053 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
105054 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
105055 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
105056 +calc_hmac_32010 calc_hmac 3 32010 NULL
105057 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
105058 +aead_len_32021 aead_len 0 32021 NULL
105059 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
105060 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
105061 +stk_read_32038 stk_read 3 32038 NULL
105062 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
105063 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
105064 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
105065 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
105066 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
105067 +bio_alloc_32095 bio_alloc 2 32095 NULL
105068 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
105069 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
105070 +disk_status_32120 disk_status 4 32120 NULL
105071 +venus_link_32165 venus_link 5 32165 NULL
105072 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
105073 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
105074 +load_header_32183 load_header 0 32183 NULL
105075 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
105076 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
105077 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
105078 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
105079 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
105080 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
105081 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
105082 +hex_string_32310 hex_string 0 32310 NULL
105083 +SyS_select_32319 SyS_select 1 32319 NULL
105084 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
105085 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
105086 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
105087 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
105088 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
105089 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
105090 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
105091 +local_clock_32385 local_clock 0 32385 NULL
105092 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
105093 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
105094 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
105095 +log_text_32428 log_text 0 32428 NULL
105096 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
105097 +hid_input_report_32458 hid_input_report 4 32458 NULL
105098 +cache_status_32462 cache_status 5 32462 NULL
105099 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
105100 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
105101 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
105102 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
105103 +disconnect_32521 disconnect 4 32521 NULL
105104 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
105105 +ilo_read_32531 ilo_read 3 32531 NULL
105106 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
105107 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
105108 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
105109 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
105110 +__first_node_32558 __first_node 0 32558 NULL
105111 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
105112 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
105113 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
105114 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
105115 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
105116 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
105117 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
105118 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
105119 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
105120 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
105121 +kvmalloc_32646 kvmalloc 1 32646 NULL
105122 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
105123 +generic_readlink_32654 generic_readlink 3 32654 NULL
105124 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
105125 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
105126 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
105127 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
105128 +get_arg_page_32746 get_arg_page 2 32746 NULL
105129 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
105130 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
105131 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
105132 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
105133 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
105134 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
105135 +vga_rseq_32848 vga_rseq 0 32848 NULL
105136 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
105137 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
105138 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
105139 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
105140 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
105141 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
105142 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
105143 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
105144 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
105145 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
105146 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
105147 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
105148 +compat_filldir_32999 compat_filldir 3 32999 NULL
105149 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
105150 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
105151 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
105152 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
105153 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
105154 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
105155 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
105156 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
105157 +alloc_tio_33077 alloc_tio 3 33077 NULL
105158 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
105159 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
105160 +write_node_33121 write_node 4 33121 NULL
105161 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
105162 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
105163 +__len_within_target_33132 __len_within_target 0 33132 NULL
105164 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
105165 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
105166 +pp_read_33210 pp_read 3 33210 NULL
105167 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
105168 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
105169 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
105170 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
105171 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
105172 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
105173 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
105174 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
105175 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
105176 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
105177 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
105178 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
105179 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
105180 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
105181 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
105182 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
105183 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
105184 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
105185 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
105186 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
105187 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
105188 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
105189 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
105190 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
105191 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
105192 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
105193 +create_entry_33479 create_entry 2 33479 NULL
105194 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
105195 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
105196 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
105197 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
105198 +res_counter_read_33499 res_counter_read 4 33499 NULL
105199 +fb_read_33506 fb_read 3 33506 NULL
105200 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
105201 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
105202 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
105203 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
105204 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
105205 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
105206 +dup_array_33551 dup_array 3 33551 NULL
105207 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
105208 +count_subheaders_33591 count_subheaders 0 33591 NULL
105209 +scsi_execute_33596 scsi_execute 5 33596 NULL
105210 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
105211 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
105212 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
105213 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
105214 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
105215 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
105216 +inw_p_33668 inw_p 0 33668 NULL
105217 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
105218 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
105219 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
105220 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
105221 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
105222 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
105223 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
105224 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
105225 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
105226 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
105227 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
105228 +Read_hfc_33755 Read_hfc 0 33755 NULL
105229 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
105230 +hashtab_create_33769 hashtab_create 3 33769 NULL
105231 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
105232 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
105233 +find_next_offset_33804 find_next_offset 3 33804 NULL
105234 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
105235 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
105236 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
105237 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
105238 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
105239 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
105240 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
105241 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
105242 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
105243 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
105244 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
105245 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
105246 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
105247 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
105248 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
105249 +ppp_write_34034 ppp_write 3 34034 NULL
105250 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
105251 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
105252 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
105253 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
105254 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
105255 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
105256 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
105257 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
105258 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
105259 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
105260 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
105261 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
105262 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
105263 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
105264 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
105265 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
105266 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
105267 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
105268 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
105269 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
105270 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
105271 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
105272 +__insert_34349 __insert 2-3 34349 NULL
105273 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
105274 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
105275 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
105276 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
105277 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
105278 +ea_read_34378 ea_read 0 34378 NULL
105279 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
105280 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
105281 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
105282 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
105283 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
105284 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
105285 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
105286 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
105287 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
105288 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
105289 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
105290 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
105291 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
105292 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
105293 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
105294 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
105295 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
105296 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
105297 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
105298 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
105299 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
105300 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
105301 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
105302 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
105303 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
105304 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
105305 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
105306 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
105307 +port_print_34704 port_print 3 34704 NULL
105308 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
105309 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
105310 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
105311 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
105312 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
105313 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
105314 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
105315 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
105316 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
105317 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
105318 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
105319 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
105320 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
105321 +msg_print_text_34889 msg_print_text 0 34889 NULL
105322 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
105323 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
105324 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
105325 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
105326 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
105327 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
105328 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
105329 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
105330 +Realloc_34961 Realloc 2 34961 NULL
105331 +mq_lookup_34990 mq_lookup 2 34990 NULL
105332 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
105333 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
105334 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
105335 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
105336 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
105337 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
105338 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
105339 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
105340 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
105341 +store_ifalias_35088 store_ifalias 4 35088 NULL
105342 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
105343 +capi_write_35104 capi_write 3 35104 NULL nohasharray
105344 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
105345 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
105346 +pointer_35138 pointer 0 35138 NULL
105347 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
105348 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
105349 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
105350 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
105351 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
105352 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
105353 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
105354 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
105355 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
105356 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
105357 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
105358 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
105359 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
105360 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
105361 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
105362 +set_fd_set_35249 set_fd_set 1 35249 NULL
105363 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
105364 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
105365 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
105366 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
105367 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
105368 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
105369 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
105370 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
105371 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
105372 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
105373 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
105374 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
105375 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
105376 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
105377 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
105378 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
105379 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
105380 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
105381 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
105382 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
105383 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
105384 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
105385 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
105386 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
105387 +async_setkey_35521 async_setkey 3 35521 NULL
105388 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
105389 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
105390 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
105391 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
105392 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
105393 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
105394 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
105395 +ReadZReg_35604 ReadZReg 0 35604 NULL
105396 +kernel_readv_35617 kernel_readv 3 35617 NULL
105397 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
105398 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
105399 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
105400 +store_debug_level_35652 store_debug_level 3 35652 NULL
105401 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
105402 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
105403 +dm_table_create_35687 dm_table_create 3 35687 NULL
105404 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
105405 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
105406 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
105407 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
105408 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
105409 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
105410 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
105411 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
105412 +fls64_35862 fls64 0 35862 NULL
105413 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
105414 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
105415 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
105416 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
105417 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
105418 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
105419 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
105420 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
105421 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
105422 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
105423 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
105424 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
105425 +acl_alloc_35979 acl_alloc 1 35979 NULL
105426 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
105427 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
105428 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
105429 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
105430 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
105431 +account_shadowed_36048 account_shadowed 2 36048 NULL
105432 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
105433 +write_emulate_36065 write_emulate 2-4 36065 NULL
105434 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
105435 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
105436 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
105437 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
105438 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
105439 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
105440 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
105441 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
105442 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
105443 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
105444 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
105445 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
105446 +twl_set_36154 twl_set 2 36154 NULL
105447 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
105448 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
105449 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
105450 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
105451 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
105452 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
105453 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
105454 +is_dirty_36223 is_dirty 2 36223 NULL
105455 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
105456 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
105457 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
105458 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
105459 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
105460 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
105461 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
105462 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
105463 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
105464 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
105465 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
105466 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
105467 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
105468 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
105469 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
105470 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
105471 +lc_create_36332 lc_create 4 36332 NULL
105472 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
105473 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
105474 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
105475 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
105476 +to_sector_36361 to_sector 0-1 36361 NULL
105477 +tunables_read_36385 tunables_read 3 36385 NULL
105478 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
105479 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
105480 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
105481 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
105482 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
105483 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
105484 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
105485 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
105486 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
105487 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
105488 +get_param_l_36518 get_param_l 0 36518 NULL
105489 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
105490 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
105491 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
105492 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
105493 +get_entry_len_36549 get_entry_len 0 36549 NULL
105494 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
105495 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
105496 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
105497 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
105498 +__erst_read_36579 __erst_read 0 36579 NULL
105499 +put_cmsg_36589 put_cmsg 4 36589 NULL
105500 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
105501 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
105502 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
105503 +format_decode_36638 format_decode 0 36638 NULL
105504 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
105505 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
105506 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
105507 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
105508 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
105509 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
105510 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
105511 +sched_clock_36717 sched_clock 0 36717 NULL
105512 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
105513 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
105514 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
105515 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
105516 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
105517 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
105518 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
105519 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
105520 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
105521 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
105522 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
105523 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
105524 +cm_write_36858 cm_write 3 36858 NULL
105525 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
105526 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
105527 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
105528 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
105529 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
105530 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
105531 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
105532 +build_key_36931 build_key 1 36931 NULL
105533 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
105534 +write_leb_36957 write_leb 5 36957 NULL
105535 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
105536 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
105537 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
105538 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
105539 +setxattr_37006 setxattr 4 37006 NULL
105540 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
105541 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
105542 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
105543 +parse_command_37079 parse_command 2 37079 NULL
105544 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
105545 +tun_get_user_37094 tun_get_user 5 37094 NULL
105546 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
105547 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
105548 +msg_word_37164 msg_word 0 37164 NULL
105549 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
105550 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
105551 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
105552 +__do_replace_37227 __do_replace 5 37227 NULL
105553 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
105554 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
105555 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
105556 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
105557 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
105558 +c101_run_37279 c101_run 2 37279 NULL
105559 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
105560 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
105561 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
105562 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
105563 +send_msg_37323 send_msg 4 37323 NULL
105564 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
105565 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
105566 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
105567 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
105568 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
105569 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
105570 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
105571 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
105572 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
105573 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
105574 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
105575 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
105576 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
105577 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
105578 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
105579 +__remove_37457 __remove 2 37457 NULL
105580 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
105581 +get_est_timing_37484 get_est_timing 0 37484 NULL
105582 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
105583 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
105584 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
105585 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
105586 +hdr_size_37536 hdr_size 0 37536 NULL
105587 +a2p_37544 a2p 0-1 37544 NULL
105588 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
105589 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
105590 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
105591 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
105592 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
105593 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
105594 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
105595 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
105596 +check_pt_base_37635 check_pt_base 3 37635 NULL
105597 +alloc_fd_37637 alloc_fd 1 37637 NULL
105598 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
105599 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
105600 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
105601 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
105602 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
105603 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
105604 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
105605 +nametbl_header_37698 nametbl_header 2 37698 NULL
105606 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
105607 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
105608 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
105609 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
105610 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
105611 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
105612 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
105613 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
105614 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
105615 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
105616 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
105617 +deny_write_access_37813 deny_write_access 0 37813 NULL
105618 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
105619 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
105620 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
105621 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
105622 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
105623 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
105624 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
105625 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
105626 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
105627 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
105628 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
105629 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
105630 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
105631 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
105632 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
105633 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
105634 +vfs_readv_38011 vfs_readv 3 38011 NULL
105635 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
105636 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
105637 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
105638 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
105639 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
105640 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
105641 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
105642 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
105643 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
105644 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
105645 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
105646 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
105647 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
105648 +ep0_read_38095 ep0_read 3 38095 NULL
105649 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
105650 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
105651 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
105652 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
105653 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
105654 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
105655 +cdev_add_38176 cdev_add 2-3 38176 NULL
105656 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
105657 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
105658 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
105659 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
105660 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
105661 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
105662 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
105663 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
105664 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
105665 +from_dblock_38256 from_dblock 0-1 38256 NULL
105666 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
105667 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
105668 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
105669 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
105670 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
105671 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
105672 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
105673 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
105674 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
105675 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
105676 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
105677 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
105678 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
105679 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
105680 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
105681 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
105682 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
105683 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
105684 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
105685 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
105686 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
105687 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
105688 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
105689 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
105690 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
105691 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
105692 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
105693 +dev_names_read_38509 dev_names_read 3 38509 NULL
105694 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
105695 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
105696 +set_queue_count_38519 set_queue_count 0 38519 NULL
105697 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
105698 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
105699 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
105700 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
105701 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
105702 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
105703 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
105704 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
105705 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
105706 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
105707 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
105708 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
105709 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
105710 +cma_create_area_38642 cma_create_area 2 38642 NULL
105711 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
105712 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
105713 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
105714 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
105715 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
105716 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
105717 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
105718 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
105719 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
105720 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
105721 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
105722 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
105723 +udf_readpages_38761 udf_readpages 4 38761 NULL
105724 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
105725 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
105726 +err_decode_38804 err_decode 2 38804 NULL
105727 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
105728 +sys_select_38827 sys_select 1 38827 NULL
105729 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
105730 +direct_entry_38836 direct_entry 3 38836 NULL
105731 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
105732 +interfaces_38859 interfaces 2 38859 NULL
105733 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
105734 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
105735 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
105736 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
105737 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
105738 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
105739 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
105740 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
105741 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
105742 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
105743 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
105744 +udf_new_block_38999 udf_new_block 4 38999 NULL
105745 +get_nodes_39012 get_nodes 3 39012 NULL
105746 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
105747 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
105748 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
105749 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
105750 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
105751 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
105752 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
105753 +ea_foreach_39133 ea_foreach 0 39133 NULL
105754 +generic_permission_39150 generic_permission 0 39150 NULL
105755 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
105756 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
105757 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
105758 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
105759 +init_list_set_39188 init_list_set 2-3 39188 NULL
105760 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
105761 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
105762 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
105763 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
105764 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
105765 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
105766 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
105767 +drm_order_39244 drm_order 0 39244 NULL
105768 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
105769 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
105770 +__skb_cow_39254 __skb_cow 2 39254 NULL
105771 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
105772 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
105773 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
105774 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
105775 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
105776 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
105777 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
105778 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
105779 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
105780 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
105781 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
105782 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
105783 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
105784 +__send_to_port_39386 __send_to_port 3 39386 NULL
105785 +user_power_read_39414 user_power_read 3 39414 NULL
105786 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
105787 +sys_semop_39457 sys_semop 3 39457 NULL
105788 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
105789 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
105790 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
105791 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
105792 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
105793 +int_proc_write_39542 int_proc_write 3 39542 NULL
105794 +pp_write_39554 pp_write 3 39554 NULL
105795 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
105796 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
105797 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
105798 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
105799 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
105800 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
105801 +ext_depth_39607 ext_depth 0 39607 NULL
105802 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
105803 +sdio_readb_39618 sdio_readb 0 39618 NULL
105804 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
105805 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
105806 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
105807 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
105808 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
105809 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
105810 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
105811 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
105812 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
105813 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
105814 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
105815 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
105816 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
105817 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
105818 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
105819 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
105820 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
105821 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
105822 +pkt_add_39897 pkt_add 3 39897 NULL
105823 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
105824 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
105825 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
105826 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
105827 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
105828 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
105829 +__spi_async_39932 __spi_async 0 39932 NULL
105830 +__get_order_39935 __get_order 0 39935 NULL
105831 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
105832 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
105833 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
105834 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
105835 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
105836 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
105837 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
105838 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
105839 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
105840 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
105841 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
105842 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
105843 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
105844 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
105845 +add_tty_40055 add_tty 1 40055 NULL nohasharray
105846 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
105847 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
105848 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
105849 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
105850 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
105851 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
105852 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
105853 +pt_write_40159 pt_write 3 40159 NULL
105854 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
105855 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
105856 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
105857 +allocate_probes_40204 allocate_probes 1 40204 NULL
105858 +compat_put_long_40214 compat_put_long 1 40214 NULL
105859 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
105860 +osst_read_40237 osst_read 3 40237 NULL
105861 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
105862 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
105863 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
105864 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
105865 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
105866 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
105867 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
105868 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
105869 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
105870 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
105871 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
105872 +mmio_read_40348 mmio_read 4 40348 NULL
105873 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
105874 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
105875 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
105876 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
105877 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
105878 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
105879 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
105880 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
105881 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
105882 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
105883 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
105884 +tty_write_room_40495 tty_write_room 0 40495 NULL
105885 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
105886 +sg_phys_40507 sg_phys 0 40507 NULL
105887 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
105888 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
105889 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
105890 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
105891 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
105892 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
105893 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
105894 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
105895 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
105896 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
105897 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
105898 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
105899 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
105900 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
105901 +fops_read_40672 fops_read 3 40672 NULL
105902 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
105903 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
105904 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
105905 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
105906 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
105907 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
105908 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
105909 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
105910 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
105911 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
105912 +card_send_command_40757 card_send_command 3 40757 NULL
105913 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
105914 +pg_write_40766 pg_write 3 40766 NULL
105915 +show_list_40775 show_list 3 40775 NULL
105916 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
105917 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
105918 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
105919 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
105920 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
105921 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
105922 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
105923 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
105924 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
105925 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
105926 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
105927 +read_file_queue_40895 read_file_queue 3 40895 NULL
105928 +waiters_read_40902 waiters_read 3 40902 NULL
105929 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
105930 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
105931 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
105932 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
105933 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
105934 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
105935 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
105936 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
105937 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
105938 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
105939 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
105940 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
105941 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
105942 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
105943 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
105944 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
105945 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
105946 +dma_attach_41094 dma_attach 5-6 41094 NULL
105947 +provide_user_output_41105 provide_user_output 3 41105 NULL
105948 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
105949 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
105950 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
105951 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
105952 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
105953 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
105954 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
105955 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
105956 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
105957 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
105958 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
105959 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
105960 +erst_read_41260 erst_read 0 41260 NULL
105961 +__fprog_create_41263 __fprog_create 2 41263 NULL
105962 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
105963 +alloc_context_41283 alloc_context 1 41283 NULL
105964 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
105965 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
105966 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
105967 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
105968 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
105969 +kmp_init_41373 kmp_init 2 41373 NULL
105970 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
105971 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
105972 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
105973 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
105974 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
105975 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
105976 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
105977 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
105978 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
105979 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
105980 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
105981 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
105982 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
105983 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
105984 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
105985 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
105986 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
105987 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
105988 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
105989 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
105990 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
105991 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
105992 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
105993 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
105994 +vga_io_r_41609 vga_io_r 0 41609 NULL
105995 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
105996 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
105997 +a2mp_send_41615 a2mp_send 4 41615 NULL
105998 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
105999 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
106000 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
106001 +get_std_timing_41654 get_std_timing 0 41654 NULL
106002 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
106003 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
106004 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
106005 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
106006 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
106007 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
106008 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
106009 +fillonedir_41746 fillonedir 3 41746 NULL
106010 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
106011 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
106012 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
106013 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
106014 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
106015 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
106016 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
106017 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
106018 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
106019 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
106020 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
106021 +get_packet_41914 get_packet 3 41914 NULL
106022 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
106023 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
106024 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
106025 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
106026 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
106027 +read_gssp_41947 read_gssp 3 41947 NULL
106028 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
106029 +portnames_read_41958 portnames_read 3 41958 NULL
106030 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
106031 +dst_mtu_41969 dst_mtu 0 41969 NULL
106032 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
106033 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
106034 +lguest_map_42008 lguest_map 1-2 42008 NULL
106035 +pool_allocate_42012 pool_allocate 3 42012 NULL
106036 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
106037 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
106038 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
106039 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
106040 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
106041 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
106042 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
106043 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
106044 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
106045 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
106046 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
106047 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
106048 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
106049 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
106050 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
106051 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
106052 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
106053 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
106054 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
106055 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
106056 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
106057 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
106058 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
106059 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
106060 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
106061 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
106062 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
106063 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
106064 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
106065 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
106066 +free_cblock_42318 free_cblock 2 42318 NULL
106067 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
106068 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
106069 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
106070 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
106071 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
106072 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
106073 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
106074 +krng_get_random_42420 krng_get_random 3 42420 NULL
106075 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
106076 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
106077 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
106078 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
106079 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
106080 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
106081 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
106082 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
106083 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
106084 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
106085 +bypass_write_42498 bypass_write 3 42498 NULL
106086 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
106087 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
106088 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
106089 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
106090 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
106091 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
106092 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
106093 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
106094 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
106095 +map_state_42602 map_state 1 42602 NULL nohasharray
106096 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
106097 +nd_get_link_42603 nd_get_link 0 42603 NULL
106098 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
106099 +resp_write_42628 resp_write 2 42628 NULL
106100 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
106101 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
106102 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
106103 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
106104 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
106105 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
106106 +vb2_read_42703 vb2_read 3 42703 NULL
106107 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
106108 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
106109 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
106110 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
106111 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
106112 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
106113 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
106114 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
106115 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
106116 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
106117 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
106118 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
106119 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
106120 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
106121 +set_arg_42824 set_arg 3 42824 NULL
106122 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
106123 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
106124 +prandom_u32_42853 prandom_u32 0 42853 NULL
106125 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
106126 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
106127 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
106128 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
106129 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
106130 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
106131 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
106132 +hd_end_request_42904 hd_end_request 2 42904 NULL
106133 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
106134 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
106135 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
106136 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
106137 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
106138 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
106139 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
106140 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
106141 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
106142 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
106143 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
106144 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
106145 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
106146 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
106147 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
106148 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
106149 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
106150 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
106151 +uuid_string_43154 uuid_string 0 43154 NULL
106152 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
106153 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
106154 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
106155 +process_measurement_43190 process_measurement 0 43190 NULL
106156 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
106157 +uio_write_43202 uio_write 3 43202 NULL
106158 +iso_callback_43208 iso_callback 3 43208 NULL
106159 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
106160 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
106161 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
106162 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
106163 +fixup_leb_43256 fixup_leb 3 43256 NULL
106164 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
106165 +evtchn_write_43278 evtchn_write 3 43278 NULL
106166 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
106167 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
106168 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
106169 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
106170 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
106171 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
106172 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
106173 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
106174 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
106175 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
106176 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
106177 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
106178 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
106179 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
106180 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
106181 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
106182 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
106183 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
106184 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
106185 +do_readlink_43518 do_readlink 2 43518 NULL
106186 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
106187 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
106188 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
106189 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
106190 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
106191 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
106192 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
106193 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
106194 +proc_read_43614 proc_read 3 43614 NULL
106195 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
106196 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
106197 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
106198 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
106199 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
106200 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
106201 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
106202 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
106203 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
106204 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
106205 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
106206 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
106207 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
106208 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
106209 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
106210 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
106211 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
106212 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
106213 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
106214 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
106215 +read_flush_43851 read_flush 3 43851 NULL
106216 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
106217 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
106218 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
106219 +SendString_43928 SendString 3 43928 NULL
106220 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
106221 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
106222 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
106223 +nla_reserve_43984 nla_reserve 3 43984 NULL
106224 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
106225 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
106226 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
106227 +emit_flags_44006 emit_flags 4-3 44006 NULL
106228 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
106229 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
106230 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
106231 +load_discard_44083 load_discard 3 44083 NULL
106232 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
106233 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
106234 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
106235 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
106236 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
106237 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
106238 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
106239 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
106240 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
106241 +__set_free_44211 __set_free 2 44211 NULL
106242 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
106243 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
106244 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
106245 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
106246 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
106247 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
106248 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
106249 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
106250 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
106251 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
106252 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
106253 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
106254 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
106255 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
106256 +__is_discarded_44359 __is_discarded 2 44359 NULL
106257 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
106258 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
106259 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
106260 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
106261 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
106262 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
106263 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
106264 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
106265 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
106266 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
106267 +bio_advance_44496 bio_advance 2 44496 NULL
106268 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
106269 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
106270 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
106271 +spidev_write_44510 spidev_write 3 44510 NULL
106272 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
106273 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
106274 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
106275 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
106276 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
106277 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
106278 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
106279 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
106280 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
106281 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
106282 +mpi_resize_44674 mpi_resize 2 44674 NULL
106283 +ts_read_44687 ts_read 3 44687 NULL
106284 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
106285 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
106286 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
106287 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
106288 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
106289 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
106290 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
106291 +set_brk_44749 set_brk 1 44749 NULL
106292 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
106293 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
106294 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
106295 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
106296 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
106297 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
106298 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
106299 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
106300 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
106301 +sisusb_write_44834 sisusb_write 3 44834 NULL
106302 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
106303 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
106304 +cubic_root_44848 cubic_root 1 44848 NULL
106305 +copydesc_user_44855 copydesc_user 3 44855 NULL
106306 +skb_availroom_44883 skb_availroom 0 44883 NULL
106307 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
106308 +do_tty_write_44896 do_tty_write 5 44896 NULL
106309 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
106310 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
106311 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
106312 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
106313 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
106314 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
106315 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
106316 +sel_write_user_45060 sel_write_user 3 45060 NULL
106317 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
106318 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
106319 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
106320 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
106321 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
106322 +usbdev_read_45114 usbdev_read 3 45114 NULL
106323 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
106324 +send_to_tty_45141 send_to_tty 3 45141 NULL
106325 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
106326 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
106327 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
106328 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
106329 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
106330 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
106331 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
106332 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
106333 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
106334 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
106335 +add_child_45201 add_child 4 45201 NULL
106336 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
106337 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
106338 +__dirty_45228 __dirty 2 45228 NULL
106339 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
106340 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
106341 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
106342 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
106343 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
106344 +pte_val_45313 pte_val 0 45313 NULL
106345 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
106346 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
106347 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
106348 +keymap_store_45406 keymap_store 4 45406 NULL
106349 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
106350 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
106351 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
106352 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
106353 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
106354 +__node_remap_45458 __node_remap 4 45458 NULL
106355 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
106356 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
106357 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
106358 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
106359 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
106360 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
106361 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
106362 +copy_macs_45534 copy_macs 4 45534 NULL
106363 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
106364 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
106365 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
106366 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
106367 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
106368 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
106369 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
106370 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
106371 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
106372 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
106373 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
106374 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
106375 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
106376 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
106377 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
106378 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
106379 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
106380 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
106381 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
106382 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
106383 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
106384 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
106385 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
106386 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
106387 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
106388 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
106389 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
106390 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
106391 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
106392 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
106393 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
106394 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
106395 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
106396 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
106397 +isdn_write_45863 isdn_write 3 45863 NULL
106398 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
106399 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
106400 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
106401 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
106402 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
106403 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
106404 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
106405 +alloc_mr_45935 alloc_mr 1 45935 NULL
106406 +split_large_page_45941 split_large_page 2 45941 NULL
106407 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
106408 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
106409 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
106410 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
106411 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
106412 +get_free_entries_46030 get_free_entries 1 46030 NULL
106413 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
106414 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
106415 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
106416 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
106417 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
106418 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
106419 +slhc_toss_46066 slhc_toss 0 46066 NULL
106420 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
106421 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
106422 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
106423 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
106424 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
106425 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
106426 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
106427 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
106428 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
106429 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
106430 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
106431 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
106432 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
106433 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
106434 +add_conn_list_46197 add_conn_list 3 46197 NULL
106435 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
106436 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
106437 +dsp_write_46218 dsp_write 2 46218 NULL
106438 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
106439 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
106440 +ReadReg_46277 ReadReg 0 46277 NULL
106441 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
106442 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
106443 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
106444 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
106445 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
106446 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
106447 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
106448 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
106449 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
106450 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
106451 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
106452 +filldir64_46469 filldir64 3 46469 NULL
106453 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
106454 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
106455 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
106456 +kmsg_read_46514 kmsg_read 3 46514 NULL
106457 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
106458 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
106459 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
106460 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
106461 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
106462 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
106463 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
106464 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
106465 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
106466 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
106467 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
106468 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
106469 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
106470 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
106471 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
106472 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
106473 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
106474 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
106475 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
106476 +prepare_copy_46725 prepare_copy 2 46725 NULL
106477 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
106478 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
106479 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
106480 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
106481 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
106482 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
106483 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
106484 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
106485 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
106486 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
106487 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
106488 +spi_async_46857 spi_async 0 46857 NULL
106489 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
106490 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
106491 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
106492 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
106493 +rvmalloc_46873 rvmalloc 1 46873 NULL
106494 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
106495 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
106496 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
106497 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
106498 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
106499 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
106500 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
106501 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
106502 +fb_write_46924 fb_write 3 46924 NULL
106503 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
106504 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
106505 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
106506 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
106507 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
106508 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
106509 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
106510 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
106511 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
106512 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
106513 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
106514 +__map_single_47020 __map_single 3-4-7 47020 NULL
106515 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
106516 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
106517 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
106518 +fs_path_len_47060 fs_path_len 0 47060 NULL
106519 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
106520 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
106521 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
106522 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
106523 +mousedev_read_47123 mousedev_read 3 47123 NULL
106524 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
106525 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
106526 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
106527 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
106528 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
106529 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
106530 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
106531 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
106532 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
106533 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
106534 +l2headersize_47238 l2headersize 0 47238 NULL
106535 +options_write_47243 options_write 3 47243 NULL
106536 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
106537 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
106538 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
106539 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
106540 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
106541 +vsnprintf_47291 vsnprintf 0 47291 NULL
106542 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
106543 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
106544 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
106545 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
106546 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
106547 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
106548 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
106549 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
106550 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
106551 +nametbl_list_47391 nametbl_list 2 47391 NULL
106552 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
106553 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
106554 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
106555 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
106556 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
106557 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
106558 +vzalloc_47421 vzalloc 1 47421 NULL
106559 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
106560 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
106561 +__load_mapping_47460 __load_mapping 2 47460 NULL
106562 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
106563 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
106564 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
106565 +core_sys_select_47494 core_sys_select 1 47494 NULL
106566 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
106567 +unlink_simple_47506 unlink_simple 3 47506 NULL
106568 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
106569 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
106570 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
106571 +oz_events_read_47535 oz_events_read 3 47535 NULL
106572 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
106573 +read_ldt_47570 read_ldt 2 47570 NULL
106574 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
106575 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
106576 +pci_iomap_47575 pci_iomap 3 47575 NULL
106577 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
106578 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
106579 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
106580 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
106581 +uea_request_47613 uea_request 4 47613 NULL
106582 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
106583 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
106584 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
106585 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
106586 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
106587 +save_microcode_47717 save_microcode 3 47717 NULL
106588 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
106589 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
106590 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
106591 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
106592 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
106593 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
106594 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
106595 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
106596 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
106597 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
106598 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
106599 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
106600 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
106601 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
106602 +vhci_read_47878 vhci_read 3 47878 NULL
106603 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
106604 +load_mapping_47904 load_mapping 3 47904 NULL
106605 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
106606 +comedi_write_47926 comedi_write 3 47926 NULL
106607 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
106608 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
106609 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
106610 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
106611 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
106612 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
106613 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
106614 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
106615 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
106616 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
106617 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
106618 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
106619 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
106620 +disc_write_48070 disc_write 3 48070 NULL
106621 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
106622 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
106623 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
106624 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
106625 +set_discoverable_48141 set_discoverable 4 48141 NULL
106626 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
106627 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
106628 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
106629 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
106630 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
106631 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
106632 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
106633 +init_ipath_48187 init_ipath 1 48187 NULL
106634 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
106635 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
106636 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
106637 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
106638 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
106639 +read_file_recv_48232 read_file_recv 3 48232 NULL
106640 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
106641 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
106642 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
106643 +send_set_info_48288 send_set_info 7 48288 NULL
106644 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
106645 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
106646 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
106647 +hash_setkey_48310 hash_setkey 3 48310 NULL
106648 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
106649 +skb_add_data_48363 skb_add_data 3 48363 NULL
106650 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
106651 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
106652 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
106653 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
106654 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
106655 +print_filtered_48442 print_filtered 2-0 48442 NULL
106656 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
106657 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
106658 +send_control_msg_48498 send_control_msg 6 48498 NULL
106659 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
106660 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
106661 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
106662 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
106663 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
106664 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
106665 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
106666 +named_distribute_48544 named_distribute 4 48544 NULL
106667 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
106668 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
106669 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
106670 +mtd_read_48655 mtd_read 0 48655 NULL
106671 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
106672 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
106673 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
106674 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
106675 +altera_drscan_48698 altera_drscan 2 48698 NULL
106676 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
106677 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
106678 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
106679 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
106680 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
106681 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
106682 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
106683 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
106684 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
106685 +azx_get_position_48841 azx_get_position 0 48841 NULL
106686 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
106687 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
106688 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
106689 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
106690 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
106691 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
106692 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
106693 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
106694 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
106695 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
106696 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
106697 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
106698 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
106699 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
106700 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
106701 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
106702 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
106703 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
106704 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
106705 +transient_status_49027 transient_status 4 49027 NULL
106706 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
106707 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
106708 +ubi_read_49061 ubi_read 0 49061 NULL
106709 +scsi_register_49094 scsi_register 2 49094 NULL
106710 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
106711 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
106712 +check_exists_49119 check_exists 2 49119 NULL nohasharray
106713 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
106714 +pt_read_49136 pt_read 3 49136 NULL
106715 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
106716 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
106717 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
106718 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
106719 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
106720 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
106721 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
106722 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
106723 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
106724 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
106725 +resp_write_same_49217 resp_write_same 2 49217 NULL
106726 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
106727 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
106728 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
106729 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
106730 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
106731 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
106732 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
106733 +uio_read_49300 uio_read 3 49300 NULL
106734 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
106735 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
106736 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
106737 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
106738 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
106739 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
106740 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
106741 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
106742 +px_raw_event_49371 px_raw_event 4 49371 NULL
106743 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
106744 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
106745 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
106746 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
106747 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
106748 +md_domain_init_49432 md_domain_init 2 49432 NULL
106749 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
106750 +get_lru_size_49441 get_lru_size 0 49441 NULL
106751 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
106752 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
106753 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
106754 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
106755 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
106756 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
106757 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
106758 +smk_write_access_49561 smk_write_access 3 49561 NULL
106759 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
106760 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
106761 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
106762 +tap_write_49595 tap_write 3 49595 NULL
106763 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
106764 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
106765 +heap_init_49617 heap_init 2 49617 NULL
106766 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
106767 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
106768 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
106769 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
106770 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
106771 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
106772 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
106773 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
106774 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
106775 +check_frame_49741 check_frame 0 49741 NULL
106776 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
106777 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
106778 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
106779 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
106780 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
106781 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
106782 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
106783 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
106784 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
106785 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
106786 +add_uuid_49831 add_uuid 4 49831 NULL
106787 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
106788 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
106789 +twl4030_write_49846 twl4030_write 2 49846 NULL
106790 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
106791 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
106792 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
106793 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
106794 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
106795 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
106796 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
106797 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
106798 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
106799 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
106800 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
106801 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
106802 +__module_alloc_50004 __module_alloc 1 50004 NULL
106803 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
106804 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
106805 +isdn_read_50021 isdn_read 3 50021 NULL
106806 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
106807 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
106808 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
106809 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
106810 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
106811 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
106812 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
106813 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
106814 +read_file_slot_50111 read_file_slot 3 50111 NULL
106815 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
106816 +copy_items_50140 copy_items 6 50140 NULL
106817 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
106818 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
106819 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
106820 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
106821 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
106822 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
106823 +odev_update_50169 odev_update 2 50169 NULL
106824 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
106825 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
106826 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
106827 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
106828 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
106829 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
106830 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
106831 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
106832 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
106833 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
106834 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
106835 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
106836 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
106837 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
106838 +do_launder_page_50329 do_launder_page 0 50329 NULL
106839 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
106840 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
106841 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
106842 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
106843 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
106844 +tpm_read_50344 tpm_read 3 50344 NULL
106845 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
106846 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
106847 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
106848 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
106849 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
106850 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
106851 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
106852 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
106853 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
106854 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
106855 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
106856 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
106857 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
106858 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
106859 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
106860 +force_mapping_50464 force_mapping 2 50464 NULL
106861 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
106862 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
106863 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
106864 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
106865 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
106866 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
106867 +fat_readpages_50582 fat_readpages 4 50582 NULL
106868 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
106869 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
106870 +sge_rx_50594 sge_rx 3 50594 NULL
106871 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
106872 +__ffs_50625 __ffs 0 50625 NULL
106873 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
106874 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
106875 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
106876 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
106877 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
106878 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
106879 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
106880 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
106881 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
106882 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
106883 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
106884 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
106885 +skb_padto_50759 skb_padto 2 50759 NULL
106886 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
106887 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
106888 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
106889 +tpm_write_50798 tpm_write 3 50798 NULL
106890 +write_flush_50803 write_flush 3 50803 NULL
106891 +dvb_play_50814 dvb_play 3 50814 NULL
106892 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
106893 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
106894 +SetArea_50835 SetArea 4 50835 NULL nohasharray
106895 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
106896 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
106897 +self_check_write_50856 self_check_write 5 50856 NULL
106898 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
106899 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
106900 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
106901 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
106902 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
106903 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
106904 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
106905 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
106906 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
106907 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
106908 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
106909 +timeout_write_50991 timeout_write 3 50991 NULL
106910 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
106911 +proc_write_51003 proc_write 3 51003 NULL
106912 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
106913 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
106914 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
106915 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
106916 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
106917 +dump_midi_51040 dump_midi 3 51040 NULL
106918 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
106919 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
106920 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
106921 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
106922 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
106923 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
106924 +ti_recv_51110 ti_recv 3 51110 NULL
106925 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
106926 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
106927 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
106928 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
106929 +set_dirty_51144 set_dirty 3 51144 NULL
106930 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
106931 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
106932 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
106933 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
106934 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
106935 +tipc_send_51238 tipc_send 4 51238 NULL
106936 +drm_property_create_51239 drm_property_create 4 51239 NULL
106937 +st_read_51251 st_read 3 51251 NULL
106938 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
106939 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
106940 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
106941 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
106942 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
106943 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
106944 +get_cell_51316 get_cell 2 51316 NULL
106945 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
106946 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
106947 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
106948 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
106949 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
106950 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
106951 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
106952 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
106953 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
106954 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
106955 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
106956 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
106957 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
106958 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
106959 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
106960 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
106961 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
106962 +vaddr_51480 vaddr 0 51480 NULL
106963 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
106964 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
106965 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
106966 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
106967 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
106968 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
106969 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
106970 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
106971 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
106972 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
106973 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
106974 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
106975 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
106976 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
106977 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
106978 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
106979 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
106980 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
106981 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
106982 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
106983 +sel_write_access_51704 sel_write_access 3 51704 NULL
106984 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
106985 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
106986 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
106987 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
106988 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
106989 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
106990 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
106991 +if_write_51756 if_write 3 51756 NULL
106992 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
106993 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
106994 +to_ratio_51809 to_ratio 2-1 51809 NULL
106995 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
106996 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
106997 +ioread32_51847 ioread32 0 51847 NULL nohasharray
106998 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
106999 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
107000 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
107001 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
107002 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
107003 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
107004 +user_read_51881 user_read 3 51881 NULL
107005 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
107006 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
107007 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
107008 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
107009 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
107010 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
107011 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
107012 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
107013 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
107014 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
107015 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
107016 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
107017 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
107018 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
107019 +rdmalt_52022 rdmalt 0 52022 NULL
107020 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
107021 +override_release_52032 override_release 2 52032 NULL
107022 +end_port_52042 end_port 0 52042 NULL
107023 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
107024 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
107025 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
107026 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
107027 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
107028 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
107029 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
107030 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
107031 +retry_count_read_52129 retry_count_read 3 52129 NULL
107032 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
107033 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
107034 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
107035 +htable_size_52148 htable_size 0-1 52148 NULL
107036 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
107037 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
107038 +alix_present_52165 alix_present 1 52165 NULL
107039 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
107040 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
107041 +print_prefix_52176 print_prefix 0 52176 NULL
107042 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
107043 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
107044 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
107045 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
107046 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
107047 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
107048 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
107049 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
107050 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
107051 +atomic64_read_52300 atomic64_read 0 52300 NULL
107052 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
107053 +read_file_reset_52310 read_file_reset 3 52310 NULL
107054 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
107055 +hwflags_read_52318 hwflags_read 3 52318 NULL
107056 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
107057 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
107058 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
107059 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
107060 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
107061 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
107062 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
107063 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
107064 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
107065 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
107066 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
107067 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
107068 +delay_status_52431 delay_status 5 52431 NULL
107069 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
107070 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
107071 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
107072 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
107073 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
107074 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
107075 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
107076 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
107077 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
107078 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
107079 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
107080 +from_oblock_52546 from_oblock 0-1 52546 NULL
107081 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
107082 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
107083 +emit_code_52583 emit_code 0-3 52583 NULL
107084 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
107085 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
107086 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
107087 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
107088 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
107089 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
107090 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
107091 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
107092 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
107093 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
107094 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
107095 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
107096 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
107097 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
107098 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
107099 +twlreg_write_52880 twlreg_write 3 52880 NULL
107100 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
107101 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
107102 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
107103 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
107104 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
107105 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
107106 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
107107 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
107108 +send_packet_52960 send_packet 4 52960 NULL
107109 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
107110 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
107111 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
107112 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
107113 +num_node_state_52989 num_node_state 0 52989 NULL
107114 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
107115 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
107116 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
107117 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
107118 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
107119 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
107120 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
107121 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
107122 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
107123 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
107124 +verity_status_53120 verity_status 5 53120 NULL
107125 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
107126 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
107127 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
107128 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
107129 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
107130 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
107131 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
107132 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
107133 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
107134 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
107135 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
107136 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
107137 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
107138 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
107139 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
107140 +vm_mmap_53339 vm_mmap 0 53339 NULL
107141 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
107142 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
107143 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
107144 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
107145 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
107146 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
107147 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
107148 +n2_run_53459 n2_run 3 53459 NULL
107149 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
107150 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
107151 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
107152 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
107153 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
107154 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
107155 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
107156 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
107157 +check_acl_53512 check_acl 0 53512 NULL
107158 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
107159 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
107160 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
107161 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
107162 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
107163 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
107164 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
107165 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
107166 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
107167 +_preload_range_53676 _preload_range 2-3 53676 NULL
107168 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
107169 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
107170 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
107171 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
107172 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
107173 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
107174 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
107175 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
107176 +wdm_write_53735 wdm_write 3 53735 NULL
107177 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
107178 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
107179 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
107180 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
107181 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
107182 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
107183 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
107184 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
107185 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
107186 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
107187 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
107188 +pms_read_53873 pms_read 3 53873 NULL
107189 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
107190 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
107191 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
107192 +proc_file_read_53905 proc_file_read 3 53905 NULL
107193 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
107194 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
107195 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
107196 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
107197 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
107198 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
107199 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
107200 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
107201 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
107202 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
107203 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
107204 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
107205 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
107206 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
107207 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
107208 +_malloc_54077 _malloc 1 54077 NULL
107209 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
107210 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
107211 +create_xattr_54106 create_xattr 5 54106 NULL
107212 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
107213 +strn_len_54122 strn_len 0 54122 NULL
107214 +isku_receive_54130 isku_receive 4 54130 NULL
107215 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
107216 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
107217 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
107218 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
107219 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
107220 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
107221 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
107222 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
107223 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
107224 +reada_add_block_54247 reada_add_block 2 54247 NULL
107225 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
107226 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
107227 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
107228 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
107229 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
107230 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
107231 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
107232 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
107233 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
107234 +sprintf_54306 sprintf 0 54306 NULL
107235 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
107236 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
107237 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
107238 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
107239 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
107240 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
107241 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
107242 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
107243 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
107244 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
107245 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
107246 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
107247 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
107248 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
107249 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
107250 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
107251 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
107252 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
107253 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
107254 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
107255 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
107256 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
107257 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
107258 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
107259 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
107260 +viacam_read_54526 viacam_read 3 54526 NULL
107261 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
107262 +setsockopt_54539 setsockopt 5 54539 NULL
107263 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
107264 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
107265 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
107266 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
107267 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
107268 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
107269 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
107270 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
107271 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
107272 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
107273 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
107274 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
107275 +evm_read_key_54674 evm_read_key 3 54674 NULL
107276 +resource_string_54699 resource_string 0 54699 NULL
107277 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
107278 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
107279 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
107280 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
107281 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
107282 +kzalloc_54740 kzalloc 1 54740 NULL
107283 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
107284 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
107285 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
107286 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
107287 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
107288 +domain_init_54797 domain_init 2 54797 NULL
107289 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
107290 +get_dev_size_54807 get_dev_size 0 54807 NULL
107291 +nfsd_write_54809 nfsd_write 6 54809 NULL
107292 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
107293 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
107294 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
107295 +write_rio_54837 write_rio 3 54837 NULL
107296 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
107297 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
107298 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
107299 +printer_read_54851 printer_read 3 54851 NULL
107300 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
107301 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
107302 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
107303 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
107304 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
107305 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
107306 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
107307 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
107308 +add_port_54941 add_port 2 54941 NULL
107309 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
107310 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
107311 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
107312 +c4_add_card_54968 c4_add_card 3 54968 NULL
107313 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
107314 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
107315 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
107316 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
107317 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
107318 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
107319 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
107320 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
107321 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
107322 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
107323 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
107324 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
107325 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
107326 +corrupt_data_55120 corrupt_data 0 55120 NULL
107327 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
107328 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
107329 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
107330 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
107331 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
107332 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
107333 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
107334 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
107335 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
107336 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
107337 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
107338 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
107339 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
107340 +dump_command_55220 dump_command 1 55220 NULL
107341 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
107342 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
107343 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
107344 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
107345 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
107346 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
107347 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
107348 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
107349 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
107350 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
107351 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
107352 +do_shmat_55336 do_shmat 5 55336 NULL
107353 +vme_user_read_55338 vme_user_read 3 55338 NULL
107354 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
107355 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
107356 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
107357 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
107358 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
107359 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
107360 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
107361 +alloc_skb_55439 alloc_skb 1 55439 NULL
107362 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
107363 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
107364 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
107365 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
107366 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
107367 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
107368 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
107369 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
107370 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
107371 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
107372 +ea_get_55522 ea_get 0 55522 NULL
107373 +buffer_size_55534 buffer_size 0 55534 NULL
107374 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
107375 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
107376 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
107377 +add_partition_55588 add_partition 2 55588 NULL
107378 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
107379 +free_pages_55603 free_pages 1 55603 NULL
107380 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
107381 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
107382 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
107383 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
107384 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
107385 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
107386 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
107387 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
107388 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
107389 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
107390 +read_oldmem_55658 read_oldmem 3 55658 NULL
107391 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
107392 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
107393 +get_info_55681 get_info 3 55681 NULL
107394 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
107395 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
107396 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
107397 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
107398 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
107399 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
107400 +set_local_name_55757 set_local_name 4 55757 NULL
107401 +strlen_55778 strlen 0 55778 NULL
107402 +set_spte_55783 set_spte 5-4 55783 NULL
107403 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
107404 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
107405 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
107406 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
107407 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
107408 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
107409 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
107410 +hsc_write_55875 hsc_write 3 55875 NULL
107411 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
107412 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
107413 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
107414 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
107415 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
107416 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
107417 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
107418 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
107419 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
107420 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
107421 +__set_discard_56081 __set_discard 2 56081 NULL
107422 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
107423 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
107424 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
107425 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
107426 +map_addr_56144 map_addr 7 56144 NULL
107427 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
107428 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
107429 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
107430 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
107431 +skb_headroom_56200 skb_headroom 0 56200 NULL
107432 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
107433 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
107434 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
107435 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
107436 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
107437 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
107438 +fd_copyin_56247 fd_copyin 3 56247 NULL
107439 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
107440 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
107441 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
107442 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
107443 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
107444 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
107445 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
107446 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
107447 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
107448 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
107449 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
107450 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
107451 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
107452 +dev_read_56369 dev_read 3 56369 NULL
107453 +write_gssp_56404 write_gssp 3 56404 NULL
107454 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
107455 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
107456 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
107457 +store_msg_56417 store_msg 3 56417 NULL
107458 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
107459 +fl_create_56435 fl_create 5 56435 NULL
107460 +gnttab_map_56439 gnttab_map 2 56439 NULL
107461 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
107462 +set_connectable_56458 set_connectable 4 56458 NULL
107463 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
107464 +putused_user_56467 putused_user 3 56467 NULL
107465 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
107466 +global_rt_period_56476 global_rt_period 0 56476 NULL
107467 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
107468 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
107469 +init_map_ip_56508 init_map_ip 5 56508 NULL
107470 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
107471 +ip_options_get_56538 ip_options_get 4 56538 NULL
107472 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
107473 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
107474 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
107475 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
107476 +event_filter_write_56609 event_filter_write 3 56609 NULL
107477 +gather_array_56641 gather_array 3 56641 NULL
107478 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
107479 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
107480 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
107481 +build_map_info_56696 build_map_info 2 56696 NULL
107482 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
107483 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
107484 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
107485 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
107486 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
107487 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
107488 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
107489 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
107490 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
107491 +hash_lookup_56792 hash_lookup 2 56792 NULL
107492 +do_syslog_56807 do_syslog 3 56807 NULL
107493 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
107494 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
107495 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
107496 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
107497 +wb_lookup_56858 wb_lookup 2 56858 NULL
107498 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
107499 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
107500 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
107501 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
107502 +strcspn_56913 strcspn 0 56913 NULL
107503 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
107504 +check_header_56930 check_header 2 56930 NULL
107505 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
107506 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
107507 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
107508 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
107509 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
107510 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
107511 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
107512 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
107513 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
107514 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
107515 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
107516 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
107517 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
107518 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
107519 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
107520 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
107521 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
107522 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
107523 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
107524 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
107525 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
107526 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
107527 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
107528 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
107529 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
107530 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
107531 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
107532 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
107533 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
107534 +flush_space_57241 flush_space 3 57241 NULL
107535 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
107536 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
107537 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
107538 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
107539 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
107540 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
107541 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
107542 +fw_file_size_57307 fw_file_size 0 57307 NULL
107543 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
107544 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
107545 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
107546 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
107547 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
107548 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
107549 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
107550 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
107551 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
107552 +read_file_blob_57406 read_file_blob 3 57406 NULL
107553 +enclosure_register_57412 enclosure_register 3 57412 NULL
107554 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
107555 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
107556 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
107557 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
107558 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
107559 +ReadReg_57453 ReadReg 0 57453 NULL
107560 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
107561 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
107562 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
107563 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
107564 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
107565 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
107566 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
107567 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
107568 +skb_headlen_57501 skb_headlen 0 57501 NULL
107569 +copy_in_user_57502 copy_in_user 3 57502 NULL
107570 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
107571 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
107572 +init_tag_map_57515 init_tag_map 3 57515 NULL
107573 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
107574 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
107575 +inode_permission_57531 inode_permission 0 57531 NULL
107576 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
107577 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
107578 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
107579 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
107580 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
107581 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
107582 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
107583 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
107584 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
107585 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
107586 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
107587 +mem_read_57631 mem_read 3 57631 NULL
107588 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
107589 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
107590 +r3964_write_57662 r3964_write 4 57662 NULL
107591 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
107592 +__lgwrite_57669 __lgwrite 4 57669 NULL
107593 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
107594 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
107595 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
107596 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
107597 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
107598 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
107599 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
107600 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
107601 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
107602 +ld2_57794 ld2 0 57794 NULL
107603 +ivtv_read_57796 ivtv_read 3 57796 NULL
107604 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
107605 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
107606 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
107607 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
107608 +copy_to_user_57835 copy_to_user 3 57835 NULL
107609 +flash_read_57843 flash_read 3 57843 NULL
107610 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
107611 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
107612 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
107613 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
107614 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
107615 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
107616 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
107617 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
107618 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
107619 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
107620 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
107621 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
107622 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
107623 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
107624 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
107625 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
107626 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
107627 +mce_async_out_58056 mce_async_out 3 58056 NULL
107628 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
107629 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
107630 +cm4040_write_58079 cm4040_write 3 58079 NULL
107631 +udi_log_event_58105 udi_log_event 3 58105 NULL
107632 +savemem_58129 savemem 3 58129 NULL
107633 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
107634 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
107635 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
107636 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
107637 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
107638 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
107639 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
107640 +read_file_debug_58256 read_file_debug 3 58256 NULL
107641 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
107642 +profile_load_58267 profile_load 3 58267 NULL
107643 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
107644 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
107645 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
107646 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
107647 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
107648 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
107649 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
107650 +next_pidmap_58347 next_pidmap 2 58347 NULL
107651 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
107652 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
107653 +save_hint_58359 save_hint 2 58359 NULL
107654 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
107655 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
107656 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
107657 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
107658 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
107659 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
107660 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
107661 +capabilities_read_58457 capabilities_read 3 58457 NULL
107662 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
107663 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
107664 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
107665 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
107666 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
107667 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
107668 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
107669 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
107670 +__clear_discard_58546 __clear_discard 2 58546 NULL
107671 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
107672 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
107673 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
107674 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
107675 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
107676 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
107677 +xip_file_read_58592 xip_file_read 3 58592 NULL
107678 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
107679 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
107680 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
107681 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
107682 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
107683 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
107684 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
107685 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
107686 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
107687 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
107688 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
107689 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
107690 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
107691 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
107692 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
107693 +acpi_map_58725 acpi_map 1-2 58725 NULL
107694 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
107695 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
107696 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
107697 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
107698 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
107699 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
107700 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
107701 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
107702 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
107703 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
107704 +ep_read_58813 ep_read 3 58813 NULL
107705 +command_write_58841 command_write 3 58841 NULL
107706 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
107707 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
107708 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
107709 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
107710 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
107711 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
107712 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
107713 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
107714 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
107715 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
107716 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
107717 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
107718 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
107719 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
107720 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
107721 +ep_write_59008 ep_write 3 59008 NULL
107722 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
107723 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
107724 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
107725 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
107726 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
107727 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
107728 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
107729 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
107730 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
107731 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
107732 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
107733 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
107734 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
107735 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
107736 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
107737 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
107738 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
107739 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
107740 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
107741 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
107742 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
107743 +dt3155_read_59226 dt3155_read 3 59226 NULL
107744 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
107745 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
107746 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
107747 +nla_len_59258 nla_len 0 59258 NULL
107748 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
107749 +fd_copyout_59323 fd_copyout 3 59323 NULL
107750 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
107751 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
107752 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
107753 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
107754 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
107755 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
107756 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
107757 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
107758 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
107759 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
107760 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
107761 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
107762 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
107763 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
107764 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
107765 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
107766 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
107767 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
107768 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
107769 +tunables_write_59563 tunables_write 3 59563 NULL
107770 +memdup_user_59590 memdup_user 2 59590 NULL
107771 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
107772 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
107773 +mtrr_write_59622 mtrr_write 3 59622 NULL
107774 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
107775 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
107776 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
107777 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
107778 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
107779 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
107780 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
107781 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
107782 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
107783 +sriov_enable_59689 sriov_enable 2 59689 NULL
107784 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
107785 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
107786 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
107787 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
107788 +strnlen_59746 strnlen 0 59746 NULL
107789 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
107790 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
107791 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
107792 +venus_remove_59781 venus_remove 4 59781 NULL
107793 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
107794 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
107795 +ipw_write_59807 ipw_write 3 59807 NULL
107796 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
107797 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
107798 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
107799 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
107800 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
107801 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
107802 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
107803 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
107804 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
107805 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
107806 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
107807 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
107808 +lookup_node_59953 lookup_node 2 59953 NULL
107809 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
107810 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
107811 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
107812 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
107813 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
107814 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
107815 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
107816 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
107817 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
107818 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
107819 +register_device_60015 register_device 2-3 60015 NULL
107820 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
107821 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
107822 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
107823 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
107824 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
107825 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
107826 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
107827 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
107828 +compat_writev_60063 compat_writev 3 60063 NULL
107829 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
107830 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
107831 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
107832 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
107833 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
107834 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
107835 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
107836 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
107837 +init_state_60165 init_state 2 60165 NULL
107838 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
107839 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
107840 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
107841 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
107842 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
107843 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
107844 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
107845 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
107846 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
107847 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
107848 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
107849 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
107850 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
107851 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
107852 +printer_write_60276 printer_write 3 60276 NULL
107853 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
107854 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
107855 +getDataLength_60301 getDataLength 0 60301 NULL
107856 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
107857 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
107858 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
107859 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
107860 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
107861 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
107862 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
107863 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
107864 +driver_names_read_60399 driver_names_read 3 60399 NULL
107865 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
107866 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
107867 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
107868 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
107869 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
107870 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
107871 +rx_data_60442 rx_data 4 60442 NULL nohasharray
107872 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
107873 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
107874 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
107875 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
107876 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
107877 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
107878 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
107879 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
107880 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
107881 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
107882 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
107883 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
107884 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
107885 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
107886 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
107887 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
107888 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
107889 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
107890 +init_data_container_60709 init_data_container 1 60709 NULL
107891 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
107892 +raid_status_60755 raid_status 5 60755 NULL
107893 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
107894 +opticon_write_60775 opticon_write 4 60775 NULL
107895 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
107896 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
107897 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
107898 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
107899 +generic_writepages_60871 generic_writepages 0 60871 NULL
107900 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
107901 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
107902 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
107903 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
107904 +sys_mlock_60932 sys_mlock 1 60932 NULL
107905 +pti_char_write_60960 pti_char_write 3 60960 NULL
107906 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
107907 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
107908 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
107909 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
107910 +symtab_init_61050 symtab_init 2 61050 NULL
107911 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
107912 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
107913 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
107914 +get_derived_key_61100 get_derived_key 4 61100 NULL
107915 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
107916 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
107917 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
107918 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
107919 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
107920 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
107921 +__vmalloc_61168 __vmalloc 1 61168 NULL
107922 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
107923 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
107924 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
107925 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
107926 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
107927 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
107928 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
107929 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
107930 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
107931 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
107932 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
107933 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
107934 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
107935 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
107936 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
107937 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
107938 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
107939 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
107940 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
107941 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
107942 +change_xattr_61390 change_xattr 5 61390 NULL
107943 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
107944 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
107945 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
107946 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
107947 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
107948 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
107949 +erst_errno_61526 erst_errno 0 61526 NULL
107950 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
107951 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
107952 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
107953 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
107954 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
107955 +seq_open_private_61589 seq_open_private 3 61589 NULL
107956 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
107957 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
107958 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
107959 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
107960 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
107961 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
107962 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
107963 +resize_stripes_61650 resize_stripes 2 61650 NULL
107964 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
107965 +insert_one_name_61668 insert_one_name 7 61668 NULL
107966 +lock_loop_61681 lock_loop 1 61681 NULL
107967 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
107968 +filter_read_61692 filter_read 3 61692 NULL
107969 +iov_length_61716 iov_length 0 61716 NULL
107970 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
107971 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
107972 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
107973 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
107974 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
107975 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
107976 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
107977 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
107978 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
107979 +get_fw_name_61874 get_fw_name 3 61874 NULL
107980 +free_init_pages_61875 free_init_pages 2 61875 NULL
107981 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
107982 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
107983 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
107984 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
107985 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
107986 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
107987 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
107988 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
107989 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
107990 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
107991 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
107992 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
107993 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
107994 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
107995 +cow_file_range_61979 cow_file_range 3 61979 NULL
107996 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
107997 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
107998 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
107999 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
108000 +SYSC_select_62024 SYSC_select 1 62024 NULL
108001 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
108002 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
108003 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
108004 +do_pselect_62061 do_pselect 1 62061 NULL
108005 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
108006 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
108007 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
108008 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
108009 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
108010 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
108011 +ql_status_62135 ql_status 5 62135 NULL
108012 +video_usercopy_62151 video_usercopy 2 62151 NULL
108013 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
108014 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
108015 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
108016 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
108017 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
108018 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
108019 +allocate_partition_62245 allocate_partition 4 62245 NULL
108020 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
108021 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
108022 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
108023 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
108024 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
108025 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
108026 +subseq_list_62332 subseq_list 3-0 62332 NULL
108027 +flash_write_62354 flash_write 3 62354 NULL
108028 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
108029 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
108030 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
108031 +altera_irscan_62396 altera_irscan 2 62396 NULL
108032 +set_ssp_62411 set_ssp 4 62411 NULL
108033 +unmap_single_62423 unmap_single 2 62423 NULL
108034 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
108035 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
108036 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
108037 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
108038 +remove_mapping_62491 remove_mapping 2 62491 NULL
108039 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
108040 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
108041 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
108042 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
108043 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
108044 +debugfs_read_62535 debugfs_read 3 62535 NULL
108045 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
108046 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
108047 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
108048 +get_subdir_62581 get_subdir 3 62581 NULL
108049 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
108050 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
108051 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
108052 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
108053 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
108054 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
108055 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
108056 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
108057 +write_62671 write 3 62671 NULL
108058 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
108059 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
108060 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
108061 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
108062 +rdm_62719 rdm 0 62719 NULL
108063 +key_replays_read_62746 key_replays_read 3 62746 NULL
108064 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
108065 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
108066 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
108067 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
108068 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
108069 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
108070 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
108071 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
108072 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
108073 +set_swbp_62853 set_swbp 3 62853 NULL
108074 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
108075 +aoechr_write_62883 aoechr_write 3 62883 NULL
108076 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
108077 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
108078 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
108079 +getdqbuf_62908 getdqbuf 1 62908 NULL
108080 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
108081 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
108082 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
108083 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
108084 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
108085 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
108086 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
108087 +unlink1_63059 unlink1 3 63059 NULL
108088 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
108089 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
108090 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
108091 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
108092 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
108093 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
108094 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
108095 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
108096 +vme_master_read_63221 vme_master_read 0 63221 NULL
108097 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
108098 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
108099 +ptp_read_63251 ptp_read 4 63251 NULL
108100 +raid5_resize_63306 raid5_resize 2 63306 NULL
108101 +proc_info_read_63344 proc_info_read 3 63344 NULL
108102 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
108103 +idmouse_read_63374 idmouse_read 3 63374 NULL
108104 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
108105 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
108106 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
108107 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
108108 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
108109 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
108110 +kone_send_63435 kone_send 4 63435 NULL
108111 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
108112 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
108113 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
108114 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
108115 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
108116 +read_kcore_63488 read_kcore 3 63488 NULL
108117 +save_hint_63497 save_hint 2 63497 NULL
108118 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
108119 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
108120 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
108121 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
108122 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
108123 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
108124 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
108125 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
108126 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
108127 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
108128 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
108129 +module_alloc_63630 module_alloc 1 63630 NULL
108130 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
108131 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
108132 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
108133 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
108134 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
108135 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
108136 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
108137 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
108138 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
108139 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
108140 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
108141 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
108142 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
108143 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
108144 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
108145 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
108146 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
108147 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
108148 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
108149 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
108150 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
108151 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
108152 +prepare_copy_63826 prepare_copy 2 63826 NULL
108153 +sel_write_load_63830 sel_write_load 3 63830 NULL
108154 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
108155 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
108156 +divas_write_63901 divas_write 3 63901 NULL
108157 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
108158 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
108159 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
108160 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
108161 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
108162 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
108163 +__team_options_register_63941 __team_options_register 3 63941 NULL
108164 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
108165 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
108166 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
108167 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
108168 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
108169 +kmemdup_64015 kmemdup 2 64015 NULL
108170 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
108171 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
108172 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
108173 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
108174 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
108175 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
108176 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
108177 +get_u8_64076 get_u8 0 64076 NULL
108178 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
108179 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
108180 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
108181 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
108182 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
108183 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
108184 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
108185 +init_bch_64130 init_bch 1-2 64130 NULL
108186 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
108187 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
108188 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
108189 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
108190 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
108191 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
108192 +read_pulse_64227 read_pulse 0-3 64227 NULL
108193 +header_len_64232 header_len 0 64232 NULL
108194 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
108195 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
108196 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
108197 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
108198 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
108199 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
108200 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
108201 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
108202 +ffz_64324 ffz 0 64324 NULL
108203 +map_region_64328 map_region 1 64328 NULL
108204 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
108205 +ts_write_64336 ts_write 3 64336 NULL
108206 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
108207 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
108208 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
108209 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
108210 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
108211 +ilo_write_64378 ilo_write 3 64378 NULL
108212 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
108213 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
108214 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
108215 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
108216 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
108217 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
108218 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
108219 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
108220 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
108221 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
108222 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
108223 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
108224 +cap_capable_64462 cap_capable 0 64462 NULL
108225 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
108226 +single_open_size_64483 single_open_size 4 64483 NULL
108227 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
108228 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
108229 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
108230 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
108231 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
108232 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
108233 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
108234 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
108235 +SyS_bind_64544 SyS_bind 3 64544 NULL
108236 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
108237 +__spi_sync_64561 __spi_sync 0 64561 NULL
108238 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
108239 +fanotify_write_64623 fanotify_write 3 64623 NULL
108240 +to_dblock_64655 to_dblock 0-1 64655 NULL
108241 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
108242 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
108243 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
108244 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
108245 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
108246 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
108247 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
108248 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
108249 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
108250 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
108251 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
108252 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
108253 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
108254 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
108255 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
108256 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
108257 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
108258 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
108259 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
108260 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
108261 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
108262 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
108263 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
108264 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
108265 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
108266 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
108267 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
108268 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
108269 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
108270 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
108271 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
108272 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
108273 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
108274 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
108275 +pskb_pull_65005 pskb_pull 2 65005 NULL
108276 +unifi_write_65012 unifi_write 3 65012 NULL
108277 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
108278 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
108279 +insert_dent_65034 insert_dent 7 65034 NULL
108280 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
108281 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
108282 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
108283 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
108284 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
108285 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
108286 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
108287 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
108288 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
108289 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
108290 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
108291 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
108292 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
108293 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
108294 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
108295 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
108296 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
108297 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
108298 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
108299 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
108300 +get_var_len_65304 get_var_len 0 65304 NULL
108301 +unpack_array_65318 unpack_array 0 65318 NULL
108302 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
108303 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
108304 +init_list_set_65351 init_list_set 2-3 65351 NULL
108305 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
108306 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
108307 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
108308 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
108309 +strchr_65372 strchr 0 65372 NULL nohasharray
108310 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
108311 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
108312 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
108313 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
108314 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
108315 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
108316 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
108317 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
108318 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
108319 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
108320 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
108321 +alloc_dr_65495 alloc_dr 2 65495 NULL
108322 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
108323 new file mode 100644
108324 index 0000000..03d0c84
108325 --- /dev/null
108326 +++ b/tools/gcc/size_overflow_plugin.c
108327 @@ -0,0 +1,2113 @@
108328 +/*
108329 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
108330 + * Licensed under the GPL v2, or (at your option) v3
108331 + *
108332 + * Homepage:
108333 + * http://www.grsecurity.net/~ephox/overflow_plugin/
108334 + *
108335 + * Documentation:
108336 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
108337 + *
108338 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
108339 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
108340 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
108341 + *
108342 + * Usage:
108343 + * $ 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
108344 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
108345 + */
108346 +
108347 +#include "gcc-plugin.h"
108348 +#include "config.h"
108349 +#include "system.h"
108350 +#include "coretypes.h"
108351 +#include "tree.h"
108352 +#include "tree-pass.h"
108353 +#include "intl.h"
108354 +#include "plugin-version.h"
108355 +#include "tm.h"
108356 +#include "toplev.h"
108357 +#include "function.h"
108358 +#include "tree-flow.h"
108359 +#include "plugin.h"
108360 +#include "gimple.h"
108361 +#include "diagnostic.h"
108362 +#include "cfgloop.h"
108363 +
108364 +#if BUILDING_GCC_VERSION >= 4008
108365 +#define TODO_dump_func 0
108366 +#endif
108367 +
108368 +struct size_overflow_hash {
108369 + const struct size_overflow_hash * const next;
108370 + const char * const name;
108371 + const unsigned int param;
108372 +};
108373 +
108374 +#include "size_overflow_hash.h"
108375 +
108376 +enum mark {
108377 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
108378 +};
108379 +
108380 +enum err_code_conditions {
108381 + CAST_ONLY, FROM_CONST
108382 +};
108383 +
108384 +static unsigned int call_count = 0;
108385 +
108386 +#define __unused __attribute__((__unused__))
108387 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
108388 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
108389 +#define BEFORE_STMT true
108390 +#define AFTER_STMT false
108391 +#define CREATE_NEW_VAR NULL_TREE
108392 +#define CODES_LIMIT 32
108393 +#define MAX_PARAM 31
108394 +#define MY_STMT GF_PLF_1
108395 +#define NO_CAST_CHECK GF_PLF_2
108396 +#define FROM_ARG true
108397 +#define FROM_RET false
108398 +
108399 +#if BUILDING_GCC_VERSION == 4005
108400 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
108401 +#endif
108402 +
108403 +int plugin_is_GPL_compatible;
108404 +void debug_gimple_stmt(gimple gs);
108405 +
108406 +static tree expand(struct pointer_set_t *visited, tree lhs);
108407 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
108408 +static tree report_size_overflow_decl;
108409 +static const_tree const_char_ptr_type_node;
108410 +static unsigned int handle_function(void);
108411 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
108412 +static tree get_size_overflow_type(gimple stmt, const_tree node);
108413 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
108414 +static void print_missing_msg(tree func, unsigned int argnum);
108415 +
108416 +static struct plugin_info size_overflow_plugin_info = {
108417 + .version = "20130822beta",
108418 + .help = "no-size-overflow\tturn off size overflow checking\n",
108419 +};
108420 +
108421 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108422 +{
108423 + unsigned int arg_count;
108424 + enum tree_code code = TREE_CODE(*node);
108425 +
108426 + switch (code) {
108427 + case FUNCTION_DECL:
108428 + arg_count = type_num_arguments(TREE_TYPE(*node));
108429 + break;
108430 + case FUNCTION_TYPE:
108431 + case METHOD_TYPE:
108432 + arg_count = type_num_arguments(*node);
108433 + break;
108434 + default:
108435 + *no_add_attrs = true;
108436 + error("%s: %qE attribute only applies to functions", __func__, name);
108437 + return NULL_TREE;
108438 + }
108439 +
108440 + for (; args; args = TREE_CHAIN(args)) {
108441 + tree position = TREE_VALUE(args);
108442 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108443 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108444 + *no_add_attrs = true;
108445 + }
108446 + }
108447 + return NULL_TREE;
108448 +}
108449 +
108450 +static const char* get_asm_name(tree node)
108451 +{
108452 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
108453 +}
108454 +
108455 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
108456 +{
108457 + unsigned int arg_count, arg_num;
108458 + enum tree_code code = TREE_CODE(*node);
108459 +
108460 + switch (code) {
108461 + case FUNCTION_DECL:
108462 + arg_count = type_num_arguments(TREE_TYPE(*node));
108463 + break;
108464 + case FUNCTION_TYPE:
108465 + case METHOD_TYPE:
108466 + arg_count = type_num_arguments(*node);
108467 + break;
108468 + case FIELD_DECL:
108469 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
108470 + if (arg_num != 0) {
108471 + *no_add_attrs = true;
108472 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
108473 + }
108474 + return NULL_TREE;
108475 + default:
108476 + *no_add_attrs = true;
108477 + error("%qE attribute only applies to functions", name);
108478 + return NULL_TREE;
108479 + }
108480 +
108481 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
108482 + return NULL_TREE;
108483 +
108484 + for (; args; args = TREE_CHAIN(args)) {
108485 + tree position = TREE_VALUE(args);
108486 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
108487 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
108488 + *no_add_attrs = true;
108489 + }
108490 + }
108491 + return NULL_TREE;
108492 +}
108493 +
108494 +static struct attribute_spec size_overflow_attr = {
108495 + .name = "size_overflow",
108496 + .min_length = 1,
108497 + .max_length = -1,
108498 + .decl_required = true,
108499 + .type_required = false,
108500 + .function_type_required = false,
108501 + .handler = handle_size_overflow_attribute,
108502 +#if BUILDING_GCC_VERSION >= 4007
108503 + .affects_type_identity = false
108504 +#endif
108505 +};
108506 +
108507 +static struct attribute_spec intentional_overflow_attr = {
108508 + .name = "intentional_overflow",
108509 + .min_length = 1,
108510 + .max_length = -1,
108511 + .decl_required = true,
108512 + .type_required = false,
108513 + .function_type_required = false,
108514 + .handler = handle_intentional_overflow_attribute,
108515 +#if BUILDING_GCC_VERSION >= 4007
108516 + .affects_type_identity = false
108517 +#endif
108518 +};
108519 +
108520 +static void register_attributes(void __unused *event_data, void __unused *data)
108521 +{
108522 + register_attribute(&size_overflow_attr);
108523 + register_attribute(&intentional_overflow_attr);
108524 +}
108525 +
108526 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
108527 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
108528 +{
108529 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
108530 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
108531 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
108532 +
108533 + unsigned int m = 0x57559429;
108534 + unsigned int n = 0x5052acdb;
108535 + const unsigned int *key4 = (const unsigned int *)key;
108536 + unsigned int h = len;
108537 + unsigned int k = len + seed + n;
108538 + unsigned long long p;
108539 +
108540 + while (len >= 8) {
108541 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
108542 + len -= 8;
108543 + }
108544 + if (len >= 4) {
108545 + cwmixb(key4[0]) key4 += 1;
108546 + len -= 4;
108547 + }
108548 + if (len)
108549 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
108550 + cwmixb(h ^ (k + n));
108551 + return k ^ h;
108552 +
108553 +#undef cwfold
108554 +#undef cwmixa
108555 +#undef cwmixb
108556 +}
108557 +
108558 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
108559 +{
108560 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
108561 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
108562 + return fn ^ codes;
108563 +}
108564 +
108565 +static inline tree get_original_function_decl(tree fndecl)
108566 +{
108567 + if (DECL_ABSTRACT_ORIGIN(fndecl))
108568 + return DECL_ABSTRACT_ORIGIN(fndecl);
108569 + return fndecl;
108570 +}
108571 +
108572 +static inline gimple get_def_stmt(const_tree node)
108573 +{
108574 + gcc_assert(node != NULL_TREE);
108575 + if (TREE_CODE(node) != SSA_NAME)
108576 + return NULL;
108577 + return SSA_NAME_DEF_STMT(node);
108578 +}
108579 +
108580 +static unsigned char get_tree_code(const_tree type)
108581 +{
108582 + switch (TREE_CODE(type)) {
108583 + case ARRAY_TYPE:
108584 + return 0;
108585 + case BOOLEAN_TYPE:
108586 + return 1;
108587 + case ENUMERAL_TYPE:
108588 + return 2;
108589 + case FUNCTION_TYPE:
108590 + return 3;
108591 + case INTEGER_TYPE:
108592 + return 4;
108593 + case POINTER_TYPE:
108594 + return 5;
108595 + case RECORD_TYPE:
108596 + return 6;
108597 + case UNION_TYPE:
108598 + return 7;
108599 + case VOID_TYPE:
108600 + return 8;
108601 + case REAL_TYPE:
108602 + return 9;
108603 + case VECTOR_TYPE:
108604 + return 10;
108605 + case REFERENCE_TYPE:
108606 + return 11;
108607 + case OFFSET_TYPE:
108608 + return 12;
108609 + case COMPLEX_TYPE:
108610 + return 13;
108611 + default:
108612 + debug_tree((tree)type);
108613 + gcc_unreachable();
108614 + }
108615 +}
108616 +
108617 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
108618 +{
108619 + gcc_assert(type != NULL_TREE);
108620 +
108621 + while (type && len < CODES_LIMIT) {
108622 + tree_codes[len] = get_tree_code(type);
108623 + len++;
108624 + type = TREE_TYPE(type);
108625 + }
108626 + return len;
108627 +}
108628 +
108629 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
108630 +{
108631 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
108632 + enum tree_code code = TREE_CODE(type);
108633 + size_t len = 0;
108634 +
108635 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
108636 +
108637 + arg = TYPE_ARG_TYPES(type);
108638 + // skip builtins __builtin_constant_p
108639 + if (!arg && DECL_BUILT_IN(fndecl))
108640 + return 0;
108641 +
108642 + if (TREE_CODE_CLASS(code) == tcc_type)
108643 + result = type;
108644 + else
108645 + result = DECL_RESULT(fndecl);
108646 +
108647 + gcc_assert(result != NULL_TREE);
108648 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
108649 +
108650 + if (arg == NULL_TREE) {
108651 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
108652 + arg_field = DECL_ARGUMENT_FLD(fndecl);
108653 + if (arg_field == NULL_TREE)
108654 + return 0;
108655 + arg = TREE_TYPE(arg_field);
108656 + len = add_type_codes(arg, tree_codes, len);
108657 + gcc_assert(len != 0);
108658 + return len;
108659 + }
108660 +
108661 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
108662 + while (arg && len < CODES_LIMIT) {
108663 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
108664 + arg = TREE_CHAIN(arg);
108665 + }
108666 +
108667 + gcc_assert(len != 0);
108668 + return len;
108669 +}
108670 +
108671 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
108672 +{
108673 + unsigned int hash;
108674 + const struct size_overflow_hash *entry;
108675 + unsigned char tree_codes[CODES_LIMIT];
108676 + size_t len;
108677 + const char *func_name;
108678 +
108679 + fndecl = get_original_function_decl(fndecl);
108680 + len = get_function_decl(fndecl, tree_codes);
108681 + if (len == 0)
108682 + return NULL;
108683 +
108684 + func_name = get_asm_name(fndecl);
108685 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
108686 +
108687 + entry = size_overflow_hash[hash];
108688 + while (entry) {
108689 + if (!strcmp(entry->name, func_name))
108690 + return entry;
108691 + entry = entry->next;
108692 + }
108693 +
108694 + return NULL;
108695 +}
108696 +
108697 +static bool is_bool(const_tree node)
108698 +{
108699 + const_tree type;
108700 +
108701 + if (node == NULL_TREE)
108702 + return false;
108703 +
108704 + type = TREE_TYPE(node);
108705 + if (!INTEGRAL_TYPE_P(type))
108706 + return false;
108707 + if (TREE_CODE(type) == BOOLEAN_TYPE)
108708 + return true;
108709 + if (TYPE_PRECISION(type) == 1)
108710 + return true;
108711 + return false;
108712 +}
108713 +
108714 +static bool skip_types(const_tree var)
108715 +{
108716 + tree type;
108717 +
108718 + if (is_gimple_constant(var))
108719 + return true;
108720 +
108721 + switch (TREE_CODE(var)) {
108722 + case ADDR_EXPR:
108723 +#if BUILDING_GCC_VERSION >= 4006
108724 + case MEM_REF:
108725 +#endif
108726 + case ARRAY_REF:
108727 + case BIT_FIELD_REF:
108728 + case INDIRECT_REF:
108729 + case TARGET_MEM_REF:
108730 + return true;
108731 + case PARM_DECL:
108732 + case VAR_DECL:
108733 + case COMPONENT_REF:
108734 + return false;
108735 + default:
108736 + break;
108737 + }
108738 +
108739 + gcc_assert(TREE_CODE(var) == SSA_NAME);
108740 +
108741 + type = TREE_TYPE(var);
108742 + switch (TREE_CODE(type)) {
108743 + case INTEGER_TYPE:
108744 + case ENUMERAL_TYPE:
108745 + return false;
108746 + case BOOLEAN_TYPE:
108747 + return is_bool(var);
108748 + default:
108749 + break;
108750 + }
108751 +
108752 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
108753 +
108754 + type = TREE_TYPE(type);
108755 + gcc_assert(type != NULL_TREE);
108756 + switch (TREE_CODE(type)) {
108757 + case RECORD_TYPE:
108758 + case POINTER_TYPE:
108759 + case ARRAY_TYPE:
108760 + return true;
108761 + case VOID_TYPE:
108762 + case INTEGER_TYPE:
108763 + case UNION_TYPE:
108764 + return false;
108765 + default:
108766 + break;
108767 + }
108768 +
108769 + debug_tree((tree)var);
108770 + gcc_unreachable();
108771 +}
108772 +
108773 +static unsigned int find_arg_number(const_tree arg, tree func)
108774 +{
108775 + tree var;
108776 + unsigned int argnum = 1;
108777 +
108778 + if (TREE_CODE(arg) == SSA_NAME)
108779 + arg = SSA_NAME_VAR(arg);
108780 +
108781 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
108782 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
108783 + continue;
108784 + if (!skip_types(var))
108785 + return argnum;
108786 + }
108787 +
108788 + return 0;
108789 +}
108790 +
108791 +static tree create_new_var(tree type)
108792 +{
108793 + tree new_var = create_tmp_var(type, "cicus");
108794 +
108795 +#if BUILDING_GCC_VERSION <= 4007
108796 + add_referenced_var(new_var);
108797 +#endif
108798 + return new_var;
108799 +}
108800 +
108801 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
108802 +{
108803 + gimple assign;
108804 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
108805 + tree type = TREE_TYPE(rhs1);
108806 + tree lhs = create_new_var(type);
108807 +
108808 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
108809 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
108810 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108811 +
108812 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
108813 + update_stmt(assign);
108814 + gimple_set_plf(assign, MY_STMT, true);
108815 + return assign;
108816 +}
108817 +
108818 +static tree cast_a_tree(tree type, tree var)
108819 +{
108820 + gcc_assert(type != NULL_TREE);
108821 + gcc_assert(var != NULL_TREE);
108822 + gcc_assert(fold_convertible_p(type, var));
108823 +
108824 + return fold_convert(type, var);
108825 +}
108826 +
108827 +static tree get_lhs(const_gimple stmt)
108828 +{
108829 + switch (gimple_code(stmt)) {
108830 + case GIMPLE_ASSIGN:
108831 + return gimple_get_lhs(stmt);
108832 + case GIMPLE_PHI:
108833 + return gimple_phi_result(stmt);
108834 + case GIMPLE_CALL:
108835 + return gimple_call_lhs(stmt);
108836 + default:
108837 + return NULL_TREE;
108838 + }
108839 +}
108840 +
108841 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
108842 +{
108843 + const_gimple def_stmt = get_def_stmt(rhs);
108844 +
108845 + if (force)
108846 + return false;
108847 +
108848 + if (is_gimple_constant(rhs))
108849 + return false;
108850 +
108851 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
108852 + return false;
108853 +
108854 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
108855 + return false;
108856 +
108857 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
108858 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
108859 + return false;
108860 +
108861 + return true;
108862 +}
108863 +
108864 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
108865 +{
108866 + gimple assign, def_stmt;
108867 +
108868 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
108869 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
108870 + gcc_unreachable();
108871 +
108872 + def_stmt = get_def_stmt(rhs);
108873 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
108874 + return def_stmt;
108875 +
108876 + if (lhs == CREATE_NEW_VAR)
108877 + lhs = create_new_var(dst_type);
108878 +
108879 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
108880 +
108881 + if (!gsi_end_p(*gsi)) {
108882 + location_t loc = gimple_location(gsi_stmt(*gsi));
108883 + gimple_set_location(assign, loc);
108884 + }
108885 +
108886 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
108887 +
108888 + if (before)
108889 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
108890 + else
108891 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
108892 + update_stmt(assign);
108893 + gimple_set_plf(assign, MY_STMT, true);
108894 +
108895 + return assign;
108896 +}
108897 +
108898 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
108899 +{
108900 + gimple_stmt_iterator gsi;
108901 + tree lhs;
108902 + const_gimple new_stmt;
108903 +
108904 + if (rhs == NULL_TREE)
108905 + return NULL_TREE;
108906 +
108907 + gsi = gsi_for_stmt(stmt);
108908 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
108909 +
108910 + lhs = get_lhs(new_stmt);
108911 + gcc_assert(lhs != NULL_TREE);
108912 + return lhs;
108913 +}
108914 +
108915 +static tree cast_to_TI_type(gimple stmt, tree node)
108916 +{
108917 + gimple_stmt_iterator gsi;
108918 + gimple cast_stmt;
108919 + tree type = TREE_TYPE(node);
108920 +
108921 + if (types_compatible_p(type, intTI_type_node))
108922 + return node;
108923 +
108924 + gsi = gsi_for_stmt(stmt);
108925 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
108926 + return gimple_get_lhs(cast_stmt);
108927 +}
108928 +
108929 +static void check_function_hash(const_gimple stmt)
108930 +{
108931 + tree func;
108932 + const struct size_overflow_hash *hash;
108933 +
108934 + if (gimple_code(stmt) != GIMPLE_CALL)
108935 + return;
108936 +
108937 + func = gimple_call_fndecl(stmt);
108938 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
108939 + if (func == NULL_TREE)
108940 + return;
108941 +
108942 + hash = get_function_hash(func);
108943 + if (!hash)
108944 + print_missing_msg(func, 0);
108945 +}
108946 +
108947 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
108948 +{
108949 + tree lhs, new_lhs;
108950 + gimple_stmt_iterator gsi;
108951 +
108952 + if (rhs1 == NULL_TREE) {
108953 + debug_gimple_stmt(oldstmt);
108954 + error("%s: rhs1 is NULL_TREE", __func__);
108955 + gcc_unreachable();
108956 + }
108957 +
108958 + switch (gimple_code(oldstmt)) {
108959 + case GIMPLE_ASM:
108960 + lhs = rhs1;
108961 + break;
108962 + case GIMPLE_CALL:
108963 + lhs = gimple_call_lhs(oldstmt);
108964 + break;
108965 + case GIMPLE_ASSIGN:
108966 + lhs = gimple_get_lhs(oldstmt);
108967 + break;
108968 + default:
108969 + debug_gimple_stmt(oldstmt);
108970 + gcc_unreachable();
108971 + }
108972 +
108973 + gsi = gsi_for_stmt(oldstmt);
108974 + pointer_set_insert(visited, oldstmt);
108975 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
108976 + basic_block next_bb, cur_bb;
108977 + const_edge e;
108978 +
108979 + gcc_assert(before == false);
108980 + gcc_assert(stmt_can_throw_internal(oldstmt));
108981 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
108982 + gcc_assert(!gsi_end_p(gsi));
108983 +
108984 + cur_bb = gimple_bb(oldstmt);
108985 + next_bb = cur_bb->next_bb;
108986 + e = find_edge(cur_bb, next_bb);
108987 + gcc_assert(e != NULL);
108988 + gcc_assert(e->flags & EDGE_FALLTHRU);
108989 +
108990 + gsi = gsi_after_labels(next_bb);
108991 + gcc_assert(!gsi_end_p(gsi));
108992 +
108993 + before = true;
108994 + oldstmt = gsi_stmt(gsi);
108995 + }
108996 +
108997 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
108998 + return new_lhs;
108999 +}
109000 +
109001 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
109002 +{
109003 + gimple stmt;
109004 + gimple_stmt_iterator gsi;
109005 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
109006 +
109007 + if (gimple_plf(oldstmt, MY_STMT))
109008 + return lhs;
109009 +
109010 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
109011 + rhs1 = gimple_assign_rhs1(oldstmt);
109012 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
109013 + }
109014 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
109015 + rhs2 = gimple_assign_rhs2(oldstmt);
109016 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
109017 + }
109018 +
109019 + stmt = gimple_copy(oldstmt);
109020 + gimple_set_location(stmt, gimple_location(oldstmt));
109021 + gimple_set_plf(stmt, MY_STMT, true);
109022 +
109023 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
109024 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
109025 +
109026 + size_overflow_type = get_size_overflow_type(oldstmt, node);
109027 +
109028 + new_var = create_new_var(size_overflow_type);
109029 + new_var = make_ssa_name(new_var, stmt);
109030 + gimple_set_lhs(stmt, new_var);
109031 +
109032 + if (rhs1 != NULL_TREE)
109033 + gimple_assign_set_rhs1(stmt, rhs1);
109034 +
109035 + if (rhs2 != NULL_TREE)
109036 + gimple_assign_set_rhs2(stmt, rhs2);
109037 +#if BUILDING_GCC_VERSION >= 4007
109038 + if (rhs3 != NULL_TREE)
109039 + gimple_assign_set_rhs3(stmt, rhs3);
109040 +#endif
109041 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
109042 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
109043 +
109044 + gsi = gsi_for_stmt(oldstmt);
109045 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
109046 + update_stmt(stmt);
109047 + pointer_set_insert(visited, oldstmt);
109048 + return gimple_get_lhs(stmt);
109049 +}
109050 +
109051 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
109052 +{
109053 + basic_block first_bb;
109054 + gimple assign;
109055 + gimple_stmt_iterator gsi;
109056 +
109057 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
109058 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109059 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
109060 +
109061 + gsi = gsi_start_bb(first_bb);
109062 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
109063 + return gimple_get_lhs(assign);
109064 +}
109065 +
109066 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
109067 +{
109068 + gimple_stmt_iterator gsi;
109069 + const_gimple assign;
109070 + gimple def_stmt = get_def_stmt(new_arg);
109071 +
109072 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
109073 + gsi = gsi_after_labels(gimple_bb(def_stmt));
109074 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
109075 + } else {
109076 + gsi = gsi_for_stmt(def_stmt);
109077 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
109078 + }
109079 +
109080 + return gimple_get_lhs(assign);
109081 +}
109082 +
109083 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
109084 +{
109085 + basic_block bb;
109086 + gimple_stmt_iterator gsi;
109087 + const_gimple assign, def_stmt;
109088 +
109089 + def_stmt = get_def_stmt(arg);
109090 + bb = gimple_bb(def_stmt);
109091 + gcc_assert(bb->index != 0);
109092 + gsi = gsi_after_labels(bb);
109093 +
109094 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
109095 + return gimple_get_lhs(assign);
109096 +}
109097 +
109098 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
109099 +{
109100 + tree size_overflow_type;
109101 + const_gimple def_stmt = get_def_stmt(arg);
109102 +
109103 + if (phi_ssa_name != NULL_TREE)
109104 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
109105 +
109106 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
109107 +
109108 + if (new_arg != NULL_TREE) {
109109 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
109110 + return use_phi_ssa_name(phi_ssa_name, new_arg);
109111 + }
109112 +
109113 + switch(gimple_code(def_stmt)) {
109114 + case GIMPLE_PHI:
109115 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
109116 + case GIMPLE_NOP:
109117 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
109118 + default:
109119 + debug_gimple_stmt((gimple)def_stmt);
109120 + gcc_unreachable();
109121 + }
109122 +}
109123 +
109124 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
109125 +{
109126 + basic_block bb;
109127 + gimple phi;
109128 + gimple_seq seq;
109129 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
109130 +
109131 + bb = gsi_bb(gsi);
109132 +
109133 + phi = create_phi_node(result, bb);
109134 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
109135 + seq = phi_nodes(bb);
109136 + gsi = gsi_last(seq);
109137 + gsi_remove(&gsi, false);
109138 +
109139 + gsi = gsi_for_stmt(oldstmt);
109140 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
109141 + gimple_set_bb(phi, bb);
109142 + gimple_set_plf(phi, MY_STMT, true);
109143 + return phi;
109144 +}
109145 +
109146 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
109147 +{
109148 + gimple new_phi = NULL;
109149 + gimple oldstmt = get_def_stmt(orig_result);
109150 + tree phi_ssa_name = NULL_TREE;
109151 + unsigned int i;
109152 +
109153 + pointer_set_insert(visited, oldstmt);
109154 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
109155 + tree arg, new_arg;
109156 +
109157 + arg = gimple_phi_arg_def(oldstmt, i);
109158 +
109159 + new_arg = expand(visited, arg);
109160 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
109161 + if (i == 0) {
109162 + phi_ssa_name = new_arg;
109163 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
109164 + }
109165 +
109166 + gcc_assert(new_phi != NULL);
109167 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
109168 + }
109169 +
109170 + gcc_assert(new_phi != NULL);
109171 + update_stmt(new_phi);
109172 + return gimple_phi_result(new_phi);
109173 +}
109174 +
109175 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
109176 +{
109177 + const_gimple assign;
109178 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109179 + tree origtype = TREE_TYPE(orig_rhs);
109180 +
109181 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
109182 +
109183 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109184 + return gimple_get_lhs(assign);
109185 +}
109186 +
109187 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
109188 +{
109189 + const_tree rhs1, lhs, rhs1_type, lhs_type;
109190 + enum machine_mode lhs_mode, rhs_mode;
109191 + gimple def_stmt = get_def_stmt(no_const_rhs);
109192 +
109193 + if (!gimple_assign_cast_p(def_stmt))
109194 + return false;
109195 +
109196 + rhs1 = gimple_assign_rhs1(def_stmt);
109197 + lhs = gimple_get_lhs(def_stmt);
109198 + rhs1_type = TREE_TYPE(rhs1);
109199 + lhs_type = TREE_TYPE(lhs);
109200 + rhs_mode = TYPE_MODE(rhs1_type);
109201 + lhs_mode = TYPE_MODE(lhs_type);
109202 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
109203 + return false;
109204 +
109205 + return true;
109206 +}
109207 +
109208 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
109209 +{
109210 + tree rhs1 = gimple_assign_rhs1(stmt);
109211 + tree lhs = gimple_get_lhs(stmt);
109212 + const_tree rhs1_type = TREE_TYPE(rhs1);
109213 + const_tree lhs_type = TREE_TYPE(lhs);
109214 +
109215 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
109216 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109217 +
109218 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
109219 +}
109220 +
109221 +static bool no_uses(tree node)
109222 +{
109223 + imm_use_iterator imm_iter;
109224 + use_operand_p use_p;
109225 +
109226 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
109227 + const_gimple use_stmt = USE_STMT(use_p);
109228 + if (use_stmt == NULL)
109229 + return true;
109230 + if (is_gimple_debug(use_stmt))
109231 + continue;
109232 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
109233 + continue;
109234 + return false;
109235 + }
109236 + return true;
109237 +}
109238 +
109239 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
109240 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
109241 +{
109242 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
109243 + gimple def_stmt = get_def_stmt(lhs);
109244 +
109245 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
109246 + return false;
109247 +
109248 + rhs1 = gimple_assign_rhs1(def_stmt);
109249 + rhs_type = TREE_TYPE(rhs1);
109250 + lhs_type = TREE_TYPE(lhs);
109251 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
109252 + return false;
109253 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
109254 + return false;
109255 +
109256 + def_stmt = get_def_stmt(rhs1);
109257 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
109258 + return false;
109259 +
109260 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
109261 + return false;
109262 +
109263 + rhs1 = gimple_assign_rhs1(def_stmt);
109264 + rhs2 = gimple_assign_rhs2(def_stmt);
109265 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
109266 + return false;
109267 +
109268 + if (is_gimple_constant(rhs2))
109269 + not_const_rhs = rhs1;
109270 + else
109271 + not_const_rhs = rhs2;
109272 +
109273 + return no_uses(not_const_rhs);
109274 +}
109275 +
109276 +static bool skip_lhs_cast_check(const_gimple stmt)
109277 +{
109278 + const_tree rhs = gimple_assign_rhs1(stmt);
109279 + const_gimple def_stmt = get_def_stmt(rhs);
109280 +
109281 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
109282 + if (gimple_code(def_stmt) == GIMPLE_ASM)
109283 + return true;
109284 +
109285 + if (is_const_plus_unsigned_signed_truncation(rhs))
109286 + return true;
109287 +
109288 + return false;
109289 +}
109290 +
109291 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
109292 +{
109293 + bool cast_lhs, cast_rhs;
109294 + tree lhs = gimple_get_lhs(stmt);
109295 + tree rhs = gimple_assign_rhs1(stmt);
109296 + const_tree lhs_type = TREE_TYPE(lhs);
109297 + const_tree rhs_type = TREE_TYPE(rhs);
109298 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
109299 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
109300 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
109301 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
109302 +
109303 + static bool check_lhs[3][4] = {
109304 + // ss su us uu
109305 + { false, true, true, false }, // lhs > rhs
109306 + { false, false, false, false }, // lhs = rhs
109307 + { true, true, true, true }, // lhs < rhs
109308 + };
109309 +
109310 + static bool check_rhs[3][4] = {
109311 + // ss su us uu
109312 + { true, false, true, true }, // lhs > rhs
109313 + { true, false, true, true }, // lhs = rhs
109314 + { true, false, true, true }, // lhs < rhs
109315 + };
109316 +
109317 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
109318 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
109319 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109320 +
109321 + if (lhs_size > rhs_size) {
109322 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109323 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109324 + } else if (lhs_size == rhs_size) {
109325 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109326 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109327 + } else {
109328 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109329 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
109330 + }
109331 +
109332 + if (!cast_lhs && !cast_rhs)
109333 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109334 +
109335 + if (cast_lhs && !skip_lhs_cast_check(stmt))
109336 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
109337 +
109338 + if (cast_rhs)
109339 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
109340 +
109341 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109342 +}
109343 +
109344 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
109345 +{
109346 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
109347 +
109348 + if (gimple_plf(stmt, MY_STMT))
109349 + return lhs;
109350 +
109351 + rhs1 = gimple_assign_rhs1(stmt);
109352 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
109353 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109354 +
109355 + new_rhs1 = expand(visited, rhs1);
109356 +
109357 + if (new_rhs1 == NULL_TREE)
109358 + return create_cast_assign(visited, stmt);
109359 +
109360 + if (gimple_plf(stmt, NO_CAST_CHECK))
109361 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109362 +
109363 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
109364 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
109365 +
109366 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
109367 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
109368 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109369 + }
109370 +
109371 + if (!gimple_assign_cast_p(stmt))
109372 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
109373 +
109374 + return create_cast_overflow_check(visited, new_rhs1, stmt);
109375 +}
109376 +
109377 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
109378 +{
109379 + tree rhs1, lhs = gimple_get_lhs(stmt);
109380 + gimple def_stmt = get_def_stmt(lhs);
109381 +
109382 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
109383 + rhs1 = gimple_assign_rhs1(def_stmt);
109384 +
109385 + if (is_gimple_constant(rhs1))
109386 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109387 +
109388 + switch (TREE_CODE(rhs1)) {
109389 + case SSA_NAME:
109390 + return handle_unary_rhs(visited, def_stmt);
109391 + case ARRAY_REF:
109392 + case BIT_FIELD_REF:
109393 + case ADDR_EXPR:
109394 + case COMPONENT_REF:
109395 + case INDIRECT_REF:
109396 +#if BUILDING_GCC_VERSION >= 4006
109397 + case MEM_REF:
109398 +#endif
109399 + case TARGET_MEM_REF:
109400 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109401 + case PARM_DECL:
109402 + case VAR_DECL:
109403 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109404 +
109405 + default:
109406 + debug_gimple_stmt(def_stmt);
109407 + debug_tree(rhs1);
109408 + gcc_unreachable();
109409 + }
109410 +}
109411 +
109412 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
109413 +{
109414 + gimple cond_stmt;
109415 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
109416 +
109417 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
109418 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
109419 + update_stmt(cond_stmt);
109420 +}
109421 +
109422 +static tree create_string_param(tree string)
109423 +{
109424 + tree i_type, a_type;
109425 + const int length = TREE_STRING_LENGTH(string);
109426 +
109427 + gcc_assert(length > 0);
109428 +
109429 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
109430 + a_type = build_array_type(char_type_node, i_type);
109431 +
109432 + TREE_TYPE(string) = a_type;
109433 + TREE_CONSTANT(string) = 1;
109434 + TREE_READONLY(string) = 1;
109435 +
109436 + return build1(ADDR_EXPR, ptr_type_node, string);
109437 +}
109438 +
109439 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
109440 +{
109441 + gimple func_stmt;
109442 + const_gimple def_stmt;
109443 + const_tree loc_line;
109444 + tree loc_file, ssa_name, current_func;
109445 + expanded_location xloc;
109446 + char *ssa_name_buf;
109447 + int len;
109448 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
109449 +
109450 + def_stmt = get_def_stmt(arg);
109451 + xloc = expand_location(gimple_location(def_stmt));
109452 +
109453 + if (!gimple_has_location(def_stmt)) {
109454 + xloc = expand_location(gimple_location(stmt));
109455 + if (!gimple_has_location(stmt))
109456 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
109457 + }
109458 +
109459 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
109460 +
109461 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
109462 + loc_file = create_string_param(loc_file);
109463 +
109464 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
109465 + current_func = create_string_param(current_func);
109466 +
109467 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
109468 + call_count++;
109469 + 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);
109470 + gcc_assert(len > 0);
109471 + ssa_name = build_string(len + 1, ssa_name_buf);
109472 + free(ssa_name_buf);
109473 + ssa_name = create_string_param(ssa_name);
109474 +
109475 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
109476 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
109477 +
109478 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
109479 +}
109480 +
109481 +static void __unused print_the_code_insertions(const_gimple stmt)
109482 +{
109483 + location_t loc = gimple_location(stmt);
109484 +
109485 + inform(loc, "Integer size_overflow check applied here.");
109486 +}
109487 +
109488 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
109489 +{
109490 + basic_block cond_bb, join_bb, bb_true;
109491 + edge e;
109492 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109493 +
109494 + cond_bb = gimple_bb(stmt);
109495 + if (before)
109496 + gsi_prev(&gsi);
109497 + if (gsi_end_p(gsi))
109498 + e = split_block_after_labels(cond_bb);
109499 + else
109500 + e = split_block(cond_bb, gsi_stmt(gsi));
109501 + cond_bb = e->src;
109502 + join_bb = e->dest;
109503 + e->flags = EDGE_FALSE_VALUE;
109504 + e->probability = REG_BR_PROB_BASE;
109505 +
109506 + bb_true = create_empty_bb(cond_bb);
109507 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
109508 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
109509 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
109510 +
109511 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
109512 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
109513 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
109514 +
109515 + if (current_loops != NULL) {
109516 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
109517 + add_bb_to_loop(bb_true, cond_bb->loop_father);
109518 + }
109519 +
109520 + insert_cond(cond_bb, arg, cond_code, type_value);
109521 + insert_cond_result(bb_true, stmt, arg, min);
109522 +
109523 +// print_the_code_insertions(stmt);
109524 +}
109525 +
109526 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
109527 +{
109528 + const_tree rhs_type = TREE_TYPE(rhs);
109529 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
109530 +
109531 + gcc_assert(rhs_type != NULL_TREE);
109532 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
109533 + return;
109534 +
109535 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
109536 +
109537 + if (is_const_plus_unsigned_signed_truncation(rhs))
109538 + return;
109539 +
109540 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
109541 + // typemax (-1) < typemin (0)
109542 + if (TREE_OVERFLOW(type_max))
109543 + return;
109544 +
109545 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
109546 +
109547 + cast_rhs_type = TREE_TYPE(cast_rhs);
109548 + type_max_type = TREE_TYPE(type_max);
109549 + type_min_type = TREE_TYPE(type_min);
109550 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
109551 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
109552 +
109553 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
109554 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
109555 +}
109556 +
109557 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
109558 +{
109559 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
109560 + return false;
109561 + if (!is_gimple_constant(rhs))
109562 + return false;
109563 + return true;
109564 +}
109565 +
109566 +static tree get_def_stmt_rhs(const_tree var)
109567 +{
109568 + tree rhs1, def_stmt_rhs1;
109569 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
109570 +
109571 + def_stmt = get_def_stmt(var);
109572 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
109573 +
109574 + rhs1 = gimple_assign_rhs1(def_stmt);
109575 + rhs1_def_stmt = get_def_stmt(rhs1);
109576 + if (!gimple_assign_cast_p(rhs1_def_stmt))
109577 + return rhs1;
109578 +
109579 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109580 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
109581 +
109582 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
109583 + case GIMPLE_CALL:
109584 + case GIMPLE_NOP:
109585 + case GIMPLE_ASM:
109586 + case GIMPLE_PHI:
109587 + return def_stmt_rhs1;
109588 + case GIMPLE_ASSIGN:
109589 + return rhs1;
109590 + default:
109591 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
109592 + gcc_unreachable();
109593 + }
109594 +}
109595 +
109596 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
109597 +{
109598 + tree new_rhs, orig_rhs;
109599 + void (*gimple_assign_set_rhs)(gimple, tree);
109600 + tree rhs1 = gimple_assign_rhs1(stmt);
109601 + tree rhs2 = gimple_assign_rhs2(stmt);
109602 + tree lhs = gimple_get_lhs(stmt);
109603 +
109604 + if (!check_overflow)
109605 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109606 +
109607 + if (change_rhs == NULL_TREE)
109608 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109609 +
109610 + if (new_rhs2 == NULL_TREE) {
109611 + orig_rhs = rhs1;
109612 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
109613 + } else {
109614 + orig_rhs = rhs2;
109615 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
109616 + }
109617 +
109618 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
109619 +
109620 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
109621 + gimple_assign_set_rhs(stmt, new_rhs);
109622 + update_stmt(stmt);
109623 +
109624 + return create_assign(visited, stmt, lhs, AFTER_STMT);
109625 +}
109626 +
109627 +static bool is_subtraction_special(const_gimple stmt)
109628 +{
109629 + gimple rhs1_def_stmt, rhs2_def_stmt;
109630 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
109631 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
109632 + const_tree rhs1 = gimple_assign_rhs1(stmt);
109633 + const_tree rhs2 = gimple_assign_rhs2(stmt);
109634 +
109635 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
109636 + return false;
109637 +
109638 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
109639 +
109640 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
109641 + return false;
109642 +
109643 + rhs1_def_stmt = get_def_stmt(rhs1);
109644 + rhs2_def_stmt = get_def_stmt(rhs2);
109645 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
109646 + return false;
109647 +
109648 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
109649 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
109650 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
109651 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
109652 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
109653 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
109654 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
109655 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
109656 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
109657 + return false;
109658 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
109659 + return false;
109660 +
109661 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
109662 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
109663 + return true;
109664 +}
109665 +
109666 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
109667 +{
109668 + tree new_rhs1, new_rhs2;
109669 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
109670 + gimple assign, stmt = get_def_stmt(lhs);
109671 + tree rhs1 = gimple_assign_rhs1(stmt);
109672 + tree rhs2 = gimple_assign_rhs2(stmt);
109673 +
109674 + if (!is_subtraction_special(stmt))
109675 + return NULL_TREE;
109676 +
109677 + new_rhs1 = expand(visited, rhs1);
109678 + new_rhs2 = expand(visited, rhs2);
109679 +
109680 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
109681 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
109682 +
109683 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
109684 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
109685 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
109686 + }
109687 +
109688 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
109689 + new_lhs = gimple_get_lhs(assign);
109690 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
109691 +
109692 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109693 +}
109694 +
109695 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
109696 +{
109697 + const_gimple def_stmt;
109698 +
109699 + if (TREE_CODE(rhs) != SSA_NAME)
109700 + return false;
109701 +
109702 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
109703 + return false;
109704 +
109705 + def_stmt = get_def_stmt(rhs);
109706 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
109707 + return false;
109708 +
109709 + return true;
109710 +}
109711 +
109712 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
109713 +{
109714 + tree rhs1, rhs2, new_lhs;
109715 + gimple def_stmt = get_def_stmt(lhs);
109716 + tree new_rhs1 = NULL_TREE;
109717 + tree new_rhs2 = NULL_TREE;
109718 +
109719 + rhs1 = gimple_assign_rhs1(def_stmt);
109720 + rhs2 = gimple_assign_rhs2(def_stmt);
109721 +
109722 + /* no DImode/TImode division in the 32/64 bit kernel */
109723 + switch (gimple_assign_rhs_code(def_stmt)) {
109724 + case RDIV_EXPR:
109725 + case TRUNC_DIV_EXPR:
109726 + case CEIL_DIV_EXPR:
109727 + case FLOOR_DIV_EXPR:
109728 + case ROUND_DIV_EXPR:
109729 + case TRUNC_MOD_EXPR:
109730 + case CEIL_MOD_EXPR:
109731 + case FLOOR_MOD_EXPR:
109732 + case ROUND_MOD_EXPR:
109733 + case EXACT_DIV_EXPR:
109734 + case POINTER_PLUS_EXPR:
109735 + case BIT_AND_EXPR:
109736 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109737 + default:
109738 + break;
109739 + }
109740 +
109741 + new_lhs = handle_integer_truncation(visited, lhs);
109742 + if (new_lhs != NULL_TREE)
109743 + return new_lhs;
109744 +
109745 + if (TREE_CODE(rhs1) == SSA_NAME)
109746 + new_rhs1 = expand(visited, rhs1);
109747 + if (TREE_CODE(rhs2) == SSA_NAME)
109748 + new_rhs2 = expand(visited, rhs2);
109749 +
109750 + if (is_a_neg_overflow(def_stmt, rhs2))
109751 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
109752 + if (is_a_neg_overflow(def_stmt, rhs1))
109753 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
109754 +
109755 +
109756 + if (is_a_constant_overflow(def_stmt, rhs2))
109757 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
109758 + if (is_a_constant_overflow(def_stmt, rhs1))
109759 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
109760 +
109761 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
109762 +}
109763 +
109764 +#if BUILDING_GCC_VERSION >= 4007
109765 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
109766 +{
109767 + if (is_gimple_constant(rhs))
109768 + return cast_a_tree(size_overflow_type, rhs);
109769 + if (TREE_CODE(rhs) != SSA_NAME)
109770 + return NULL_TREE;
109771 + return expand(visited, rhs);
109772 +}
109773 +
109774 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
109775 +{
109776 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
109777 + gimple def_stmt = get_def_stmt(lhs);
109778 +
109779 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
109780 +
109781 + rhs1 = gimple_assign_rhs1(def_stmt);
109782 + rhs2 = gimple_assign_rhs2(def_stmt);
109783 + rhs3 = gimple_assign_rhs3(def_stmt);
109784 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
109785 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
109786 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
109787 +
109788 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
109789 +}
109790 +#endif
109791 +
109792 +static tree get_size_overflow_type(gimple stmt, const_tree node)
109793 +{
109794 + const_tree type;
109795 + tree new_type;
109796 +
109797 + gcc_assert(node != NULL_TREE);
109798 +
109799 + type = TREE_TYPE(node);
109800 +
109801 + if (gimple_plf(stmt, MY_STMT))
109802 + return TREE_TYPE(node);
109803 +
109804 + switch (TYPE_MODE(type)) {
109805 + case QImode:
109806 + new_type = intHI_type_node;
109807 + break;
109808 + case HImode:
109809 + new_type = intSI_type_node;
109810 + break;
109811 + case SImode:
109812 + new_type = intDI_type_node;
109813 + break;
109814 + case DImode:
109815 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
109816 + new_type = intDI_type_node;
109817 + else
109818 + new_type = intTI_type_node;
109819 + break;
109820 + default:
109821 + debug_tree((tree)node);
109822 + error("%s: unsupported gcc configuration.", __func__);
109823 + gcc_unreachable();
109824 + }
109825 +
109826 + if (TYPE_QUALS(type) != 0)
109827 + return build_qualified_type(new_type, TYPE_QUALS(type));
109828 + return new_type;
109829 +}
109830 +
109831 +static tree expand_visited(gimple def_stmt)
109832 +{
109833 + const_gimple next_stmt;
109834 + gimple_stmt_iterator gsi;
109835 + enum gimple_code code = gimple_code(def_stmt);
109836 +
109837 + if (code == GIMPLE_ASM)
109838 + return NULL_TREE;
109839 +
109840 + gsi = gsi_for_stmt(def_stmt);
109841 + gsi_next(&gsi);
109842 +
109843 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
109844 + return NULL_TREE;
109845 + gcc_assert(!gsi_end_p(gsi));
109846 + next_stmt = gsi_stmt(gsi);
109847 +
109848 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
109849 + return NULL_TREE;
109850 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
109851 +
109852 + return get_lhs(next_stmt);
109853 +}
109854 +
109855 +static tree expand(struct pointer_set_t *visited, tree lhs)
109856 +{
109857 + gimple def_stmt;
109858 +
109859 + if (skip_types(lhs))
109860 + return NULL_TREE;
109861 +
109862 + def_stmt = get_def_stmt(lhs);
109863 +
109864 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
109865 + return NULL_TREE;
109866 +
109867 + if (gimple_plf(def_stmt, MY_STMT))
109868 + return lhs;
109869 +
109870 + if (pointer_set_contains(visited, def_stmt))
109871 + return expand_visited(def_stmt);
109872 +
109873 + switch (gimple_code(def_stmt)) {
109874 + case GIMPLE_PHI:
109875 + return handle_phi(visited, lhs);
109876 + case GIMPLE_CALL:
109877 + case GIMPLE_ASM:
109878 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
109879 + case GIMPLE_ASSIGN:
109880 + switch (gimple_num_ops(def_stmt)) {
109881 + case 2:
109882 + return handle_unary_ops(visited, def_stmt);
109883 + case 3:
109884 + return handle_binary_ops(visited, lhs);
109885 +#if BUILDING_GCC_VERSION >= 4007
109886 + case 4:
109887 + return handle_ternary_ops(visited, lhs);
109888 +#endif
109889 + }
109890 + default:
109891 + debug_gimple_stmt(def_stmt);
109892 + error("%s: unknown gimple code", __func__);
109893 + gcc_unreachable();
109894 + }
109895 +}
109896 +
109897 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
109898 +{
109899 + const_gimple assign;
109900 + tree orig_type = TREE_TYPE(orig_node);
109901 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
109902 +
109903 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
109904 + return gimple_get_lhs(assign);
109905 +}
109906 +
109907 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
109908 +{
109909 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
109910 + update_stmt(stmt);
109911 +}
109912 +
109913 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
109914 +{
109915 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
109916 + update_stmt(stmt);
109917 +}
109918 +
109919 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
109920 +{
109921 + tree arg;
109922 + const_tree origarg;
109923 +
109924 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
109925 + return true;
109926 +
109927 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
109928 + while (origarg && *argnum) {
109929 + (*argnum)--;
109930 + origarg = TREE_CHAIN(origarg);
109931 + }
109932 +
109933 + gcc_assert(*argnum == 0);
109934 +
109935 + gcc_assert(origarg != NULL_TREE);
109936 + *argnum = 0;
109937 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
109938 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
109939 + return true;
109940 + return false;
109941 +}
109942 +
109943 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
109944 +{
109945 + gimple phi = get_def_stmt(result);
109946 + unsigned int i, n = gimple_phi_num_args(phi);
109947 +
109948 + if (!phi)
109949 + return MARK_NO;
109950 +
109951 + pointer_set_insert(visited, phi);
109952 + for (i = 0; i < n; i++) {
109953 + enum mark marked;
109954 + const_tree arg = gimple_phi_arg_def(phi, i);
109955 + marked = pre_expand(visited, search_err_code, arg);
109956 + if (marked != MARK_NO)
109957 + return marked;
109958 + }
109959 + return MARK_NO;
109960 +}
109961 +
109962 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109963 +{
109964 + gimple def_stmt = get_def_stmt(lhs);
109965 + const_tree rhs;
109966 +
109967 + if (!def_stmt)
109968 + return MARK_NO;
109969 +
109970 + rhs = gimple_assign_rhs1(def_stmt);
109971 +
109972 + def_stmt = get_def_stmt(rhs);
109973 + if (is_gimple_constant(rhs))
109974 + search_err_code[FROM_CONST] = true;
109975 +
109976 + return pre_expand(visited, search_err_code, rhs);
109977 +}
109978 +
109979 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
109980 +{
109981 + gimple def_stmt = get_def_stmt(lhs);
109982 + const_tree rhs1, rhs2;
109983 + enum mark marked;
109984 +
109985 + if (!def_stmt)
109986 + return MARK_NO;
109987 +
109988 + search_err_code[CAST_ONLY] = false;
109989 +
109990 + rhs1 = gimple_assign_rhs1(def_stmt);
109991 + rhs2 = gimple_assign_rhs2(def_stmt);
109992 + marked = pre_expand(visited, search_err_code, rhs1);
109993 + if (marked != MARK_NO)
109994 + return marked;
109995 + return pre_expand(visited, search_err_code, rhs2);
109996 +}
109997 +
109998 +static const_tree search_field_decl(const_tree comp_ref)
109999 +{
110000 + const_tree field = NULL_TREE;
110001 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
110002 +
110003 + for (i = 0; i < len; i++) {
110004 + field = TREE_OPERAND(comp_ref, i);
110005 + if (TREE_CODE(field) == FIELD_DECL)
110006 + break;
110007 + }
110008 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
110009 + return field;
110010 +}
110011 +
110012 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
110013 +{
110014 + const_tree attr, p;
110015 +
110016 + // 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);
110017 + if (fndecl == NULL_TREE)
110018 + return MARK_NO;
110019 +
110020 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
110021 + if (!attr || !TREE_VALUE(attr))
110022 + return MARK_NO;
110023 +
110024 + p = TREE_VALUE(attr);
110025 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
110026 + return MARK_TURN_OFF;
110027 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
110028 + return MARK_NOT_INTENTIONAL;
110029 + if (argnum == 0) {
110030 + gcc_assert(current_function_decl == fndecl);
110031 + return MARK_NO;
110032 + }
110033 +
110034 + do {
110035 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
110036 + return MARK_YES;
110037 + p = TREE_CHAIN(p);
110038 + } while (p);
110039 +
110040 + return MARK_NO;
110041 +}
110042 +
110043 +static void print_missing_msg(tree func, unsigned int argnum)
110044 +{
110045 + unsigned int new_hash;
110046 + size_t len;
110047 + unsigned char tree_codes[CODES_LIMIT];
110048 + location_t loc;
110049 + const char *curfunc;
110050 +
110051 + func = get_original_function_decl(func);
110052 + loc = DECL_SOURCE_LOCATION(func);
110053 + curfunc = get_asm_name(func);
110054 +
110055 + len = get_function_decl(func, tree_codes);
110056 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
110057 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
110058 +}
110059 +
110060 +static unsigned int search_missing_attribute(const_tree arg)
110061 +{
110062 + unsigned int argnum;
110063 + const struct size_overflow_hash *hash;
110064 + const_tree type = TREE_TYPE(arg);
110065 + tree func = get_original_function_decl(current_function_decl);
110066 +
110067 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
110068 +
110069 + if (TREE_CODE(type) == POINTER_TYPE)
110070 + return 0;
110071 +
110072 + argnum = find_arg_number(arg, func);
110073 + if (argnum == 0)
110074 + return 0;
110075 +
110076 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
110077 + return argnum;
110078 +
110079 + hash = get_function_hash(func);
110080 + if (!hash || !(hash->param & (1U << argnum))) {
110081 + print_missing_msg(func, argnum);
110082 + return 0;
110083 + }
110084 + return argnum;
110085 +}
110086 +
110087 +static enum mark is_already_marked(const_tree lhs)
110088 +{
110089 + unsigned int argnum;
110090 + const_tree fndecl;
110091 +
110092 + argnum = search_missing_attribute(lhs);
110093 + fndecl = get_original_function_decl(current_function_decl);
110094 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
110095 + return MARK_YES;
110096 + return MARK_NO;
110097 +}
110098 +
110099 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
110100 +{
110101 + const_gimple def_stmt;
110102 +
110103 + if (skip_types(lhs))
110104 + return MARK_NO;
110105 +
110106 + if (TREE_CODE(lhs) == PARM_DECL)
110107 + return is_already_marked(lhs);
110108 +
110109 + if (TREE_CODE(lhs) == COMPONENT_REF) {
110110 + const_tree field, attr;
110111 +
110112 + field = search_field_decl(lhs);
110113 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
110114 + if (!attr || !TREE_VALUE(attr))
110115 + return MARK_NO;
110116 + return MARK_YES;
110117 + }
110118 +
110119 + def_stmt = get_def_stmt(lhs);
110120 +
110121 + if (!def_stmt)
110122 + return MARK_NO;
110123 +
110124 + if (pointer_set_contains(visited, def_stmt))
110125 + return MARK_NO;
110126 +
110127 + switch (gimple_code(def_stmt)) {
110128 + case GIMPLE_NOP:
110129 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
110130 + return is_already_marked(lhs);
110131 + return MARK_NO;
110132 + case GIMPLE_PHI:
110133 + return walk_phi(visited, search_err_code, lhs);
110134 + case GIMPLE_CALL:
110135 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
110136 + return MARK_TURN_OFF;
110137 + check_function_hash(def_stmt);
110138 + return MARK_NO;
110139 + case GIMPLE_ASM:
110140 + search_err_code[CAST_ONLY] = false;
110141 + return MARK_NO;
110142 + case GIMPLE_ASSIGN:
110143 + switch (gimple_num_ops(def_stmt)) {
110144 + case 2:
110145 + return walk_unary_ops(visited, search_err_code, lhs);
110146 + case 3:
110147 + return walk_binary_ops(visited, search_err_code, lhs);
110148 + }
110149 + default:
110150 + debug_gimple_stmt((gimple)def_stmt);
110151 + error("%s: unknown gimple code", __func__);
110152 + gcc_unreachable();
110153 + }
110154 +}
110155 +
110156 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
110157 +static bool skip_asm(const_tree arg)
110158 +{
110159 + gimple def_stmt = get_def_stmt(arg);
110160 +
110161 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
110162 + return false;
110163 +
110164 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
110165 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
110166 +}
110167 +
110168 +/*
110169 +0</MARK_YES: no dup, search attributes (so, int)
110170 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
110171 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
110172 +*/
110173 +
110174 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
110175 +{
110176 + struct pointer_set_t *visited;
110177 + enum mark is_marked, is_found;
110178 + location_t loc;
110179 + bool search_err_code[2] = {true, false};
110180 +
110181 + is_marked = mark_status(current_function_decl, 0);
110182 + if (is_marked == MARK_TURN_OFF)
110183 + return true;
110184 +
110185 + is_marked = mark_status(fndecl, argnum + 1);
110186 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
110187 + return true;
110188 +
110189 + visited = pointer_set_create();
110190 + is_found = pre_expand(visited, search_err_code, arg);
110191 + pointer_set_destroy(visited);
110192 +
110193 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
110194 + return true;
110195 +
110196 + if (where == FROM_ARG && skip_asm(arg))
110197 + return true;
110198 +
110199 + if (is_found == MARK_TURN_OFF)
110200 + return true;
110201 +
110202 + if ((is_found == MARK_YES && is_marked == MARK_YES))
110203 + return true;
110204 +
110205 + if (is_found == MARK_YES) {
110206 + loc = DECL_SOURCE_LOCATION(fndecl);
110207 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
110208 + return true;
110209 + }
110210 + return false;
110211 +}
110212 +
110213 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
110214 +{
110215 + struct pointer_set_t *visited;
110216 + tree arg, new_arg;
110217 + bool match;
110218 +
110219 + if (argnum == 0)
110220 + return;
110221 +
110222 + argnum--;
110223 +
110224 + match = get_function_arg(&argnum, fndecl);
110225 + if (!match)
110226 + return;
110227 + gcc_assert(gimple_call_num_args(stmt) > argnum);
110228 + arg = gimple_call_arg(stmt, argnum);
110229 + if (arg == NULL_TREE)
110230 + return;
110231 +
110232 + if (skip_types(arg))
110233 + return;
110234 +
110235 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
110236 + return;
110237 +
110238 + visited = pointer_set_create();
110239 + new_arg = expand(visited, arg);
110240 + pointer_set_destroy(visited);
110241 +
110242 + if (new_arg == NULL_TREE)
110243 + return;
110244 +
110245 + change_function_arg(stmt, arg, argnum, new_arg);
110246 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
110247 +}
110248 +
110249 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
110250 +{
110251 + tree p = TREE_VALUE(attr);
110252 + do {
110253 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
110254 + p = TREE_CHAIN(p);
110255 + } while (p);
110256 +}
110257 +
110258 +static void handle_function_by_hash(gimple stmt, tree fndecl)
110259 +{
110260 + unsigned int num;
110261 + const struct size_overflow_hash *hash;
110262 +
110263 + hash = get_function_hash(fndecl);
110264 + if (!hash)
110265 + return;
110266 +
110267 + for (num = 0; num <= MAX_PARAM; num++)
110268 + if (hash->param & (1U << num))
110269 + handle_function_arg(stmt, fndecl, num);
110270 +}
110271 +
110272 +static bool check_return_value(void)
110273 +{
110274 + const struct size_overflow_hash *hash;
110275 +
110276 + hash = get_function_hash(current_function_decl);
110277 + if (!hash || !(hash->param & 1U << 0))
110278 + return false;
110279 +
110280 + return true;
110281 +}
110282 +
110283 +static void handle_return_value(gimple ret_stmt)
110284 +{
110285 + struct pointer_set_t *visited;
110286 + tree ret, new_ret;
110287 +
110288 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
110289 + return;
110290 +
110291 + ret = gimple_return_retval(ret_stmt);
110292 +
110293 + if (skip_types(ret))
110294 + return;
110295 +
110296 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
110297 + return;
110298 +
110299 + visited = pointer_set_create();
110300 + new_ret = expand(visited, ret);
110301 + pointer_set_destroy(visited);
110302 +
110303 + change_function_return(ret_stmt, ret, new_ret);
110304 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
110305 +}
110306 +
110307 +static void set_plf_false(void)
110308 +{
110309 + basic_block bb;
110310 +
110311 + FOR_ALL_BB(bb) {
110312 + gimple_stmt_iterator si;
110313 +
110314 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
110315 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110316 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
110317 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
110318 + }
110319 +}
110320 +
110321 +static unsigned int handle_function(void)
110322 +{
110323 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
110324 + bool check_ret;
110325 +
110326 + set_plf_false();
110327 +
110328 + check_ret = check_return_value();
110329 +
110330 + do {
110331 + gimple_stmt_iterator gsi;
110332 + next = bb->next_bb;
110333 +
110334 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110335 + tree fndecl, attr;
110336 + gimple stmt = gsi_stmt(gsi);
110337 +
110338 + if (check_ret)
110339 + handle_return_value(stmt);
110340 +
110341 + if (!(is_gimple_call(stmt)))
110342 + continue;
110343 + fndecl = gimple_call_fndecl(stmt);
110344 + if (fndecl == NULL_TREE)
110345 + continue;
110346 + if (gimple_call_num_args(stmt) == 0)
110347 + continue;
110348 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
110349 + if (!attr || !TREE_VALUE(attr))
110350 + handle_function_by_hash(stmt, fndecl);
110351 + else
110352 + handle_function_by_attribute(stmt, attr, fndecl);
110353 + gsi = gsi_for_stmt(stmt);
110354 + next = gimple_bb(stmt)->next_bb;
110355 + }
110356 + bb = next;
110357 + } while (bb);
110358 + return 0;
110359 +}
110360 +
110361 +static struct gimple_opt_pass size_overflow_pass = {
110362 + .pass = {
110363 + .type = GIMPLE_PASS,
110364 + .name = "size_overflow",
110365 +#if BUILDING_GCC_VERSION >= 4008
110366 + .optinfo_flags = OPTGROUP_NONE,
110367 +#endif
110368 + .gate = NULL,
110369 + .execute = handle_function,
110370 + .sub = NULL,
110371 + .next = NULL,
110372 + .static_pass_number = 0,
110373 + .tv_id = TV_NONE,
110374 + .properties_required = PROP_cfg,
110375 + .properties_provided = 0,
110376 + .properties_destroyed = 0,
110377 + .todo_flags_start = 0,
110378 + .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
110379 + }
110380 +};
110381 +
110382 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
110383 +{
110384 + tree fntype;
110385 +
110386 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
110387 +
110388 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
110389 + fntype = build_function_type_list(void_type_node,
110390 + const_char_ptr_type_node,
110391 + unsigned_type_node,
110392 + const_char_ptr_type_node,
110393 + const_char_ptr_type_node,
110394 + NULL_TREE);
110395 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
110396 +
110397 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
110398 + TREE_PUBLIC(report_size_overflow_decl) = 1;
110399 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
110400 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
110401 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
110402 +}
110403 +
110404 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110405 +{
110406 + int i;
110407 + const char * const plugin_name = plugin_info->base_name;
110408 + const int argc = plugin_info->argc;
110409 + const struct plugin_argument * const argv = plugin_info->argv;
110410 + bool enable = true;
110411 +
110412 + struct register_pass_info size_overflow_pass_info = {
110413 + .pass = &size_overflow_pass.pass,
110414 + .reference_pass_name = "ssa",
110415 + .ref_pass_instance_number = 1,
110416 + .pos_op = PASS_POS_INSERT_AFTER
110417 + };
110418 +
110419 + if (!plugin_default_version_check(version, &gcc_version)) {
110420 + error(G_("incompatible gcc/plugin versions"));
110421 + return 1;
110422 + }
110423 +
110424 + for (i = 0; i < argc; ++i) {
110425 + if (!strcmp(argv[i].key, "no-size-overflow")) {
110426 + enable = false;
110427 + continue;
110428 + }
110429 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110430 + }
110431 +
110432 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
110433 + if (enable) {
110434 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
110435 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
110436 + }
110437 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
110438 +
110439 + return 0;
110440 +}
110441 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
110442 new file mode 100644
110443 index 0000000..ac2901e
110444 --- /dev/null
110445 +++ b/tools/gcc/stackleak_plugin.c
110446 @@ -0,0 +1,327 @@
110447 +/*
110448 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
110449 + * Licensed under the GPL v2
110450 + *
110451 + * Note: the choice of the license means that the compilation process is
110452 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110453 + * but for the kernel it doesn't matter since it doesn't link against
110454 + * any of the gcc libraries
110455 + *
110456 + * gcc plugin to help implement various PaX features
110457 + *
110458 + * - track lowest stack pointer
110459 + *
110460 + * TODO:
110461 + * - initialize all local variables
110462 + *
110463 + * BUGS:
110464 + * - none known
110465 + */
110466 +#include "gcc-plugin.h"
110467 +#include "config.h"
110468 +#include "system.h"
110469 +#include "coretypes.h"
110470 +#include "tree.h"
110471 +#include "tree-pass.h"
110472 +#include "flags.h"
110473 +#include "intl.h"
110474 +#include "toplev.h"
110475 +#include "plugin.h"
110476 +//#include "expr.h" where are you...
110477 +#include "diagnostic.h"
110478 +#include "plugin-version.h"
110479 +#include "tm.h"
110480 +#include "function.h"
110481 +#include "basic-block.h"
110482 +#include "gimple.h"
110483 +#include "rtl.h"
110484 +#include "emit-rtl.h"
110485 +
110486 +#if BUILDING_GCC_VERSION >= 4008
110487 +#define TODO_dump_func 0
110488 +#endif
110489 +
110490 +extern void print_gimple_stmt(FILE *, gimple, int, int);
110491 +
110492 +int plugin_is_GPL_compatible;
110493 +
110494 +static int track_frame_size = -1;
110495 +static const char track_function[] = "pax_track_stack";
110496 +static const char check_function[] = "pax_check_alloca";
110497 +static bool init_locals;
110498 +
110499 +static struct plugin_info stackleak_plugin_info = {
110500 + .version = "201302112000",
110501 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
110502 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
110503 +};
110504 +
110505 +static bool gate_stackleak_track_stack(void);
110506 +static unsigned int execute_stackleak_tree_instrument(void);
110507 +static unsigned int execute_stackleak_final(void);
110508 +
110509 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
110510 + .pass = {
110511 + .type = GIMPLE_PASS,
110512 + .name = "stackleak_tree_instrument",
110513 +#if BUILDING_GCC_VERSION >= 4008
110514 + .optinfo_flags = OPTGROUP_NONE,
110515 +#endif
110516 + .gate = gate_stackleak_track_stack,
110517 + .execute = execute_stackleak_tree_instrument,
110518 + .sub = NULL,
110519 + .next = NULL,
110520 + .static_pass_number = 0,
110521 + .tv_id = TV_NONE,
110522 + .properties_required = PROP_gimple_leh | PROP_cfg,
110523 + .properties_provided = 0,
110524 + .properties_destroyed = 0,
110525 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
110526 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
110527 + }
110528 +};
110529 +
110530 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
110531 + .pass = {
110532 + .type = RTL_PASS,
110533 + .name = "stackleak_final",
110534 +#if BUILDING_GCC_VERSION >= 4008
110535 + .optinfo_flags = OPTGROUP_NONE,
110536 +#endif
110537 + .gate = gate_stackleak_track_stack,
110538 + .execute = execute_stackleak_final,
110539 + .sub = NULL,
110540 + .next = NULL,
110541 + .static_pass_number = 0,
110542 + .tv_id = TV_NONE,
110543 + .properties_required = 0,
110544 + .properties_provided = 0,
110545 + .properties_destroyed = 0,
110546 + .todo_flags_start = 0,
110547 + .todo_flags_finish = TODO_dump_func
110548 + }
110549 +};
110550 +
110551 +static bool gate_stackleak_track_stack(void)
110552 +{
110553 + return track_frame_size >= 0;
110554 +}
110555 +
110556 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
110557 +{
110558 + gimple check_alloca;
110559 + tree fntype, fndecl, alloca_size;
110560 +
110561 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
110562 + fndecl = build_fn_decl(check_function, fntype);
110563 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110564 +
110565 + // insert call to void pax_check_alloca(unsigned long size)
110566 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
110567 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
110568 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
110569 +}
110570 +
110571 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
110572 +{
110573 + gimple track_stack;
110574 + tree fntype, fndecl;
110575 +
110576 + fntype = build_function_type_list(void_type_node, NULL_TREE);
110577 + fndecl = build_fn_decl(track_function, fntype);
110578 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
110579 +
110580 + // insert call to void pax_track_stack(void)
110581 + track_stack = gimple_build_call(fndecl, 0);
110582 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
110583 +}
110584 +
110585 +#if BUILDING_GCC_VERSION == 4005
110586 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
110587 +{
110588 + tree fndecl;
110589 +
110590 + if (!is_gimple_call(stmt))
110591 + return false;
110592 + fndecl = gimple_call_fndecl(stmt);
110593 + if (!fndecl)
110594 + return false;
110595 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
110596 + return false;
110597 +// print_node(stderr, "pax", fndecl, 4);
110598 + return DECL_FUNCTION_CODE(fndecl) == code;
110599 +}
110600 +#endif
110601 +
110602 +static bool is_alloca(gimple stmt)
110603 +{
110604 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
110605 + return true;
110606 +
110607 +#if BUILDING_GCC_VERSION >= 4007
110608 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
110609 + return true;
110610 +#endif
110611 +
110612 + return false;
110613 +}
110614 +
110615 +static unsigned int execute_stackleak_tree_instrument(void)
110616 +{
110617 + basic_block bb, entry_bb;
110618 + bool prologue_instrumented = false, is_leaf = true;
110619 +
110620 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
110621 +
110622 + // 1. loop through BBs and GIMPLE statements
110623 + FOR_EACH_BB(bb) {
110624 + gimple_stmt_iterator gsi;
110625 +
110626 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110627 + gimple stmt;
110628 +
110629 + stmt = gsi_stmt(gsi);
110630 +
110631 + if (is_gimple_call(stmt))
110632 + is_leaf = false;
110633 +
110634 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
110635 + if (!is_alloca(stmt))
110636 + continue;
110637 +
110638 + // 2. insert stack overflow check before each __builtin_alloca call
110639 + stackleak_check_alloca(&gsi);
110640 +
110641 + // 3. insert track call after each __builtin_alloca call
110642 + stackleak_add_instrumentation(&gsi);
110643 + if (bb == entry_bb)
110644 + prologue_instrumented = true;
110645 + }
110646 + }
110647 +
110648 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
110649 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
110650 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
110651 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
110652 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
110653 + return 0;
110654 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
110655 + return 0;
110656 +
110657 + // 4. insert track call at the beginning
110658 + if (!prologue_instrumented) {
110659 + gimple_stmt_iterator gsi;
110660 +
110661 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110662 + if (dom_info_available_p(CDI_DOMINATORS))
110663 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110664 + gsi = gsi_start_bb(bb);
110665 + stackleak_add_instrumentation(&gsi);
110666 + }
110667 +
110668 + return 0;
110669 +}
110670 +
110671 +static unsigned int execute_stackleak_final(void)
110672 +{
110673 + rtx insn, next;
110674 +
110675 + if (cfun->calls_alloca)
110676 + return 0;
110677 +
110678 + // keep calls only if function frame is big enough
110679 + if (get_frame_size() >= track_frame_size)
110680 + return 0;
110681 +
110682 + // 1. find pax_track_stack calls
110683 + for (insn = get_insns(); insn; insn = next) {
110684 + // 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))
110685 + rtx body;
110686 +
110687 + next = NEXT_INSN(insn);
110688 + if (!CALL_P(insn))
110689 + continue;
110690 + body = PATTERN(insn);
110691 + if (GET_CODE(body) != CALL)
110692 + continue;
110693 + body = XEXP(body, 0);
110694 + if (GET_CODE(body) != MEM)
110695 + continue;
110696 + body = XEXP(body, 0);
110697 + if (GET_CODE(body) != SYMBOL_REF)
110698 + continue;
110699 + if (strcmp(XSTR(body, 0), track_function))
110700 + continue;
110701 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110702 + // 2. delete call
110703 + delete_insn_and_edges(insn);
110704 +#if BUILDING_GCC_VERSION >= 4007
110705 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
110706 + insn = next;
110707 + next = NEXT_INSN(insn);
110708 + delete_insn_and_edges(insn);
110709 + }
110710 +#endif
110711 + }
110712 +
110713 +// print_simple_rtl(stderr, get_insns());
110714 +// print_rtl(stderr, get_insns());
110715 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
110716 +
110717 + return 0;
110718 +}
110719 +
110720 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
110721 +{
110722 + const char * const plugin_name = plugin_info->base_name;
110723 + const int argc = plugin_info->argc;
110724 + const struct plugin_argument * const argv = plugin_info->argv;
110725 + int i;
110726 + struct register_pass_info stackleak_tree_instrument_pass_info = {
110727 + .pass = &stackleak_tree_instrument_pass.pass,
110728 +// .reference_pass_name = "tree_profile",
110729 + .reference_pass_name = "optimized",
110730 + .ref_pass_instance_number = 1,
110731 + .pos_op = PASS_POS_INSERT_BEFORE
110732 + };
110733 + struct register_pass_info stackleak_final_pass_info = {
110734 + .pass = &stackleak_final_rtl_opt_pass.pass,
110735 + .reference_pass_name = "final",
110736 + .ref_pass_instance_number = 1,
110737 + .pos_op = PASS_POS_INSERT_BEFORE
110738 + };
110739 +
110740 + if (!plugin_default_version_check(version, &gcc_version)) {
110741 + error(G_("incompatible gcc/plugin versions"));
110742 + return 1;
110743 + }
110744 +
110745 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
110746 +
110747 + for (i = 0; i < argc; ++i) {
110748 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
110749 + if (!argv[i].value) {
110750 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110751 + continue;
110752 + }
110753 + track_frame_size = atoi(argv[i].value);
110754 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
110755 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110756 + continue;
110757 + }
110758 + if (!strcmp(argv[i].key, "initialize-locals")) {
110759 + if (argv[i].value) {
110760 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
110761 + continue;
110762 + }
110763 + init_locals = true;
110764 + continue;
110765 + }
110766 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
110767 + }
110768 +
110769 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
110770 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
110771 +
110772 + return 0;
110773 +}
110774 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
110775 new file mode 100644
110776 index 0000000..4fae911
110777 --- /dev/null
110778 +++ b/tools/gcc/structleak_plugin.c
110779 @@ -0,0 +1,277 @@
110780 +/*
110781 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
110782 + * Licensed under the GPL v2
110783 + *
110784 + * Note: the choice of the license means that the compilation process is
110785 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
110786 + * but for the kernel it doesn't matter since it doesn't link against
110787 + * any of the gcc libraries
110788 + *
110789 + * gcc plugin to forcibly initialize certain local variables that could
110790 + * otherwise leak kernel stack to userland if they aren't properly initialized
110791 + * by later code
110792 + *
110793 + * Homepage: http://pax.grsecurity.net/
110794 + *
110795 + * Usage:
110796 + * $ # for 4.5/4.6/C based 4.7
110797 + * $ 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
110798 + * $ # for C++ based 4.7/4.8+
110799 + * $ 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
110800 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
110801 + *
110802 + * TODO: eliminate redundant initializers
110803 + * increase type coverage
110804 + */
110805 +
110806 +#include "gcc-plugin.h"
110807 +#include "config.h"
110808 +#include "system.h"
110809 +#include "coretypes.h"
110810 +#include "tree.h"
110811 +#include "tree-pass.h"
110812 +#include "intl.h"
110813 +#include "plugin-version.h"
110814 +#include "tm.h"
110815 +#include "toplev.h"
110816 +#include "function.h"
110817 +#include "tree-flow.h"
110818 +#include "plugin.h"
110819 +#include "gimple.h"
110820 +#include "diagnostic.h"
110821 +#include "cfgloop.h"
110822 +#include "langhooks.h"
110823 +
110824 +#if BUILDING_GCC_VERSION >= 4008
110825 +#define TODO_dump_func 0
110826 +#endif
110827 +
110828 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
110829 +
110830 +// unused type flag in all versions 4.5-4.8
110831 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
110832 +
110833 +int plugin_is_GPL_compatible;
110834 +void debug_gimple_stmt(gimple gs);
110835 +
110836 +static struct plugin_info structleak_plugin_info = {
110837 + .version = "201304082245",
110838 + .help = "disable\tdo not activate plugin\n",
110839 +};
110840 +
110841 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
110842 +{
110843 + *no_add_attrs = true;
110844 +
110845 + // check for types? for now accept everything linux has to offer
110846 + if (TREE_CODE(*node) != FIELD_DECL)
110847 + return NULL_TREE;
110848 +
110849 + *no_add_attrs = false;
110850 + return NULL_TREE;
110851 +}
110852 +
110853 +static struct attribute_spec user_attr = {
110854 + .name = "user",
110855 + .min_length = 0,
110856 + .max_length = 0,
110857 + .decl_required = false,
110858 + .type_required = false,
110859 + .function_type_required = false,
110860 + .handler = handle_user_attribute,
110861 +#if BUILDING_GCC_VERSION >= 4007
110862 + .affects_type_identity = true
110863 +#endif
110864 +};
110865 +
110866 +static void register_attributes(void *event_data, void *data)
110867 +{
110868 + register_attribute(&user_attr);
110869 +// register_attribute(&force_attr);
110870 +}
110871 +
110872 +static tree get_field_type(tree field)
110873 +{
110874 + return strip_array_types(TREE_TYPE(field));
110875 +}
110876 +
110877 +static bool is_userspace_type(tree type)
110878 +{
110879 + tree field;
110880 +
110881 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
110882 + tree fieldtype = get_field_type(field);
110883 + enum tree_code code = TREE_CODE(fieldtype);
110884 +
110885 + if (code == RECORD_TYPE || code == UNION_TYPE)
110886 + if (is_userspace_type(fieldtype))
110887 + return true;
110888 +
110889 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
110890 + return true;
110891 + }
110892 + return false;
110893 +}
110894 +
110895 +static void finish_type(void *event_data, void *data)
110896 +{
110897 + tree type = (tree)event_data;
110898 +
110899 + if (TYPE_USERSPACE(type))
110900 + return;
110901 +
110902 + if (is_userspace_type(type))
110903 + TYPE_USERSPACE(type) = 1;
110904 +}
110905 +
110906 +static void initialize(tree var)
110907 +{
110908 + basic_block bb;
110909 + gimple_stmt_iterator gsi;
110910 + tree initializer;
110911 + gimple init_stmt;
110912 +
110913 + // this is the original entry bb before the forced split
110914 + // TODO: check further BBs in case more splits occured before us
110915 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
110916 +
110917 + // first check if the variable is already initialized, warn otherwise
110918 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
110919 + gimple stmt = gsi_stmt(gsi);
110920 + tree rhs1;
110921 +
110922 + // we're looking for an assignment of a single rhs...
110923 + if (!gimple_assign_single_p(stmt))
110924 + continue;
110925 + rhs1 = gimple_assign_rhs1(stmt);
110926 +#if BUILDING_GCC_VERSION >= 4007
110927 + // ... of a non-clobbering expression...
110928 + if (TREE_CLOBBER_P(rhs1))
110929 + continue;
110930 +#endif
110931 + // ... to our variable...
110932 + if (gimple_get_lhs(stmt) != var)
110933 + continue;
110934 + // if it's an initializer then we're good
110935 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
110936 + return;
110937 + }
110938 +
110939 + // these aren't the 0days you're looking for
110940 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
110941 +
110942 + // build the initializer expression
110943 + initializer = build_constructor(TREE_TYPE(var), NULL);
110944 +
110945 + // build the initializer stmt
110946 + init_stmt = gimple_build_assign(var, initializer);
110947 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
110948 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
110949 + update_stmt(init_stmt);
110950 +}
110951 +
110952 +static unsigned int handle_function(void)
110953 +{
110954 + basic_block bb;
110955 + unsigned int ret = 0;
110956 + tree var;
110957 +
110958 +#if BUILDING_GCC_VERSION == 4005
110959 + tree vars;
110960 +#else
110961 + unsigned int i;
110962 +#endif
110963 +
110964 + // split the first bb where we can put the forced initializers
110965 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
110966 + if (dom_info_available_p(CDI_DOMINATORS))
110967 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
110968 +
110969 + // enumarate all local variables and forcibly initialize our targets
110970 +#if BUILDING_GCC_VERSION == 4005
110971 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
110972 + var = TREE_VALUE(vars);
110973 +#else
110974 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
110975 +#endif
110976 + tree type = TREE_TYPE(var);
110977 +
110978 + gcc_assert(DECL_P(var));
110979 + if (!auto_var_in_fn_p(var, current_function_decl))
110980 + continue;
110981 +
110982 + // only care about structure types
110983 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
110984 + continue;
110985 +
110986 + // if the type is of interest, examine the variable
110987 + if (TYPE_USERSPACE(type))
110988 + initialize(var);
110989 + }
110990 +
110991 + return ret;
110992 +}
110993 +
110994 +static struct gimple_opt_pass structleak_pass = {
110995 + .pass = {
110996 + .type = GIMPLE_PASS,
110997 + .name = "structleak",
110998 +#if BUILDING_GCC_VERSION >= 4008
110999 + .optinfo_flags = OPTGROUP_NONE,
111000 +#endif
111001 + .gate = NULL,
111002 + .execute = handle_function,
111003 + .sub = NULL,
111004 + .next = NULL,
111005 + .static_pass_number = 0,
111006 + .tv_id = TV_NONE,
111007 + .properties_required = PROP_cfg,
111008 + .properties_provided = 0,
111009 + .properties_destroyed = 0,
111010 + .todo_flags_start = 0,
111011 + .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
111012 + }
111013 +};
111014 +
111015 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
111016 +{
111017 + int i;
111018 + const char * const plugin_name = plugin_info->base_name;
111019 + const int argc = plugin_info->argc;
111020 + const struct plugin_argument * const argv = plugin_info->argv;
111021 + bool enable = true;
111022 +
111023 + struct register_pass_info structleak_pass_info = {
111024 + .pass = &structleak_pass.pass,
111025 + .reference_pass_name = "ssa",
111026 + .ref_pass_instance_number = 1,
111027 + .pos_op = PASS_POS_INSERT_AFTER
111028 + };
111029 +
111030 + if (!plugin_default_version_check(version, &gcc_version)) {
111031 + error(G_("incompatible gcc/plugin versions"));
111032 + return 1;
111033 + }
111034 +
111035 + if (strcmp(lang_hooks.name, "GNU C")) {
111036 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
111037 + enable = false;
111038 + }
111039 +
111040 + for (i = 0; i < argc; ++i) {
111041 + if (!strcmp(argv[i].key, "disable")) {
111042 + enable = false;
111043 + continue;
111044 + }
111045 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
111046 + }
111047 +
111048 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
111049 + if (enable) {
111050 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
111051 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
111052 + }
111053 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
111054 +
111055 + return 0;
111056 +}
111057 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
111058 index 280dd82..077b427 100644
111059 --- a/tools/lib/lk/Makefile
111060 +++ b/tools/lib/lk/Makefile
111061 @@ -28,7 +28,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
111062
111063 LIBFILE = liblk.a
111064
111065 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
111066 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
111067 EXTLIBS = -lelf -lpthread -lrt -lm
111068 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
111069 ALL_LDFLAGS = $(LDFLAGS)
111070 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
111071 index 6789d78..4afd019e 100644
111072 --- a/tools/perf/util/include/asm/alternative-asm.h
111073 +++ b/tools/perf/util/include/asm/alternative-asm.h
111074 @@ -5,4 +5,7 @@
111075
111076 #define altinstruction_entry #
111077
111078 + .macro pax_force_retaddr rip=0, reload=0
111079 + .endm
111080 +
111081 #endif
111082 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
111083 index 96b919d..c49bb74 100644
111084 --- a/tools/perf/util/include/linux/compiler.h
111085 +++ b/tools/perf/util/include/linux/compiler.h
111086 @@ -18,4 +18,12 @@
111087 #define __force
111088 #endif
111089
111090 +#ifndef __size_overflow
111091 +# define __size_overflow(...)
111092 +#endif
111093 +
111094 +#ifndef __intentional_overflow
111095 +# define __intentional_overflow(...)
111096 +#endif
111097 +
111098 #endif
111099 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
111100 index 1580dd4..5627b5b 100644
111101 --- a/virt/kvm/kvm_main.c
111102 +++ b/virt/kvm/kvm_main.c
111103 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
111104
111105 static cpumask_var_t cpus_hardware_enabled;
111106 static int kvm_usage_count = 0;
111107 -static atomic_t hardware_enable_failed;
111108 +static atomic_unchecked_t hardware_enable_failed;
111109
111110 struct kmem_cache *kvm_vcpu_cache;
111111 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
111112
111113 -static __read_mostly struct preempt_ops kvm_preempt_ops;
111114 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
111115 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
111116 +static struct preempt_ops kvm_preempt_ops = {
111117 + .sched_in = kvm_sched_in,
111118 + .sched_out = kvm_sched_out,
111119 +};
111120
111121 struct dentry *kvm_debugfs_dir;
111122
111123 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
111124 /* We can read the guest memory with __xxx_user() later on. */
111125 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
111126 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
111127 - !access_ok(VERIFY_WRITE,
111128 + !__access_ok(VERIFY_WRITE,
111129 (void __user *)(unsigned long)mem->userspace_addr,
111130 mem->memory_size)))
111131 goto out;
111132 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
111133 return 0;
111134 }
111135
111136 -static struct file_operations kvm_vcpu_fops = {
111137 +static file_operations_no_const kvm_vcpu_fops __read_only = {
111138 .release = kvm_vcpu_release,
111139 .unlocked_ioctl = kvm_vcpu_ioctl,
111140 #ifdef CONFIG_COMPAT
111141 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
111142 return 0;
111143 }
111144
111145 -static struct file_operations kvm_vm_fops = {
111146 +static file_operations_no_const kvm_vm_fops __read_only = {
111147 .release = kvm_vm_release,
111148 .unlocked_ioctl = kvm_vm_ioctl,
111149 #ifdef CONFIG_COMPAT
111150 @@ -2662,7 +2667,7 @@ out:
111151 return r;
111152 }
111153
111154 -static struct file_operations kvm_chardev_ops = {
111155 +static file_operations_no_const kvm_chardev_ops __read_only = {
111156 .unlocked_ioctl = kvm_dev_ioctl,
111157 .compat_ioctl = kvm_dev_ioctl,
111158 .llseek = noop_llseek,
111159 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
111160
111161 if (r) {
111162 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
111163 - atomic_inc(&hardware_enable_failed);
111164 + atomic_inc_unchecked(&hardware_enable_failed);
111165 printk(KERN_INFO "kvm: enabling virtualization on "
111166 "CPU%d failed\n", cpu);
111167 }
111168 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
111169
111170 kvm_usage_count++;
111171 if (kvm_usage_count == 1) {
111172 - atomic_set(&hardware_enable_failed, 0);
111173 + atomic_set_unchecked(&hardware_enable_failed, 0);
111174 on_each_cpu(hardware_enable_nolock, NULL, 1);
111175
111176 - if (atomic_read(&hardware_enable_failed)) {
111177 + if (atomic_read_unchecked(&hardware_enable_failed)) {
111178 hardware_disable_all_nolock();
111179 r = -EBUSY;
111180 }
111181 @@ -3100,7 +3105,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
111182 kvm_arch_vcpu_put(vcpu);
111183 }
111184
111185 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111186 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111187 struct module *module)
111188 {
111189 int r;
111190 @@ -3147,7 +3152,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111191 if (!vcpu_align)
111192 vcpu_align = __alignof__(struct kvm_vcpu);
111193 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
111194 - 0, NULL);
111195 + SLAB_USERCOPY, NULL);
111196 if (!kvm_vcpu_cache) {
111197 r = -ENOMEM;
111198 goto out_free_3;
111199 @@ -3157,9 +3162,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111200 if (r)
111201 goto out_free;
111202
111203 + pax_open_kernel();
111204 kvm_chardev_ops.owner = module;
111205 kvm_vm_fops.owner = module;
111206 kvm_vcpu_fops.owner = module;
111207 + pax_close_kernel();
111208
111209 r = misc_register(&kvm_dev);
111210 if (r) {
111211 @@ -3169,9 +3176,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
111212
111213 register_syscore_ops(&kvm_syscore_ops);
111214
111215 - kvm_preempt_ops.sched_in = kvm_sched_in;
111216 - kvm_preempt_ops.sched_out = kvm_sched_out;
111217 -
111218 r = kvm_init_debug();
111219 if (r) {
111220 printk(KERN_ERR "kvm: create debugfs files failed\n");